aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlu0r1ne <flur01ne@flu0r1ne.net>2021-09-05 14:18:31 -0500
committerFlu0r1ne <flur01ne@flu0r1ne.net>2021-09-05 14:18:31 -0500
commitb9b8d706efd0d9c1848d50e7f8afa1a74ce90037 (patch)
treee79553fcc8ab1c348bfae80ce62a64d791eedfe4
parent0f8c8df3e9d4ed05475b0fa3f1d26253e3de719d (diff)
downloadplanr-b9b8d706efd0d9c1848d50e7f8afa1a74ce90037.tar.xz
planr-b9b8d706efd0d9c1848d50e7f8afa1a74ce90037.zip
Add mechanism to conditionally run some tests - FS approch should be taken upon revision
-rw-r--r--cmd/planr/main.go1
-rw-r--r--cmd/planr/sub/evaluate.go36
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)
}
}