ReviewOS

also looking at this

zig-utils/zig-test-framework

Unify discovery and programmatic test execution

#23
Merged glennmichael123 wants to merge codex/issue-5-unified-test-pipeline into main
12 files +656 -169
src/cli.zigmodified+6-7
Changes to src/cli.zig
@@ -326,7 +326,6 @@ pub const CLI = struct {
326326 if (!self.options.watch and self.options.watch_debounce != 300) return "--watch-debounce";
327327 if (!self.options.ui and self.options.ui_port != 8080) return "--ui-port";
328328 if (!self.options.ui and !std.mem.eql(u8, self.options.ui_host, "127.0.0.1")) return "--ui-host";
329 if (self.options.reporter != .spec) return "--reporter";
330329 if (self.options.quiet) return "--quiet";
331330 if (self.options.parallel) return "--parallel";
332331 if (self.options.jobs != null) return "--jobs";
@@ -335,8 +334,6 @@ pub const CLI = struct {
335334 if (self.options.profile_memory) return "--profile-memory";
336335 if (self.options.memory_threshold != 0) return "--memory-threshold";
337336 if (self.options.fail_on_leak) return "--fail-on-leak";
338 if (self.options.junit_output != null) return "--junit-output";
339 if (self.options.timeout != null) return "--timeout";
340337 if (self.options.ui) return "--ui";
341338 return null;
342339 }
@@ -442,6 +439,8 @@ pub const CLI = struct {
442439 .use_colors = !self.options.no_color,
443440 .parallel = self.options.parallel,
444441 .n_jobs = self.options.jobs,
442 .junit_output = self.options.junit_output orelse "test-results.xml",
443 .timeout_ms = self.options.timeout,
445444 };
446445 }
447446};
@@ -691,18 +690,18 @@ test "discovery accepts implemented options" {
691690 try std.testing.expectEqual(@as(?[]const u8, null), cli.unsupportedDiscoveryOption());
692691}
693692
694test "discovery identifies unsupported options" {
693test "discovery accepts reporter selection" {
695694 var cli = CLI.init(std.testing.allocator);
696695 const args = [_][]const u8{ "zig-test", "--test-dir", "tests", "--reporter", "json" };
697696 try cli.parse(&args);
698 try std.testing.expectEqualStrings("--reporter", cli.unsupportedDiscoveryOption().?);
697 try std.testing.expectEqual(@as(?[]const u8, null), cli.unsupportedDiscoveryOption());
699698}
700699
701test "discovery reports timeout and parallel options as unsupported" {
700test "discovery accepts timeout and reports parallel as unsupported" {
702701 var cli = CLI.init(std.testing.allocator);
703702
704703 cli.options.timeout = 1000;
705 try std.testing.expectEqualStrings("--timeout", cli.unsupportedDiscoveryOption().?);
704 try std.testing.expectEqual(@as(?[]const u8, null), cli.unsupportedDiscoveryOption());
706705
707706 cli.options.timeout = null;
708707 cli.options.parallel = true;