authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-01-15 07:55:47+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-01-19 13:16:25+01:00
logac793232eeeca87378b6b6cf4bec6e610859b5b1
treed7ae3e756b8e5b4602d7212ce495a25656f7f81d
parentb1b234daa095ef5497cbfb7821b2852afac1afea
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

test: skip non-libc module tests for targets that require or default to libc

We were just creating duplicate work and breaking -Dskip-libc.

1 files changed, 22 insertions(+), 10 deletions(-)

test/tests.zig+22-10
...@@ -2345,27 +2345,39 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {...@@ -2345,27 +2345,39 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
2345 }2345 }
2346 }2346 }
23472347
2348 const resolved_target = b.resolveTargetQuery(test_target.target);
2349 const target = &resolved_target.result;
2350
2351 if (test_target.link_libc == false and target.requiresLibC()) continue;
2352 // If the target requires libc, there's no point building the cases that
2353 // don't explicitly link libc as they'll just end up actually linking
2354 // libc anyway, thus creating duplicate work and making -Dskip-libc not
2355 // work as expected.
2356 if (test_target.link_libc == null and target.requiresLibC()) continue;
2357 // These targets don't strictly require libc, but we don't yet have a
2358 // syscall layer for them, so the compiler links libc by default. They
2359 // therefore get the same treatment here.
2360 if (test_target.link_libc == null and (target.os.tag == .freebsd or target.os.tag == .netbsd)) continue;
2361
2348 if (!options.test_extra_targets and test_target.extra_target) continue;2362 if (!options.test_extra_targets and test_target.extra_target) continue;
23492363
2350 if (options.skip_non_native and !test_target.target.isNative())2364 if (options.skip_non_native and !test_target.target.isNative())
2351 continue;2365 continue;
23522366
2353 if (options.skip_spirv and test_target.target.cpu_arch != null and test_target.target.cpu_arch.?.isSpirV()) continue;2367 if (options.skip_spirv and target.cpu.arch.isSpirV()) continue;
2354 if (options.skip_wasm and test_target.target.cpu_arch != null and test_target.target.cpu_arch.?.isWasm()) continue;2368 if (options.skip_wasm and target.cpu.arch.isWasm()) continue;
23552369
2356 if (options.skip_freebsd and test_target.target.os_tag == .freebsd) continue;2370 if (options.skip_freebsd and target.os.tag == .freebsd) continue;
2357 if (options.skip_netbsd and test_target.target.os_tag == .netbsd) continue;2371 if (options.skip_netbsd and target.os.tag == .netbsd) continue;
2358 if (options.skip_openbsd and test_target.target.os_tag == .openbsd) continue;2372 if (options.skip_openbsd and target.os.tag == .openbsd) continue;
2359 if (options.skip_windows and test_target.target.os_tag == .windows) continue;2373 if (options.skip_windows and target.os.tag == .windows) continue;
2360 if (options.skip_darwin and test_target.target.os_tag != null and test_target.target.os_tag.?.isDarwin()) continue;2374 if (options.skip_darwin and target.os.tag.isDarwin()) continue;
2361 if (options.skip_linux and test_target.target.os_tag == .linux) continue;2375 if (options.skip_linux and target.os.tag == .linux) continue;
23622376
2363 const would_use_llvm = wouldUseLlvm(test_target.use_llvm, test_target.target, test_target.optimize_mode);2377 const would_use_llvm = wouldUseLlvm(test_target.use_llvm, test_target.target, test_target.optimize_mode);
2364 if (options.skip_llvm and would_use_llvm) continue;2378 if (options.skip_llvm and would_use_llvm) continue;
23652379
2366 const resolved_target = b.resolveTargetQuery(test_target.target);
2367 const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");2380 const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
2368 const target = &resolved_target.result;
23692381
2370 if (options.test_target_filters.len > 0) {2382 if (options.test_target_filters.len > 0) {
2371 for (options.test_target_filters) |filter| {2383 for (options.test_target_filters) |filter| {