diff options
Diffstat (limited to 'cmd/planr')
-rw-r--r-- | cmd/planr/main.go | 1 | ||||
-rw-r--r-- | cmd/planr/sub/evaluate.go | 36 |
2 files changed, 31 insertions, 6 deletions
diff --git a/cmd/planr/main.go b/cmd/planr/main.go index d179b76..93f1cbf 100644 --- a/cmd/planr/main.go +++ b/cmd/planr/main.go @@ -19,6 +19,7 @@ func printUsage(w io.Writer) { fmt.Fprintln(w, " version ") fmt.Fprintln(w, " build ") fmt.Fprintln(w, " evaluate ") + fmt.Fprintln(w, " evaluate <test0> <test1> ... ") fmt.Fprintln(w, " evaluate -json ") fmt.Fprintln(w, " clean ") fmt.Fprintln(w, " config <key> ") diff --git a/cmd/planr/sub/evaluate.go b/cmd/planr/sub/evaluate.go index 95f88d0..21481a1 100644 --- a/cmd/planr/sub/evaluate.go +++ b/cmd/planr/sub/evaluate.go @@ -14,12 +14,14 @@ type gradingResults struct { Score planr.Scoring } -func prettyPrint(results gradingResults) { +func prettyPrint(results gradingResults, summarize bool) { for _, tr := range results.TestResults { tcPprint(tr) } - printScoring(results.Score) + if summarize { + printScoring(results.Score) + } } func jsonPrint(results gradingResults) { @@ -37,12 +39,34 @@ func Evaluate(runner planr.Runner, params []string, cfg planr.Config) { jsonOutput := f.Bool("json", false, "print json output") - f.Parse(params) - dieIncompatibleVersion(cfg) + f.Parse(params) + tcs := runner.CollectCases() - trs := runner.Evaluate(tcs) + + // Filter those tests which patch IDs in params + filteredTcs := make([]planr.TestCase, 0) + summarizeScore := false + if f.NArg() > 0 { + ids := f.Args() + + membershipFun := make(map[string] bool, 0) + for _, id := range ids { + membershipFun[id] = true + } + + for i := range tcs { + if membershipFun[tcs[i].Cname] { + filteredTcs = append(filteredTcs, tcs[i]) + } + } + } else { + summarizeScore = true + filteredTcs = tcs + } + + trs := runner.Evaluate(filteredTcs) results := gradingResults { TestResults: trs, @@ -52,6 +76,6 @@ func Evaluate(runner planr.Runner, params []string, cfg planr.Config) { if *jsonOutput { jsonPrint(results) } else { - prettyPrint(results) + prettyPrint(results, summarizeScore) } } |