Open baronleonardo opened 1 year ago
behavior changed in master, tests are not currently expected to output https://github.com/ziglang/zig/issues/15091
also related https://github.com/ziglang/zig/issues/5738
edit there was another related issue but i cant find it atm
test
blocks are meant to be whats commonly referred to as "unit tests" and should generally not have observable side effects
@nektro the warn and error log levels should make tests fail though, so I could see why this would be desired (also, it’s helpful when debugging tests)
printing
)during first stage of developing a module I need to test it by just printing out to see (I failed to debug unit tests in zig so I;m using the old school way printing)
What I do:
Test [1/1] test.testing...
. For the example in the OP that could be:test "testing" {
std.debug.print("\n", .{});
std.log.warn("test", .{});
}
Test [1/1] test.testing...
if you have a print function how do you test it ?
Either:
std.io.Writer
instead) and then in the tests you can use e.g. an ArrayList as a buffer to write into instead of outputting to stderr/stdoutthanks @squeek502 for your ideas but they are workarounds to me not solutions we could solve all of that by just printing out normally
It's not as simple as 'printing out normally' since the Test [1/1] test.testing...
is technically part of a progress bar. If you have multiple tests the Test [1/5] test.testing...
would get overwritten with Test [2/5] test.test2...
and so on. If none of the tests print to stderr, then the final result of zig test
ends up looking like this:
> zig test multiple-tests.zig
All 7 tests passed.
while developing you can also put it in a pub fn main() !void {}
and move to test {}
once it is ready
can we add for example std.testing.print
function ?
Zig Version
0.10.1
Steps to Reproduce and Observed Behavior
output:
Expected Behavior
output: