ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.65k stars 2.53k forks source link

"All tests passed" overwrite. #16669

Open Rexicon226 opened 1 year ago

Rexicon226 commented 1 year ago

Zig Version

0.10.1

Steps to Reproduce and Observed Behavior

Running a debug print in a test such as this:

test "Example Test" {
    std.debug.print("{d}", .{1});
}

When running the zig test on the file containing it, or in any way triggering the test, this will be the output:

TAll 1 tests passed.

Clearly, you can see the issue. when running the same test but some any other text around the {d}, for example:

test "Example Test" {
    std.debug.print("{d}\n", .{1});
}

It will work as expected test.Example Test... 1

Expected Behavior

I assume, that the excepted behavior should be something like test.Example Test... 1 All 1 tests passed. maybe? I don't know exactly how I would handle the lack of an enter in a test, but there must be something better than this.

Rexicon226 commented 1 year ago

I confirmed the same issue is present in 0.11.0.

Rexicon226 commented 1 year ago

After trying this in 0.12.0-dev.4+e7ba4b7f9, I can see that the issue is still there.

scheibo commented 1 year ago

https://github.com/ziglang/zig/issues/15091 possibly relevant

Rexicon226 commented 1 year ago

So this will fix the issue.

Now tests like:

test "Example Test" {
    std.debug.print("{d}", .{1});
}

Run like this:

Test [1/1] test.Example Test... 1

All 1 tests passed.

Which in my opinion is the best option.

Having two tests runs like this:

test "Example Test" {
    std.debug.print("{d}", .{1});
}

test "Example Test 2" {

}

Result:

Test [1/2] test.Example Test... 1
Test [2/2] test.Example Test 2...

All 2 tests passed.

With a print:

test "Example Test" {
    std.debug.print("{d}", .{1});
}

test "Example Test 2" {
    std.debug.print("{d}", .{2});
}
Test [1/2] test.Example Test... 1
Test [2/2] test.Example Test 2... 2

All 2 tests passed.
Rexicon226 commented 1 year ago

To be honest, I'm actually really confused how the \n print only affects the last one, there must be some kind of forward escape somewhere, but I don't know where that might be.