zig icon indicating copy to clipboard operation
zig copied to clipboard

test: improve how filtering works

Open perillo opened this issue 11 months ago • 4 comments

#19079 improved how filtering works, but there is still an issue.

The problem is that there are two test types: normal test (where the test name is a string literal) and a decltest (where the test name is an identifier).

An example, we have mem.test.endsWith and mem.decltest.minMax. This makes it pratically impossible for a normal user to run tests from a specified namespace, without first checking the source code.

Is it possible to exclude test and decltest when matching a filter, without causing problems?

Thanks.

perillo avatar Mar 01 '24 20:03 perillo

I found another possible issue:

> zig test lib/std/std.zig --test-filter "mem" --zig-lib-dir lib
All 157 tests passed.
> zig test lib/std/std.zig --test-filter "mem." --zig-lib-dir lib
All 138 tests passed.
> zig test lib/std/std.zig --test-filter ".mem" --zig-lib-dir lib
All 65 tests passed.
> zig test lib/std/std.zig --test-filter ".mem." --zig-lib-dir lib
All 56 tests passed.

I expect the number of tests to be the same.

perillo avatar Mar 01 '24 20:03 perillo

I would not expect the number of tests to be the same.

nektro avatar Mar 01 '24 21:03 nektro

Also, i wanted to ask. If this is an intended behaviour:

test {
    std.debug.print("this is test_0\n", .{});
}

test "second test" {
    std.debug.print("this is second test\n", .{});
}

test "second test or third" {
    std.debug.print("this is second test\n", .{});
}

How to test only "second test" or "test_0". I found that no matter of --test-filter values - "test_0" will run (test_1, somerandomstring, anything).

zig test main.zig --test-filter "second test"

Will execute all 3 tests.

There is still no way of running single test, i think.

star-tek-mb avatar Apr 13 '24 14:04 star-tek-mb

Another thing to consider - if casing is important. Maybe the zig standard is that all tests are specified using lower case letters, but I'd wager that users are sometimes mixing cases.

So we either make the matching case insensitive, or optionally case insensitive, perhaps with regex support similar to /foobar/i.

adworacz avatar Apr 30 '24 22:04 adworacz