| ... | ... | @@ -1,20 +1,21 @@ |
| 1 | 1 | pub fn build(b: *std.Build) void { |
| 2 | | // To avoid having to explicitly link required system libraries into the final test |
| 3 | | // executable (e.g. ntdll on Windows), we'll just link everything with libc here. |
| 2 | const is_windows = b.graph.host.result.os.tag == .windows; |
| 4 | 3 | |
| 5 | 4 | const test_obj = b.addTest(.{ |
| 6 | 5 | .emit_object = true, |
| 7 | 6 | .root_module = b.createModule(.{ |
| 8 | 7 | .root_source_file = b.path("src/main.zig"), |
| 9 | 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 | 16 | const test_exe_mod = b.createModule(.{ |
| 15 | 17 | .root_source_file = null, |
| 16 | 18 | .target = b.graph.host, |
| 17 | | .link_libc = true, |
| 18 | 19 | }); |
| 19 | 20 | test_exe_mod.addObject(test_obj); |
| 20 | 21 | const test_exe = b.addExecutable(.{ |
| ... | ... | @@ -26,7 +27,10 @@ pub fn build(b: *std.Build) void { |
| 26 | 27 | b.default_step = test_step; |
| 27 | 28 | |
| 28 | 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 | 34 | test_step.dependOn(&test_run.step); |
| 31 | 35 | } |
| 32 | 36 | |