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:
32
build.zig
32
build.zig
@@ -1606,40 +1606,19 @@ fn addZig0TestStep(
|
||||
valgrind: bool,
|
||||
test_timeout: ?[]const u8,
|
||||
) 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(.{
|
||||
.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"),
|
||||
.optimize = optimize,
|
||||
.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";
|
||||
|
||||
for ([_]struct { mod: *std.Build.Module, name: []const u8 }{
|
||||
.{ .mod = test_mod, .name = "test" },
|
||||
.{ .mod = astgen_test_mod, .name = "astgen_test" },
|
||||
}) |entry| {
|
||||
addZig0CSources(b, entry.mod, cc, optimize);
|
||||
entry.mod.linkSystemLibrary("c", .{});
|
||||
|
||||
const test_exe = b.addTest(.{
|
||||
.root_module = entry.mod,
|
||||
.root_module = test_mod,
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
});
|
||||
@@ -1662,10 +1641,9 @@ fn addZig0TestStep(
|
||||
step.dependOn(&install.step);
|
||||
} else {
|
||||
const run = b.addRunArtifact(test_exe);
|
||||
run.step.name = b.fmt("{s} ({s})", .{ entry.name, cc });
|
||||
run.step.name = b.fmt("test ({s})", .{cc});
|
||||
step.dependOn(&run.step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn addZig0CSources(
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
pub const zig0 = @import("zig0_bridge");
|
||||
|
||||
test {
|
||||
_ = @import("parser_test.zig");
|
||||
_ = @import("tokenizer.zig");
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
test {
|
||||
_ = @import("stage0/astgen_test.zig");
|
||||
_ = @import("stage0/test_all.zig");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user