ReviewOS

also looking at this

zig-utils/zig-test-framework

fix: honor discovery-mode CLI options

#17
Merged glennmichael123 wants to merge codex/issue-2-discovery-cli into main
10 files +192 -24

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

README.mdmodified+7-0
Changes to README.md
@@ -94,8 +94,15 @@ This will automatically discover and run all `*.test.zig` files in the `tests` d
9494- `--pattern <pattern>` - File pattern to match (default: `*.test.zig`)
9595- `--no-recursive` - Disable recursive directory search
9696- `--bail` - Stop on first failure
97- `--filter <text>` / `--grep <text>` - Run only Zig tests whose names contain the text
98- `--no-color` - Disable color in child Zig test processes
9799- `--verbose` - Show detailed output
98100
101Discovery mode rejects options that it cannot honor yet instead of silently
102ignoring them. Reporter selection, quiet output, timeouts, parallel jobs,
103snapshot updates, memory profiling, configuration files, JUnit output, and the
104web UI require the shared execution pipeline planned for future releases.
105
99106**Examples:**
100107
101108```bash
build.zigmodified+3-0
Changes to build.zig
@@ -130,6 +130,9 @@ pub fn build(b: *std.Build) void {
130130 .target = target,
131131 .optimize = optimize,
132132 .link_libc = true,
133 .imports = &.{
134 .{ .name = "zig_test_framework", .module = lib_module },
135 },
133136 }),
134137 });
135138 const run_filter_tests = b.addRunArtifact(filter_tests);
tests/filter_test.zigmodified+15-13
Changes to tests/filter_test.zig
@@ -1,19 +1,21 @@
11const std = ;
2const ztf = ;
23
3// Placeholder tests for filter module
4// TODO: Implement comprehensive tests for test filtering
4test "discovery forwards test-name filters to zig test" {
5 const allocator = std.testing.allocator;
6 var discovered = ztf.DiscoveryResult.init(allocator);
7 defer discovered.deinit();
58
6test "filter by test name" {
7 // Test filtering tests by name
8 try std.testing.expect(true);
9}
9 try discovered.addFile(
10 "tests/fixtures/filter_fixture.zig",
11 "fixtures/filter_fixture.zig",
12 "filter_fixture.zig",
13 );
1014
11test "filter by pattern" {
12 // Test filtering tests by pattern
13 try std.testing.expect(true);
14}
15 const passed = try ztf.runDiscoveredTests(allocator, &discovered, .{
16 .filter = "selected test passes",
17 .use_colors = false,
18 });
1519
16test "filter combination" {
17 // Test combined filters
18 try std.testing.expect(true);
20 try std.testing.expect(passed);
1921}
tests/fixtures/filter_fixture.zigadded+9-0
Changes to tests/fixtures/filter_fixture.zig
@@ -0,0 +1,9 @@
1const std = ;
2
3test "selected test passes" {
4 try std.testing.expect(true);
5}
6
7test "unselected test fails" {
8 return error.ShouldHaveBeenFiltered;
9}