Skip to content

Commit 0bc7050

Browse files
committed
Add cross-platform test targets
1 parent 3826593 commit 0bc7050

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

build.zig

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
const std = @import("std");
22

3+
const test_targets = [_]std.Target.Query{
4+
.{}, // native
5+
.{
6+
.cpu_arch = .x86_64,
7+
.os_tag = .linux,
8+
},
9+
.{
10+
.cpu_arch = .aarch64,
11+
.os_tag = .macos,
12+
},
13+
};
14+
315
pub fn build(b: *std.Build) void {
416
const target = b.standardTargetOptions(.{});
517
const optimize = b.standardOptimizeOption(.{});
@@ -29,9 +41,14 @@ pub fn build(b: *std.Build) void {
2941
});
3042
b.installArtifact(exe);
3143

32-
const getopt_lib_unit_tests = b.addTest(.{ .root_module = getopt_lib_mod });
33-
const run_tests = b.addRunArtifact(getopt_lib_unit_tests);
34-
3544
const test_step = b.step("test", "Run tests");
36-
test_step.dependOn(&run_tests.step);
45+
for (test_targets) |test_target| {
46+
const unit_tests = b.addTest(.{
47+
.root_module = getopt_lib_mod,
48+
.target = b.resolveTargetQuery(test_target),
49+
});
50+
51+
const run_unit_tests = b.addRunArtifact(unit_tests);
52+
test_step.dependOn(&run_unit_tests.step);
53+
}
3754
}

0 commit comments

Comments
 (0)