From b9b8d706efd0d9c1848d50e7f8afa1a74ce90037 Mon Sep 17 00:00:00 2001 From: Flu0r1ne Date: Sun, 5 Sep 2021 14:18:31 -0500 Subject: Add mechanism to conditionally run some tests - FS approch should be taken upon revision --- cmd/planr/main.go | 1 + cmd/planr/sub/evaluate.go | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'cmd/planr') 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 ... ") fmt.Fprintln(w, " evaluate -json ") fmt.Fprintln(w, " clean ") fmt.Fprintln(w, " config ") 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) } } -- cgit v1.2.3