Commit 6317226
committed
Add T.TODO and t.Todo() to drive the TODO directive
The spec [1] suggests "not ok 13 # TODO ...", but if you attempt this
with:
t.Fail("# TODO foo")
you get an extra hyphen ("not ok 13 - # TODO foo") which is parsed as
a failed test (and not a TODO test).
I'd initially written up an alternative to Ok:
T.TODO(test bool, description string)
but Michael pointed out that future work may add additional test
methods (e.g. EqOk) and wanted to support those as well with something
like [2]:
t.TODO = true
t.Ok(Foo(), "foo")
t.EqOk(Bar(), Baz(), "bar == baz")
t.TODO = false // could be done via defer too
or [2]:
t.TODO( func () {
t.Ok(Foo(), "foo")
t.EqOk(Bar(), Baz(), "bar == baz")
})
This commit adds a .TODO boolean following Michael's first proposal.
It also adds a Todo() method returning a copy of the test-state (but
setting TODO), which you can use to avoid altering the original
test-state's TODO value. This can be useful when you don't want to
bother with a defer, or your TODO tests all live in an existing branch
of a function, or you want to chain methods for a one-off TODO test:
t.TODO().Ok(Foo(), "foo")
To keep the count synchronized between sibling test states,
nextTestNumber is now a pointer. We don't do anything to keep Writer
synchronized, because it's already part of the public API as a
non-pointer, and Michael is ok leaving this up to the caller [3].
[1]: http://testanything.org/tap-version-13-specification.html#todo-tests
[2]: mndrix/tap-go#6 (comment)
[3]: mndrix/tap-go#6 (comment)1 parent d8e35a4 commit 6317226
1 file changed
Lines changed: 22 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| 45 | + | |
42 | 46 | | |
43 | | - | |
| 47 | + | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
| |||
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
77 | | - | |
78 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
79 | 87 | | |
80 | 88 | | |
81 | 89 | | |
| |||
105 | 113 | | |
106 | 114 | | |
107 | 115 | | |
108 | | - | |
| 116 | + | |
109 | 117 | | |
110 | 118 | | |
111 | 119 | | |
| |||
117 | 125 | | |
118 | 126 | | |
119 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
120 | 135 | | |
121 | 136 | | |
122 | 137 | | |
123 | | - | |
124 | | - | |
| 138 | + | |
| 139 | + | |
125 | 140 | | |
126 | 141 | | |
127 | 142 | | |
| |||
0 commit comments