Skip to content

Commit 5282b96

Browse files
committed
.tools: Remove redundant r.Pass check when 'fail == 0'
The previous version of this script would always pass this check, because when 'fail == 0' was true, all of the messages had passed. That lead to logic like: a. If all checks passed for the commit and the verbose flag is set, print all the messages (which all passed). b. If all checks passed for the commit and the verbose flag is not set, don't print details about any messages (which all passed). c. If any checks failed, print all the failed messages. That wasn't printing successful checks when the verbose flag was true but some checks failed. This commit shifts the logic around to: A. If the verbose flag is set, print messages for all checks, using TAP's "ok" and "not ok" to distinguish between per-check pass/fail [1]. B. If the verbose flag is not set, only print the failed messages (but still keep the "not ok" prefix). In the non-verbose case, then (b/c) and (B) look the same (modulo my "not ok" prefix adjustment). And in the verbose case, I think (A) is preferable to (a/c), because there's no reason to *not* print successful checks when you've enabled the verbose flag. [1]: http://testanything.org/ Signed-off-by: W. Trevor King <[email protected]>
1 parent c00555c commit 5282b96

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

.tools/validate.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,19 @@ func main() {
7474
results = append(results, vr...)
7575
if _, fail := vr.PassFail(); fail == 0 {
7676
fmt.Println("PASS")
77-
if *flVerbose {
78-
for _, r := range vr {
79-
if r.Pass {
80-
fmt.Printf(" - %s\n", r.Msg)
81-
}
82-
}
83-
}
8477
} else {
8578
fmt.Println("FAIL")
86-
// default, only print out failed validations
87-
for _, r := range vr {
88-
if !r.Pass {
89-
fmt.Printf(" - %s\n", r.Msg)
79+
}
80+
for _, r := range vr {
81+
if *flVerbose {
82+
if r.Pass {
83+
fmt.Printf("ok")
84+
} else {
85+
fmt.Printf("not ok")
9086
}
87+
fmt.Printf(" %s\n", r.Msg)
88+
} else if !r.Pass {
89+
fmt.Printf("not ok %s\n", r.Msg)
9190
}
9291
}
9392
}

0 commit comments

Comments
 (0)