New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zig test no output #10242
Comments
This test case can be reduced to mkdir dir1
mkdir dir2
# insert file1.zig
# insert file2.zig
# pwd = xxx/src
zig test dir1/file1.zig # success
cd dir1; # pwd = xxx/src/dir1
zig test file1.zig # failure // dir1/file1.zig
const std = @import("std");
//const shared = @import("./../dir/file2.zig");
const shared = @import("../dir2/file2.zig");
test "solution test" {
try std.testing.expect(true);
} // dir2/file2.zig
const std = @import("std"); Unfortunately root source files are not yet documented, which would clarify how this is not a bug. |
Sorry, I'm not sure I understand. Does this mean you can't run tests if they're not toplevel files? For my case, if I just cd next to the file in the subdir I'm still not getting the test to run.
|
Check out the build.zig file. This is where the build step that you are running with |
Thanks, that makes sense. I expected some sort of output like 'no tests found' or something, like it normally does if it can't find one. Without any output at all, it's unclear what's happening as a newbie. I just expected to see either: 'tests found and tests passed/failed' or 'no tests found'. I didn't expect there to be a third valid outcome where nothing is output. Thanks again for clarifying that it was an incorrectly set up build.zig! |
|
This issue can be reproduced as of 0.11.0 using nothing more than Steps to Reproducezig init-exe
zig build test after the last command I get no output in version 0.11.0-dev.2680+a1aa55ebe. Interesting the correct behaviour occurs in version 0.10.1: Furthermore |
@LincePotiguara this is expected. When everything works successfully, it is traditional for command line applications to print nothing. If you would like to see a summary, you can pass |
I would have thought by default you'd get a green 'all tests passed' instead of absolutely nothing by default, but I understand that some CLIs return absolutely nothing when they're successful too. |
It seems a bit inconsistent with doing this: zig init-exe
zig test src/main.zig which outputs:
Is this intended? |
Hey @lawrence-laz , You may specify the const std = @import("std");
test "nothing" {
std.testing.log_level = .info;
std.log.info("nothing", .{});
std.log.debug("nothing", .{});
std.log.warn("nothing", .{});
try std.testing.expect(true);
} which creates this output:
|
The new command as of |
Comming from other languages and testing frameworks is kinda odd for me that # Not cached
❯ zig build test --summary all
Build Summary: 3/3 steps succeeded; 1/1 tests passed
test success
└─ run test 1 passed 2ms MaxRSS:3M
└─ zig test Debug native success 977ms MaxRSS:156M
# cached
❯ zig build test --summary all
Build Summary: 3/3 steps succeeded
test cached
└─ run test cached
└─ zig test Debug native cached 18ms MaxRSS:17M I would expect to at least tell me what file name the test run from and the name of the test, what is the reason to have |
IIRC |
Agreed. I've been learning a little about zig the last couple days, and tried a few things with a friend of mine. We both were confused that |
I concur, coming from the Python world. Pytest prints a detailed test report on completion, including a simple summary of what happened: ' 777 passed, 3 skipped, 13 warnings in 2.35s`. I feel the summary is required to be certain that tests are actually running and the number you expect is correct. Details of the platform the tests were run on and versions are also useful information if the test report is required for later validation/review. The percentage complete is less useful for zig test due to it being MUCH faster. |
Zig Version
0.9.0-dev.1737+c42763f8c
Steps to Reproduce
edit
src/Main.zig
toedit
src/subdir/solution.zig
to:edit
src/other_subdir/shared.zig
tothen run
then go into
./src/subdir/solution.zig
and change it toand rerun
Expected Behavior
I expect to be able to run
zig test somefile/in/subdirs/file.zig
to detect and run the tests in<..>/file.zig
regardless of whether@import
is usedActual Behavior
zig test somefile/in/subdirs/file.zig
is silently running, and not apparently doing anything once the tests compile.The tests are detected, because removing the
test "solution test" { ... }
block,zig test <..>/solution.zig
correctly tells me that no tests are detected. Any compiler errors are properly detected here.The text was updated successfully, but these errors were encountered: