You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
0 commit comments