simplify zig0 test setup: single test module, remove zig0_test.zig

Consolidate the two separate test modules (test_mod via
lib/std/zig/zig0_test.zig + astgen_test_mod via stage0_test_root.zig)
into a single test module rooted at stage0_test_root.zig.

The zig0_test.zig bridge approach ran std's parser/tokenizer tests with
C comparison enabled, but the stage0/ test files already do the same
C-vs-Zig comparison directly via @cImport. The only "lost" tests are an
unnamed root test block and a Zig-only fuzz test — no zig0 coverage lost.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 14:19:15 +00:00
parent 9bc6ac6679
commit 143234146e
3 changed files with 29 additions and 57 deletions

View File

@@ -1606,65 +1606,43 @@ fn addZig0TestStep(
valgrind: bool, valgrind: bool,
test_timeout: ?[]const u8, test_timeout: ?[]const u8,
) void { ) void {
const bridge_mod = b.createModule(.{
.root_source_file = b.path("stage0/zig0_bridge.zig"),
.target = target,
.optimize = optimize,
});
bridge_mod.addIncludePath(b.path("stage0"));
// Parser + tokenizer tests (hooks into std's test files via zig0 bridge)
const test_mod = b.createModule(.{ const test_mod = b.createModule(.{
.root_source_file = b.path("lib/std/zig/zig0_test.zig"),
.optimize = optimize,
.target = target,
});
test_mod.addImport("zig0_bridge", bridge_mod);
// AstGen tests (standalone C-vs-Zig ZIR comparison)
const astgen_test_mod = b.createModule(.{
.root_source_file = b.path("stage0_test_root.zig"), .root_source_file = b.path("stage0_test_root.zig"),
.optimize = optimize, .optimize = optimize,
.target = target, .target = target,
}); });
astgen_test_mod.addIncludePath(b.path("stage0")); test_mod.addIncludePath(b.path("stage0"));
addZig0CSources(b, test_mod, cc, optimize);
test_mod.linkSystemLibrary("c", .{});
const timeout: ?[]const u8 = test_timeout orelse if (valgrind) null else "10"; const timeout: ?[]const u8 = test_timeout orelse if (valgrind) null else "10";
for ([_]struct { mod: *std.Build.Module, name: []const u8 }{ const test_exe = b.addTest(.{
.{ .mod = test_mod, .name = "test" }, .root_module = test_mod,
.{ .mod = astgen_test_mod, .name = "astgen_test" }, .use_llvm = false,
}) |entry| { .use_lld = false,
addZig0CSources(b, entry.mod, cc, optimize); });
entry.mod.linkSystemLibrary("c", .{}); if (valgrind) {
test_exe.setExecCmd(&.{
const test_exe = b.addTest(.{ "valgrind",
.root_module = entry.mod, "--error-exitcode=2",
.use_llvm = false, "--leak-check=full",
.use_lld = false, "--show-leak-kinds=all",
"--errors-for-leak-kinds=all",
"--track-fds=yes",
"--quiet",
null,
}); });
if (valgrind) { } else {
test_exe.setExecCmd(&.{ test_exe.setExecCmd(&.{ "timeout", timeout orelse "10", null });
"valgrind", }
"--error-exitcode=2", if (no_exec) {
"--leak-check=full", const install = b.addInstallArtifact(test_exe, .{});
"--show-leak-kinds=all", step.dependOn(&install.step);
"--errors-for-leak-kinds=all", } else {
"--track-fds=yes", const run = b.addRunArtifact(test_exe);
"--quiet", run.step.name = b.fmt("test ({s})", .{cc});
null, step.dependOn(&run.step);
});
} else {
test_exe.setExecCmd(&.{ "timeout", timeout orelse "10", null });
}
if (no_exec) {
const install = b.addInstallArtifact(test_exe, .{});
step.dependOn(&install.step);
} else {
const run = b.addRunArtifact(test_exe);
run.step.name = b.fmt("{s} ({s})", .{ entry.name, cc });
step.dependOn(&run.step);
}
} }
} }

View File

@@ -1,6 +0,0 @@
pub const zig0 = @import("zig0_bridge");
test {
_ = @import("parser_test.zig");
_ = @import("tokenizer.zig");
}

View File

@@ -1,3 +1,3 @@
test { test {
_ = @import("stage0/astgen_test.zig"); _ = @import("stage0/test_all.zig");
} }