www.ziglang.org
www.ziglang.org copied to clipboard
Zig test example output not accurate
I copied the detect-test.zig example from the documentation and ran
zig test detect_test.zig
as I wanted to make sure that the builtin.is_test in 1/1 test "builtin.is_test"... OK, as presented in the documentation, is coming from the "name" of the test and not in some way from the argument to expect().
Unfortunately my (0.7.1) zig doesn't output that line. It only shows:
All 1 tests passed.
- If there is some option for
zig testthat outputs what is shown it shown in the documentation, or else the output in the documentation should be updated to reflect reality. - the input should be disambiguated by not repeating the same significant string of characters in any example. In this case e.g. by changing the last part of the exmple to be:
test "fn builtin.is_test" {
expect(builtin.is_test);
}
(and if necessary adapt the output).
That might have been an imprecision in the old build, can you confirm if the same problem is present for the 0.8.0 release? Thanks!
Yes the problem is present in the 0.8.0 release. The input file in the 0.8.0 documentation has been updated for the change , but the output documentation still has the Test [1/1] test "builtin.is_test"... and the compiler doesn't output that.
You have to redirect stderr to a "dumb" terminal. You can do this by: zig test detect_test.zig 2>&1 | less. The website uses a "dumb" terminal to do this, so that is why it shows like that.
I seem to have the same issue as OP with current zig's documentation (version 0.12.0-dev.1127+32bc07767). The 'dumb terminal' solution does not work (for me).