master
 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.linkSystemLibrary("ntdll");
13        test_obj.linkSystemLibrary("kernel32");
14        test_obj.linkSystemLibrary("ws2_32");
15    }
16
17    const test_exe_mod = b.createModule(.{
18        .root_source_file = null,
19        .target = b.graph.host,
20    });
21    test_exe_mod.addObject(test_obj);
22    const test_exe = b.addExecutable(.{
23        .name = "test",
24        .root_module = test_exe_mod,
25    });
26
27    const test_step = b.step("test", "Test the program");
28    b.default_step = test_step;
29
30    const test_run = b.addRunArtifact(test_exe);
31    test_run.addCheck(.{ .expect_stderr_match = "All 3 tests passed." });
32    test_step.dependOn(&test_run.step);
33}
34
35const std = @import("std");