@@ -43,11 +43,23 @@ pub fn build(b: *std.Build) void {
4343 const run_embedding = b .addSystemCommand (&.{ wasmtime_opt , "--dir" , "/" });
4444 run_embedding .addArtifactArg (embedding_exe );
4545
46+ // ── Native test runner (replaces bash scripts) ────────────────────────────
47+
48+ const test_runner_mod = b .createModule (.{
49+ .root_source_file = b .path ("src/test_runner.zig" ),
50+ .target = b .graph .host ,
51+ .optimize = .Debug ,
52+ });
53+ test_runner_mod .link_libc = true ;
54+ const test_runner_exe = b .addExecutable (.{ .name = "test-runner" , .root_module = test_runner_mod });
55+
4656 // ── Conformance ───────────────────────────────────────────────────────────
4757
48- const conformance = b .addSystemCommand (&.{ "bash" , "./tests/run_conformance.sh" });
49- conformance .step .dependOn (& install_debug .step );
50- conformance .setEnvironmentVariable ("WASMTIME_BIN" , wasmtime_opt );
58+ const run_conformance = b .addRunArtifact (test_runner_exe );
59+ run_conformance .step .dependOn (& install_debug .step );
60+ run_conformance .addArg ("conformance" );
61+ run_conformance .addArg (wasmtime_opt );
62+ run_conformance .addArg ("build/gengo-runtime.wasm" );
5163
5264 // ── Named steps ───────────────────────────────────────────────────────────
5365
@@ -69,29 +81,51 @@ pub fn build(b: *std.Build) void {
6981 const test_step = b .step ("test" , "Run runtime safety, embedding API, and conformance tests" );
7082 test_step .dependOn (& run_vm_safety .step );
7183 test_step .dependOn (& run_embedding .step );
72- test_step .dependOn (& conformance .step );
84+ test_step .dependOn (& run_conformance .step );
7385
74- const bench = scriptStep (b , "bash" , "./tests/run_bench.sh" , & install_debug .step , wasmtime_opt );
86+ const run_bench = b .addRunArtifact (test_runner_exe );
87+ run_bench .step .dependOn (& install_debug .step );
88+ run_bench .addArg ("bench" );
89+ run_bench .addArg (wasmtime_opt );
90+ run_bench .addArg ("build/gengo-runtime.wasm" );
7591 const bench_step = b .step ("bench" , "Run benchmark suite" );
76- bench_step .dependOn (& bench .step );
92+ bench_step .dependOn (& run_bench .step );
7793
78- const bench_release = scriptStep (b , "bash" , "./tests/run_bench.sh" , & install_release .step , wasmtime_opt );
94+ const run_bench_release = b .addRunArtifact (test_runner_exe );
95+ run_bench_release .step .dependOn (& install_release .step );
96+ run_bench_release .addArg ("bench" );
97+ run_bench_release .addArg (wasmtime_opt );
98+ run_bench_release .addArg ("build/gengo-runtime.wasm" );
7999 const bench_release_step = b .step ("bench-release" , "Run benchmark suite (ReleaseFast)" );
80- bench_release_step .dependOn (& bench_release .step );
100+ bench_release_step .dependOn (& run_bench_release .step );
81101
82102 // bench-perf: perf-instrumented debug build; outputs PERF: lines to stderr
83103 const perf_opts = b .addOptions ();
84104 perf_opts .addOption (bool , "perf" , true );
85105 const perf_opts_mod = perf_opts .createModule ();
86106 const gengo_perf = addWasmExe (b , "gengo-perf" , "src/main.zig" , wasm_target , .Debug , & preset .step , perf_opts_mod );
87107 const install_perf = installWasmAs (b , gengo_perf , "gengo-perf.wasm" );
88- const bench_perf = scriptStep (b , "bash" , "./scripts/perf/run.sh" , & install_perf .step , wasmtime_opt );
108+
109+ const bench_perf_runner_mod = b .createModule (.{
110+ .root_source_file = b .path ("src/bench_perf_runner.zig" ),
111+ .target = b .graph .host ,
112+ .optimize = .Debug ,
113+ });
114+ bench_perf_runner_mod .link_libc = true ;
115+ const bench_perf_runner_exe = b .addExecutable (.{ .name = "bench-perf-runner" , .root_module = bench_perf_runner_mod });
116+ const run_bench_perf = b .addRunArtifact (bench_perf_runner_exe );
117+ run_bench_perf .step .dependOn (& install_perf .step );
118+ run_bench_perf .addArg (wasmtime_opt );
89119 const bench_perf_step = b .step ("bench-perf" , "Run benchmarks with perf counters (PERF: lines on stderr)" );
90- bench_perf_step .dependOn (& bench_perf .step );
120+ bench_perf_step .dependOn (& run_bench_perf .step );
91121
92- const parity = scriptStep (b , "bash" , "./tests/run_host_parity.sh" , & install_debug .step , wasmtime_opt );
122+ const run_parity = b .addRunArtifact (test_runner_exe );
123+ run_parity .step .dependOn (& install_debug .step );
124+ run_parity .addArg ("parity" );
125+ run_parity .addArg (wasmtime_opt );
126+ run_parity .addArg ("build/gengo-runtime.wasm" );
93127 const parity_step = b .step ("parity" , "Run host/embedded parity tests" );
94- parity_step .dependOn (& parity .step );
128+ parity_step .dependOn (& run_parity .step );
95129
96130 // ── Native CLI ────────────────────────────────────────────────────────────
97131
@@ -189,15 +223,4 @@ fn installWasmAs(
189223 return step ;
190224}
191225
192- fn scriptStep (
193- b : * std.Build ,
194- shell : []const u8 ,
195- script : []const u8 ,
196- depends_on : * std.Build.Step ,
197- wasmtime : []const u8 ,
198- ) * std.Build.Step.Run {
199- const step = b .addSystemCommand (&.{ shell , script });
200- step .step .dependOn (depends_on );
201- step .setEnvironmentVariable ("WASMTIME_BIN" , wasmtime );
202- return step ;
203- }
226+
0 commit comments