authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-30 08:43:56+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-30 08:46:46+02:00
logceca6cca1624dbe64aef63bf9c29efa91ec93feb
treed00990fb20afb3260bb7bba855657bbaa4f067cb
parentbb7af4df66b7d627472f219b274fcbbc7b1b65ec
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

test-incremental: respect -Dskip-non-native and other similar options


2 files changed, 98 insertions(+), 17 deletions(-)

build.zig+13-1
...@@ -772,7 +772,19 @@ pub fn build(b: *std.Build) !void {...@@ -772,7 +772,19 @@ pub fn build(b: *std.Build) !void {
772 }772 }
773773
774 const test_incremental_step = b.step("test-incremental", "Run the incremental compilation test cases");774 const test_incremental_step = b.step("test-incremental", "Run the incremental compilation test cases");
775 try tests.addIncrementalTests(b, test_incremental_step, test_filters, test_target_filters);775 try tests.addIncrementalTests(b, test_incremental_step, .{
776 .test_filters = test_filters,
777 .test_target_filters = test_target_filters,
778 .skip_non_native = skip_non_native,
779 .skip_wasm = skip_wasm,
780 .skip_freebsd = skip_freebsd,
781 .skip_netbsd = skip_netbsd,
782 .skip_openbsd = skip_openbsd,
783 .skip_windows = skip_windows,
784 .skip_darwin = skip_darwin,
785 .skip_linux = skip_linux,
786 .skip_llvm = skip_llvm,
787 });
776 if (!skip_test_incremental) test_step.dependOn(test_incremental_step);788 if (!skip_test_incremental) test_step.dependOn(test_incremental_step);
777789
778 if (tests.addLibcTestNszTests(b, .{790 if (tests.addLibcTestNszTests(b, .{
test/tests.zig+85-16
...@@ -2250,23 +2250,57 @@ const link_targets = blk: {...@@ -2250,23 +2250,57 @@ const link_targets = blk: {
2250 };2250 };
2251};2251};
22522252
2253/// Unlike `test_targets` and `c_abi_targets`, these targets are just simple strings which we pass2253const IncrementalTarget = struct {
2254/// directly to `incr-check`. They include the target triple and the compiler backend.2254 target: std.Target.Query,
2255 backend: enum { selfhosted, llvm, cbe },
2256};
2257
2258/// These are passed to `incr-check` as `<target>-<backend>` strings.
2255///2259///
2256/// If only one specific test is failing on a target, instead of entirely disabling the target here,2260/// If only one specific test is failing on a target, instead of entirely disabling the target here,
2257/// you can skip the target for that specific test only by adding a line like this to the manifest:2261/// you can skip the target for that specific test only by adding a line like this to the manifest:
2258/// #skip_target=x86_64-linux-selfhosted2262/// #skip_target=x86_64-linux-selfhosted
2259const incremental_targets: []const []const u8 = &.{2263const incremental_targets = &[_]IncrementalTarget{
2260 // Avoid adding more CBE or LLVM targets without good reason: they're a lot slower than others2264 // Avoid adding more CBE or LLVM targets without good reason: they're a lot slower than others
2261 // to run due to the output (C source code or LLVM IR) being built non-incrementally (by Clang2265 // to run due to the output (C source code or LLVM IR) being built non-incrementally (by Clang
2262 // or LLVM). We just have a couple here to make sure that it works.2266 // or LLVM). We just have a couple here to make sure that it works.
2263 "x86_64-linux-cbe",2267 .{
2264 "x86_64-linux-llvm",2268 .target = .{
2269 .cpu_arch = .x86_64,
2270 .os_tag = .linux,
2271 },
2272 .backend = .cbe,
2273 },
2274 .{
2275 .target = .{
2276 .cpu_arch = .x86_64,
2277 .os_tag = .linux,
2278 },
2279 .backend = .llvm,
2280 },
22652281
2266 "x86_64-linux-selfhosted",2282 .{
2283 .target = .{
2284 .cpu_arch = .x86_64,
2285 .os_tag = .linux,
2286 },
2287 .backend = .selfhosted,
2288 },
2267 // https://codeberg.org/ziglang/zig/issues/317732289 // https://codeberg.org/ziglang/zig/issues/31773
2268 //"x86_64-windows-selfhosted",2290 // .{
2269 "wasm32-wasi-selfhosted",2291 // .target = .{
2292 // .cpu_arch = .x86_64,
2293 // .os_tag = .windows,
2294 // },
2295 // .backend = .selfhosted,
2296 // },
2297 .{
2298 .target = .{
2299 .cpu_arch = .wasm32,
2300 .os_tag = .wasi,
2301 },
2302 .backend = .selfhosted,
2303 },
2270};2304};
22712305
2272fn compatible32bitArch(host: *const std.Target) ?std.Target.Cpu.Arch {2306fn compatible32bitArch(host: *const std.Target) ?std.Target.Cpu.Arch {
...@@ -3290,11 +3324,24 @@ pub fn addDebuggerTests(b: *std.Build, options: DebuggerContext.Options) ?*Step...@@ -3290,11 +3324,24 @@ pub fn addDebuggerTests(b: *std.Build, options: DebuggerContext.Options) ?*Step
3290 return step;3324 return step;
3291}3325}
32923326
3327const IncrementalTestOptions = struct {
3328 test_filters: []const []const u8,
3329 test_target_filters: []const []const u8,
3330 skip_non_native: bool,
3331 skip_wasm: bool,
3332 skip_freebsd: bool,
3333 skip_netbsd: bool,
3334 skip_openbsd: bool,
3335 skip_windows: bool,
3336 skip_darwin: bool,
3337 skip_linux: bool,
3338 skip_llvm: bool,
3339};
3340
3293pub fn addIncrementalTests(3341pub fn addIncrementalTests(
3294 b: *std.Build,3342 b: *std.Build,
3295 test_step: *Step,3343 test_step: *Step,
3296 test_filters: []const []const u8,3344 options: IncrementalTestOptions,
3297 test_target_filters: []const []const u8,
3298) !void {3345) !void {
3299 const io = b.graph.io;3346 const io = b.graph.io;
33003347
...@@ -3316,9 +3363,9 @@ pub fn addIncrementalTests(...@@ -3316,9 +3363,9 @@ pub fn addIncrementalTests(
3316 while (try it.next(io)) |entry| {3363 while (try it.next(io)) |entry| {
3317 if (std.mem.endsWith(u8, entry.basename, ".swp")) continue;3364 if (std.mem.endsWith(u8, entry.basename, ".swp")) continue;
33183365
3319 for (test_filters) |test_filter| {3366 for (options.test_filters) |test_filter| {
3320 if (std.mem.find(u8, entry.path, test_filter)) |_| break;3367 if (std.mem.find(u8, entry.path, test_filter)) |_| break;
3321 } else if (test_filters.len > 0) continue;3368 } else if (options.test_filters.len > 0) continue;
33223369
3323 switch (entry.kind) {3370 switch (entry.kind) {
3324 .file => {},3371 .file => {},
...@@ -3329,13 +3376,35 @@ pub fn addIncrementalTests(...@@ -3329,13 +3376,35 @@ pub fn addIncrementalTests(
3329 }3376 }
3330 b.dependOnFileContents(b.path(b.pathJoin(&.{ "test", "incremental", entry.path })));3377 b.dependOnFileContents(b.path(b.pathJoin(&.{ "test", "incremental", entry.path })));
33313378
3332 for (incremental_targets) |target_str| {3379 for (incremental_targets) |test_target| {
3333 if (test_target_filters.len > 0) {3380 const resolved_target = b.resolveTargetQuery(test_target.target);
3334 for (test_target_filters) |filter| {3381
3335 if (std.mem.find(u8, target_str, filter) != null) break;3382 if (options.skip_non_native and !isNative(&resolved_target, &b.graph.host.result))
3383 continue;
3384
3385 const target = &resolved_target.result;
3386
3387 if (options.skip_wasm and target.cpu.arch.isWasm()) continue;
3388
3389 if (options.skip_freebsd and target.os.tag == .freebsd) continue;
3390 if (options.skip_netbsd and target.os.tag == .netbsd) continue;
3391 if (options.skip_openbsd and target.os.tag == .openbsd) continue;
3392 if (options.skip_windows and target.os.tag == .windows) continue;
3393 if (options.skip_darwin and target.os.tag.isDarwin()) continue;
3394 if (options.skip_linux and target.os.tag == .linux) continue;
3395
3396 if (options.skip_llvm and test_target.backend == .llvm) continue;
3397
3398 const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
3399
3400 if (options.test_target_filters.len > 0) {
3401 for (options.test_target_filters) |filter| {
3402 if (std.mem.find(u8, triple_txt, filter) != null) break;
3336 } else continue;3403 } else continue;
3337 }3404 }
33383405
3406 const target_str = b.fmt("{s}-{t}", .{ triple_txt, test_target.backend });
3407
3339 const run = b.addRunArtifact(incr_check);3408 const run = b.addRunArtifact(incr_check);
3340 run.setName(b.fmt("incr-check {s} '{s}'", .{ target_str, entry.basename }));3409 run.setName(b.fmt("incr-check {s} '{s}'", .{ target_str, entry.basename }));
33413410