main: "--- build done ---" delimiter on stderr for top-level #run

Tests that exercise top-level #run produce two interleaved
output streams: the interp's #run prints (flushed via
std.debug.print → stderr at core.zig:187/190) and the JIT-
executed main's prints (libc write fd=1 → stdout). When the
test runner captures both via 2>&1 the boundary between them
is invisible — the snapshot reads as one block.

Now `sx run` emits "--- build done ---\n" on stderr right
before invoking the JIT, when `hasTopLevelRun(root)` is true.
Tests without top-level #run keep their current snapshots
unchanged; only the 7 affected tests pick up the delimiter
between the build-time and run-time sections.

Example: 05-run flips from
    hello 25
    hello 25
to
    hello 25
    --- build done ---
    hello 25

— the first "hello 25" is from `#run main()` running at
compile time, the second is from JIT main() running at
runtime. The delimiter makes that explicit.

204/204 example tests + `zig build test` green.
This commit is contained in:
agra
2026-05-27 17:08:14 +03:00
parent d91a15f6c9
commit 2993072972
8 changed files with 16 additions and 1 deletions

View File

@@ -283,6 +283,15 @@ pub fn main(init: std.process.Init) !void {
// JIT from precompiled object (relocation only, no IR compilation)
sx.llvm_api.initNativeTarget();
timer.mark();
// Phase separator: emit a clear delimiter between any #run output
// (which prints via the interp to stderr) and the JIT-executed
// main's runtime output (which writes to stdout). Without this,
// test logs and human-eye reads interleave compile-time and
// run-time output ambiguously. Only when top-level #run exists —
// pure-runtime tests keep their current snapshots.
if (hasTopLevelRun(root)) {
std.debug.print("--- build done ---\n", .{});
}
const exit_code = sx.target.runJITFromObject(obj_buf) catch {
// JIT failed — fall back to AOT
timer.record("jit-fail");

View File

@@ -1,2 +1,3 @@
hello 25
--- build done ---
hello 25

View File

@@ -1 +1,2 @@
--- build done ---
runtime main

View File

@@ -1 +1,2 @@
--- build done ---
rt

View File

@@ -1 +1,2 @@
--- build done ---
rt

View File

@@ -1 +1,2 @@
--- build done ---
ios-sim runtime main

View File

@@ -1,3 +1,4 @@
--- build done ---
build config: ok
pointer size: 8
os: macos

View File

@@ -1 +1 @@
--- build done ---