www.ziglang.org icon indicating copy to clipboard operation
www.ziglang.org copied to clipboard

Zig test example output not accurate

Open AvdN opened this issue 4 years ago • 4 comments

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.
  1. If there is some option for zig test that outputs what is shown it shown in the documentation, or else the output in the documentation should be updated to reflect reality.
  2. 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).

AvdN avatar May 27 '21 08:05 AvdN

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!

kristoff-it avatar Jun 07 '21 15:06 kristoff-it

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.

AvdN avatar Jun 07 '21 15:06 AvdN

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.

g-w1 avatar Sep 08 '21 14:09 g-w1

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).

samusz avatar Oct 28 '23 14:10 samusz