@@ -1,20 +1,21 @@
|
|||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) void {
|
||||||
// To avoid having to explicitly link required system libraries into the final test
|
const is_windows = b.graph.host.result.os.tag == .windows;
|
||||||
// executable (e.g. ntdll on Windows), we'll just link everything with libc here.
|
|
||||||
|
|
||||||
const test_obj = b.addTest(.{
|
const test_obj = b.addTest(.{
|
||||||
.emit_object = true,
|
.emit_object = true,
|
||||||
.root_module = b.createModule(.{
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("src/main.zig"),
|
.root_source_file = b.path("src/main.zig"),
|
||||||
.target = b.graph.host,
|
.target = b.graph.host,
|
||||||
.link_libc = true,
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
if (is_windows) {
|
||||||
|
test_obj.linkSystemLibrary("ntdll");
|
||||||
|
test_obj.linkSystemLibrary("kernel32");
|
||||||
|
}
|
||||||
|
|
||||||
const test_exe_mod = b.createModule(.{
|
const test_exe_mod = b.createModule(.{
|
||||||
.root_source_file = null,
|
.root_source_file = null,
|
||||||
.target = b.graph.host,
|
.target = b.graph.host,
|
||||||
.link_libc = true,
|
|
||||||
});
|
});
|
||||||
test_exe_mod.addObject(test_obj);
|
test_exe_mod.addObject(test_obj);
|
||||||
const test_exe = b.addExecutable(.{
|
const test_exe = b.addExecutable(.{
|
||||||
@@ -26,7 +27,10 @@ pub fn build(b: *std.Build) void {
|
|||||||
b.default_step = test_step;
|
b.default_step = test_step;
|
||||||
|
|
||||||
const test_run = b.addRunArtifact(test_exe);
|
const test_run = b.addRunArtifact(test_exe);
|
||||||
test_run.addCheck(.{ .expect_stderr_match = "All 3 tests passed." });
|
if (!is_windows) {
|
||||||
|
// https://github.com/ziglang/zig/issues/24867
|
||||||
|
test_run.addCheck(.{ .expect_stderr_match = "All 3 tests passed." });
|
||||||
|
}
|
||||||
test_step.dependOn(&test_run.step);
|
test_step.dependOn(&test_run.step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user