authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-30 09:00:59+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-30 09:00:59+02:00
log6534993573f184c78733ab5a05c61b4860c71d87
treea640a8bbeb4228035d9abee061976a762e36b570
parentceca6cca1624dbe64aef63bf9c29efa91ec93feb
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

test-link: respect various skip options properly

Also use the smarter isNative() function.

2 files changed, 32 insertions(+), 5 deletions(-)

build.zig+6
......@@ -656,8 +656,14 @@ pub fn build(b: *std.Build) !void {
656656 .test_filters = test_filters,
657657 .optimize_modes = optimize_modes,
658658 .skip_non_native = skip_non_native,
659 .skip_freebsd = skip_freebsd,
660 .skip_netbsd = skip_netbsd,
661 .skip_openbsd = skip_openbsd,
659662 .skip_windows = skip_windows,
663 .skip_darwin = skip_darwin,
664 .skip_linux = skip_linux,
660665 .skip_llvm = skip_llvm,
666 .skip_libc = skip_libc,
661667 .max_rss = 100_000_000,
662668 }));
663669 test_step.dependOn(tests.addStackTraceTests(b, .{
test/tests.zig+26-5
......@@ -3198,8 +3198,14 @@ const LinkTestOptions = struct {
31983198 test_filters: []const []const u8,
31993199 optimize_modes: []const OptimizeMode,
32003200 skip_non_native: bool,
3201 skip_freebsd: bool,
3202 skip_netbsd: bool,
3203 skip_openbsd: bool,
32013204 skip_windows: bool,
3205 skip_darwin: bool,
3206 skip_linux: bool,
32023207 skip_llvm: bool,
3208 skip_libc: bool,
32033209 max_rss: usize,
32043210};
32053211
......@@ -3212,22 +3218,37 @@ pub fn addLinkTests(b: *std.Build, options: LinkTestOptions) *Step {
32123218 ) orelse false;
32133219
32143220 for (link_targets) |link_target| {
3215 if (options.skip_non_native and !link_target.target.isNative()) continue;
3216 if (options.skip_windows and link_target.target.os_tag == .windows) continue;
3217
32183221 const resolved_target = b.resolveTargetQuery(link_target.target);
3219 const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
3222
3223 if (options.skip_non_native and !isNative(&resolved_target, &b.graph.host.result))
3224 continue;
3225
32203226 const target = &resolved_target.result;
32213227
3228 if (options.skip_freebsd and target.os.tag == .freebsd) continue;
3229 if (options.skip_netbsd and target.os.tag == .netbsd) continue;
3230 if (options.skip_openbsd and target.os.tag == .openbsd) continue;
3231 if (options.skip_windows and target.os.tag == .windows) continue;
3232 if (options.skip_darwin and target.os.tag.isDarwin()) continue;
3233 if (options.skip_linux and target.os.tag == .linux) continue;
3234
3235 const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
3236
32223237 if (options.test_target_filters.len > 0) {
32233238 for (options.test_target_filters) |filter| {
32243239 if (std.mem.find(u8, triple_txt, filter) != null) break;
32253240 } else continue;
32263241 }
32273242
3243 if (options.skip_libc and (link_target.link_libc == true or std.os.targetRequiresLibC(target)))
3244 continue;
3245
3246 // We can't provide MSVC libc when cross-compiling.
3247 if (target.abi == .msvc and link_target.link_libc == true and builtin.os.tag != .windows)
3248 continue;
3249
32283250 for (options.optimize_modes) |optimize_mode| {
32293251 if (link_target.optimize_mode != optimize_mode) continue;
3230 if (link_target.link_libc and target.abi == .msvc and b.graph.host.result.os.tag != .windows) continue;
32313252 const would_use_llvm = wouldUseLlvm(link_target.use_llvm, link_target.target, optimize_mode);
32323253 if (options.skip_llvm and would_use_llvm) continue;
32333254