zig icon indicating copy to clipboard operation
zig copied to clipboard

test: when test-filter text-key is contained in filename, all cases ran

Open mindon opened this issue 1 year ago • 2 comments

Zig Version

0.13.0-dev.73+db890dbae

Steps to Reproduce and Observed Behavior

zig test hello.zig --test-filter hell

// hello.zig
const std = @import("std");

test "hell" {
  try std.testing.expect(true);
}

test "world" {
  try std.testing.expect(false);
}

here the hello.zig filename contains the text hell

Expected Behavior

run only test case hell

mindon avatar May 09 '24 09:05 mindon

Since https://github.com/ziglang/zig/pull/19079, --test-filter works on fully qualified names, so this is intentional.

I believe the fully qualified name of the hell test in your case would be hello.test.hell, so if you want to specifically run tests named hell, you can filter for test.hell.

squeek502 avatar May 09 '24 09:05 squeek502

@squeek502 Is there (a plan to add) some way to list all found/executed tests? I'd imagine a zig test --list with sorted output would be useful in trying to figure out why a test was/wasn't run, finding typos etc.

rohlem avatar May 09 '24 10:05 rohlem

Since #19079, --test-filter works on fully qualified names, so this is intentional.

I believe the fully qualified name of the hell test in your case would be hello.test.hell, so if you want to specifically run tests named hell, you can filter for test.hell.

i see. the filename.test. is an inclusive prefix for all test names --test-filter.

maybe the docs should be updated to make this intentional idea more obviously ;-p

btw, should the directory part of the file path be inclusive too? i mean this case zig test say/hello.zig --test-filter hell

mindon avatar May 10 '24 07:05 mindon