Skip to content

Commit 80022f6

Browse files
committed
test/failing: Wrap failing tests in another harness
Use two harnesses, where the inner harness has failing tests and writes to a buffer. The outer harness checks that buffer to ensure the output is appropriate. This lets the whole test suite pass: $ make ... All tests successful. Files=6, Tests=15, 0 wallclock secs ( 0.05 usr 0.01 sys + 0.00 cusr 0.01 csys = 0.07 CPU) Result: PASS while before this commit it failed: $ make ... Test Summary Report ------------------- test/failing/test (Wstat: 0 Tests: 2 Failed: 2) Failed tests: 1-2 Files=6, Tests=15, 0 wallclock secs ( 0.05 usr + 0.00 sys = 0.05 CPU) Result: FAIL Makefile:7: recipe for target 'all' failed make: *** [all] Error 1
1 parent 010390e commit 80022f6

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

util/tap/test/failing/main.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
package main
22

3-
import "github.com/mndrix/tap-go"
3+
import (
4+
"bytes"
5+
6+
"github.com/mndrix/tap-go"
7+
)
48

59
func main() {
6-
t := tap.New()
7-
t.Header(2)
8-
t.Ok(false, "first test")
9-
t.Fail("second test")
10+
t1 := tap.New()
11+
t1.Header(2)
12+
13+
buf := new(bytes.Buffer)
14+
t2 := tap.New()
15+
t2.Writer = buf
16+
t2.Header(2)
17+
18+
buf.Reset()
19+
t2.Ok(false, "first test")
20+
t1.Ok(buf.String() == "not ok 1 - first test\n", "Ok(false, ...) produces appropriate output")
21+
22+
buf.Reset()
23+
t2.Fail("second test")
24+
t1.Ok(buf.String() == "not ok 2 - second test\n", "Fail(...) produces appropriate output")
1025
}

0 commit comments

Comments
 (0)