1pub fn build(b: *std.Build) void {
2 const is_windows = b.graph.host.result.os.tag == .windows;
3
4 const test_obj = b.addTest(.{
5 .emit_object = true,
6 .root_module = b.createModule(.{
7 .root_source_file = b.path("src/main.zig"),
8 .target = b.graph.host,
9 }),
10 });
11 if (is_windows) {
12 test_obj.root_module.linkSystemLibrary("ntdll", .{});
13 test_obj.root_module.linkSystemLibrary("kernel32", .{});
14 }
15
16 const test_exe_mod = b.createModule(.{
17 .root_source_file = null,
18 .target = b.graph.host,
19 });
20 test_exe_mod.addObject(test_obj);
21 const test_exe = b.addExecutable(.{
22 .name = "test",
23 .root_module = test_exe_mod,
24 });
25
26 const test_step = b.step("test", "Test the program");
27 b.default_step = test_step;
28
29 const test_run = b.addRunArtifact(test_exe);
30 test_run.addCheck(.{ .expect_stderr_match = "All 3 tests passed." });
31 test_step.dependOn(&test_run.step);
32}
33
34const std = @import("std");