From 143234146e2023e8f8d3b11e635d5f220736082e Mon Sep 17 00:00:00 2001 From: Motiejus Date: Sat, 14 Feb 2026 14:19:15 +0000 Subject: [PATCH] simplify zig0 test setup: single test module, remove zig0_test.zig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- build.zig | 78 ++++++++++++++------------------------- lib/std/zig/zig0_test.zig | 6 --- stage0_test_root.zig | 2 +- 3 files changed, 29 insertions(+), 57 deletions(-) delete mode 100644 lib/std/zig/zig0_test.zig diff --git a/build.zig b/build.zig index 5028b3f070..7b1a86499c 100644 --- a/build.zig +++ b/build.zig @@ -1606,65 +1606,43 @@ 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, - .use_llvm = false, - .use_lld = false, + const test_exe = b.addTest(.{ + .root_module = test_mod, + .use_llvm = false, + .use_lld = false, + }); + if (valgrind) { + test_exe.setExecCmd(&.{ + "valgrind", + "--error-exitcode=2", + "--leak-check=full", + "--show-leak-kinds=all", + "--errors-for-leak-kinds=all", + "--track-fds=yes", + "--quiet", + null, }); - if (valgrind) { - test_exe.setExecCmd(&.{ - "valgrind", - "--error-exitcode=2", - "--leak-check=full", - "--show-leak-kinds=all", - "--errors-for-leak-kinds=all", - "--track-fds=yes", - "--quiet", - null, - }); - } 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); - } + } 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("test ({s})", .{cc}); + step.dependOn(&run.step); } } diff --git a/lib/std/zig/zig0_test.zig b/lib/std/zig/zig0_test.zig deleted file mode 100644 index 72f2b7f807..0000000000 --- a/lib/std/zig/zig0_test.zig +++ /dev/null @@ -1,6 +0,0 @@ -pub const zig0 = @import("zig0_bridge"); - -test { - _ = @import("parser_test.zig"); - _ = @import("tokenizer.zig"); -} diff --git a/stage0_test_root.zig b/stage0_test_root.zig index 3ca87c275d..525f3e60f2 100644 --- a/stage0_test_root.zig +++ b/stage0_test_root.zig @@ -1,3 +1,3 @@ test { - _ = @import("stage0/astgen_test.zig"); + _ = @import("stage0/test_all.zig"); }