also looking at this
Unify discovery and programmatic test execution
#23
12 files
+656
-169
| @@ -326,7 +326,6 @@ pub const CLI = struct { | ||
| 326 | 326 | if (!self.options.watch and self.options.watch_debounce != 300) return "--watch-debounce"; |
| 327 | 327 | if (!self.options.ui and self.options.ui_port != 8080) return "--ui-port"; |
| 328 | 328 | 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"; | |
| 330 | 329 | if (self.options.quiet) return "--quiet"; |
| 331 | 330 | if (self.options.parallel) return "--parallel"; |
| 332 | 331 | if (self.options.jobs != null) return "--jobs"; |
| @@ -335,8 +334,6 @@ pub const CLI = struct { | ||
| 335 | 334 | if (self.options.profile_memory) return "--profile-memory"; |
| 336 | 335 | if (self.options.memory_threshold != 0) return "--memory-threshold"; |
| 337 | 336 | 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"; | |
| 340 | 337 | if (self.options.ui) return "--ui"; |
| 341 | 338 | return null; |
| 342 | 339 | } |
| @@ -442,6 +439,8 @@ pub const CLI = struct { | ||
| 442 | 439 | .use_colors = !self.options.no_color, |
| 443 | 440 | .parallel = self.options.parallel, |
| 444 | 441 | .n_jobs = self.options.jobs, |
| 442 | .junit_output = self.options.junit_output orelse "test-results.xml", | |
| 443 | .timeout_ms = self.options.timeout, | |
| 445 | 444 | }; |
| 446 | 445 | } |
| 447 | 446 | }; |
| @@ -691,18 +690,18 @@ test "discovery accepts implemented options" { | ||
| 691 | 690 | try std.testing.expectEqual(@as(?[]const u8, null), cli.unsupportedDiscoveryOption()); |
| 692 | 691 | } |
| 693 | 692 | |
| 694 | test "discovery identifies unsupported options" { | |
| 693 | test "discovery accepts reporter selection" { | |
| 695 | 694 | var cli = CLI.init(std.testing.allocator); |
| 696 | 695 | const args = [_][]const u8{ "zig-test", "--test-dir", "tests", "--reporter", "json" }; |
| 697 | 696 | try cli.parse(&args); |
| 698 | try std.testing.expectEqualStrings("--reporter", cli.unsupportedDiscoveryOption().?); | |
| 697 | try std.testing.expectEqual(@as(?[]const u8, null), cli.unsupportedDiscoveryOption()); | |
| 699 | 698 | } |
| 700 | 699 | |
| 701 | test "discovery reports timeout and parallel options as unsupported" { | |
| 700 | test "discovery accepts timeout and reports parallel as unsupported" { | |
| 702 | 701 | var cli = CLI.init(std.testing.allocator); |
| 703 | 702 | |
| 704 | 703 | cli.options.timeout = 1000; |
| 705 | try std.testing.expectEqualStrings("--timeout", cli.unsupportedDiscoveryOption().?); | |
| 704 | try std.testing.expectEqual(@as(?[]const u8, null), cli.unsupportedDiscoveryOption()); | |
| 706 | 705 | |
| 707 | 706 | cli.options.timeout = null; |
| 708 | 707 | cli.options.parallel = true; |