| ... | @@ -1,20 +1,21 @@ | ... | @@ -1,20 +1,21 @@ |
| 1 | pub fn build(b: *std.Build) void { | 1 | pub fn build(b: *std.Build) void { |
| 2 | // To avoid having to explicitly link required system libraries into the final test | 2 | const is_windows = b.graph.host.result.os.tag == .windows; |
| 3 | // executable (e.g. ntdll on Windows), we'll just link everything with libc here. | | |
| 4 | | 3 | |
| 5 | const test_obj = b.addTest(.{ | 4 | const test_obj = b.addTest(.{ |
| 6 | .emit_object = true, | 5 | .emit_object = true, |
| 7 | .root_module = b.createModule(.{ | 6 | .root_module = b.createModule(.{ |
| 8 | .root_source_file = b.path("src/main.zig"), | 7 | .root_source_file = b.path("src/main.zig"), |
| 9 | .target = b.graph.host, | 8 | .target = b.graph.host, |
| 10 | .link_libc = true, | | |
| 11 | }), | 9 | }), |
| 12 | }); | 10 | }); |
| | 11 | if (is_windows) { |
| | 12 | test_obj.linkSystemLibrary("ntdll"); |
| | 13 | test_obj.linkSystemLibrary("kernel32"); |
| | 14 | } |
| 13 | | 15 | |
| 14 | const test_exe_mod = b.createModule(.{ | 16 | const test_exe_mod = b.createModule(.{ |
| 15 | .root_source_file = null, | 17 | .root_source_file = null, |
| 16 | .target = b.graph.host, | 18 | .target = b.graph.host, |
| 17 | .link_libc = true, | | |
| 18 | }); | 19 | }); |
| 19 | test_exe_mod.addObject(test_obj); | 20 | test_exe_mod.addObject(test_obj); |
| 20 | const test_exe = b.addExecutable(.{ | 21 | const test_exe = b.addExecutable(.{ |
| ... | @@ -26,7 +27,10 @@ pub fn build(b: *std.Build) void { | ... | @@ -26,7 +27,10 @@ pub fn build(b: *std.Build) void { |
| 26 | b.default_step = test_step; | 27 | b.default_step = test_step; |
| 27 | | 28 | |
| 28 | const test_run = b.addRunArtifact(test_exe); | 29 | const test_run = b.addRunArtifact(test_exe); |
| 29 | test_run.addCheck(.{ .expect_stderr_match = "All 3 tests passed." }); | 30 | if (!is_windows) { |
| | 31 | // https://github.com/ziglang/zig/issues/24867 |
| | 32 | test_run.addCheck(.{ .expect_stderr_match = "All 3 tests passed." }); |
| | 33 | } |
| 30 | test_step.dependOn(&test_run.step); | 34 | test_step.dependOn(&test_run.step); |
| 31 | } | 35 | } |
| 32 | | 36 | |