Skip to content

Commit 650828c

Browse files
committed
.tools: Make -v output comply with TAP version 13
Using TAP [1] makes it easy to consume the output of this tool in a variety of existing harnesses [2]. Only the verbose results are TAP compliant, mostly because folks aren't likely to care about verbosity if they're just piping the results into a TAP harness. If we end up wanting the non-verbose output to be TAP compliant, we'll have to switch to the trailing count approach explained in the "Unknown amount and failures" section of the spec [1], and we'll have to keep a running counter of failed checks (instead of the current len(DefaultRules)-based approach). [1]: http://testanything.org/tap-version-13-specification.html [2]: http://testanything.org/consumers.html Signed-off-by: W. Trevor King <wking@tremily.us>
1 parent 66e9ac3 commit 650828c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

.tools/validate.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,30 @@ func main() {
6868
}
6969

7070
results := ValidateResults{}
71-
for _, commit := range c {
72-
fmt.Printf(" * %s %s ... ", commit["abbreviated_commit"], commit["subject"])
71+
72+
if *flVerbose {
73+
fmt.Println("TAP version 13")
74+
fmt.Printf("1..%d\n", len(c)*len(DefaultRules))
75+
}
76+
for i, commit := range c {
77+
fmt.Printf("# %s %s ... ", commit["abbreviated_commit"], commit["subject"])
7378
vr := ValidateCommit(commit, DefaultRules)
7479
results = append(results, vr...)
7580
if _, fail := vr.PassFail(); fail == 0 {
7681
fmt.Println("PASS")
7782
} else {
7883
fmt.Println("FAIL")
7984
}
80-
for _, r := range vr {
85+
for j, r := range vr {
8186
if *flVerbose {
8287
if r.Pass {
8388
fmt.Printf("ok")
8489
} else {
8590
fmt.Printf("not ok")
8691
}
87-
fmt.Printf(" %s\n", r.Msg)
92+
fmt.Printf(" %d - %s\n", i*len(DefaultRules)+j+1, r.Msg)
8893
} else if !r.Pass {
89-
fmt.Printf("not ok %s\n", r.Msg)
94+
fmt.Printf("not ok - %s\n", r.Msg)
9095
}
9196
}
9297
}

0 commit comments

Comments
 (0)