tests: add test-incremental step

This is contained in the `test` step, so is tested by CI.

This commit also includes some enhancements to the `incr-check` tool to
make this work correctly.
This commit is contained in:
mlugg 2024-08-20 18:09:23 +01:00
parent d23db9427b
commit f60c045cef
No known key found for this signature in database
GPG key ID: 3F5B7DCCBF4AF02E
3 changed files with 35 additions and 1 deletions

View file

@ -577,6 +577,10 @@ pub fn build(b: *std.Build) !void {
} else { } else {
update_mingw_step.dependOn(&b.addFail("The -Dmingw-src=... option is required for this step").step); update_mingw_step.dependOn(&b.addFail("The -Dmingw-src=... option is required for this step").step);
} }
const test_incremental_step = b.step("test-incremental", "Run the incremental compilation test cases");
try tests.addIncrementalTests(b, test_incremental_step);
test_step.dependOn(test_incremental_step);
} }
fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {

View file

@ -1509,3 +1509,31 @@ pub fn addDebuggerTests(b: *std.Build, options: DebuggerContext.Options) ?*Step
}); });
return step; return step;
} }
pub fn addIncrementalTests(b: *std.Build, test_step: *Step) !void {
const incr_check = b.addExecutable(.{
.name = "incr-check",
.root_source_file = b.path("tools/incr-check.zig"),
.target = b.graph.host,
.optimize = .Debug,
});
var dir = try b.build_root.handle.openDir("test/incremental", .{ .iterate = true });
defer dir.close();
var it = try dir.walk(b.graph.arena);
while (try it.next()) |entry| {
if (entry.kind != .file) continue;
const run = b.addRunArtifact(incr_check);
run.setName(b.fmt("incr-check '{s}'", .{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("{}", .{b.graph.zig_lib_directory}) });
run.addCheck(.{ .expect_term = .{ .Exited = 0 } });
test_step.dependOn(&run.step);
}
}

View file

@ -68,7 +68,9 @@ pub fn main() !void {
const debug_log_verbose = debug_zcu or debug_link; const debug_log_verbose = debug_zcu or debug_link;
for (case.targets) |target| { for (case.targets) |target| {
if (debug_log_verbose) {
std.log.scoped(.status).info("target: '{s}-{s}'", .{ target.query, @tagName(target.backend) }); std.log.scoped(.status).info("target: '{s}-{s}'", .{ target.query, @tagName(target.backend) });
}
var child_args: std.ArrayListUnmanaged([]const u8) = .empty; var child_args: std.ArrayListUnmanaged([]const u8) = .empty;
try child_args.appendSlice(arena, &.{ try child_args.appendSlice(arena, &.{