tests: move incremental target matrix out of manifests

Having the matrix of test targets for incremental compilation in the
individual test manifests has turned out to be inconvenient for a few
reasons: the tests are almost certain to accidentally get out of sync,
disabling targets entirely is annoying to do, and incr-check needs to
take care to print the target in all error messages (which currently
does not always happen).

If I recall correctly, I originally designed it this way because it
allows targets to be disabled at the granularity of individual tests,
but there's an easier approach to that: just let a test manifest that it
should be *skipped* on a certain target! As skipping is the rare case,
and also the case you want readers to notice, it makes sense for *it* to
be explicitly specified, like how unit tests use `error.SkipZigTest`.

So, `incr-check` no longer runs through a list of targets specified in
the manifest. Instead, it accepts (and, in fact, requires) a single
target on the command line, and runs the test for that specific target.
If the file contains a `#skip_target` directive for that target, then
`incr-check` exits immediately, so we can still disable targets at
individual test granularity, but you can also disable a target for all
tests by just commenting it out of the matrix in `test/tests.zig`.

As a nice bonus, this also allows the build system to run different
incremental test targets in parallel, because the targets are now
different steps.

This definitely seems like a better way to split the work between the
build system and incr-check---sorry for getting this wrong initially!
This commit is contained in:
Matthew Lugg
2026-04-14 10:26:35 +01:00
committed by mlugg
parent 8578b07faa
commit 291addadf8
39 changed files with 269 additions and 436 deletions
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const S = struct { x: u8 };
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const S = @This();
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
pub fn main() !void {
-7
View File
@@ -1,10 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
pub fn main() !void {
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const Tag = u2;
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
#update=initial version
#file=main.zig
export fn foo() void {}
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
pub fn main() !void {
@@ -1,7 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
-4
View File
@@ -1,7 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#module=foo=foo.zig
#update=initial version
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
pub fn main() !u8 {
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
pub fn main() !u8 {
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
pub fn main() !void {
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const S = extern struct { x: u8, y: u8 };
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version with compile error
#file=main.zig
pub fn main() void {}
-7
View File
@@ -1,10 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version with no compile log
#file=main.zig
const std = @import("std");
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
pub fn main() void {}
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const foo = @as(u8, 123);
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version with error
#file=main.zig
pub fn main() !void {
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=non-inline version
#file=main.zig
pub fn main() !void {
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const foo = @import("foo.zig");
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
pub fn main() !void {
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const MyEnum = enum(u8) {
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const E = enum { a, b, c };
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const SomeType = u32;
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
pub const A = struct { b: B };
-6
View File
@@ -1,9 +1,3 @@
#target=x86_64-linux-selfhosted
//#target=x86_64-windows-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=x86_64-linux-llvm
//#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const std = @import("std");
+37 -11
View File
@@ -1989,6 +1989,26 @@ const c_abi_targets = blk: {
};
};
/// Unlike `test_targets` and `c_abi_targets`, these targets are just simple strings which we pass
/// directly to `incr-check`. They include the target triple and the compiler backend.
///
/// If only one specific test is failing on a target, instead of entirely disabling the target here,
/// you can skip the target for that specific test only by adding a line like this to the manifest:
/// #skip_target=x86_64-linux-selfhosted
const incremental_targets: []const []const u8 = &.{
// Avoid adding more CBE or LLVM targets without good reason: they're a lot slower than others
// to run due to the output (C source code or LLVM IR) being built non-incrementally (by Clang
// or LLVM). We just have a couple here to make sure that it works.
"x86_64-linux-cbe",
"x86_64-linux-llvm",
"x86_64-linux-selfhosted",
// https://codeberg.org/ziglang/zig/issues/31773
//"x86_64-windows-selfhosted",
// https://codeberg.org/ziglang/zig/issues/31810
//"wasm32-wasi-selfhosted",
};
fn compatible32bitArch(b: *std.Build) ?std.Target.Cpu.Arch {
const host = b.graph.host.result;
return switch (host.os.tag) {
@@ -2935,21 +2955,27 @@ pub fn addIncrementalTests(b: *std.Build, test_step: *Step, test_filters: []cons
if (std.mem.indexOf(u8, entry.path, test_filter)) |_| break;
} else if (test_filters.len > 0) continue;
const run = b.addRunArtifact(incr_check);
run.setName(b.fmt("incr-check '{s}'", .{entry.basename}));
for (incremental_targets) |target_str| {
const run = b.addRunArtifact(incr_check);
run.setName(b.fmt("incr-check {s} '{s}'", .{ target_str, entry.basename }));
run.addArg(b.graph.zig_exe);
run.addFileArg(b.path("test/incremental/").path(b, entry.path));
run.addArgs(&.{ "--zig-lib-dir", b.fmt("{f}", .{b.graph.zig_lib_directory}) });
run.addArg(b.graph.zig_exe);
run.addFileArg(b.path("test/incremental/").path(b, entry.path));
run.addArgs(&.{
"--zig-lib-dir", b.graph.zig_lib_directory.path orelse ".",
"--target", target_str,
});
if (b.enable_qemu) run.addArg("-fqemu");
if (b.enable_wine) run.addArg("-fwine");
if (b.enable_wasmtime) run.addArg("-fwasmtime");
if (b.enable_darling) run.addArg("-fdarling");
run.addArg("--quiet"); // don't fill stderr telling us about skipped tests etc
run.addCheck(.{ .expect_term = .{ .exited = 0 } });
if (b.enable_qemu) run.addArg("-fqemu");
if (b.enable_wine) run.addArg("-fwine");
if (b.enable_wasmtime) run.addArg("-fwasmtime");
if (b.enable_darling) run.addArg("-fdarling");
test_step.dependOn(&run.step);
run.addCheck(.{ .expect_term = .{ .exited = 0 } });
test_step.dependOn(&run.step);
}
}
}