test: run example corpus in zig build test; sx ir → stdout

`zig build test` now runs the full examples/ + issues/ regression corpus
alongside the Zig unit tests, driven by a pure-Zig test
(src/corpus_run.test.zig) — no shell script in the build path. It spawns
the installed `sx` per example (subprocess-isolated, per-run timeout),
diffs stdout/stderr/exit and optional `sx ir` snapshots, and fails the
build on any mismatch. The file list is enumerated at runtime, so new
examples are covered with no test edit.

- `sx ir` / `ir-dump` now write to stdout (fd 1) instead of stderr, so
  the dumps can be piped/redirected.
- `zig build test -Dupdate-goldens` regenerates snapshots in-build,
  byte-identical to the legacy `run_examples.sh --update`; on mismatch
  the runner prints how to regenerate.
- run_examples.sh kept (still used by tools/verify-step.sh) and made
  portable to a bare macOS: timeout/gtimeout fallback, bash 3.2-safe
  empty-array handling.
- CLAUDE.md: document the new workflow.
This commit is contained in:
agra
2026-06-13 09:41:56 +03:00
parent 39488133c9
commit ab3c9202ff
7 changed files with 464 additions and 25 deletions

View File

@@ -2917,7 +2917,11 @@ pub const LLVMEmitter = struct {
const ir_str = c.LLVMPrintModuleToString(self.llvm_module);
defer c.LLVMDisposeMessage(ir_str);
const len = std.mem.len(ir_str);
std.debug.print("{s}\n", .{ir_str[0..len]});
// Write to fd 1 (stdout), not std.debug.print (stderr): `sx ir` is a
// data-emitting command meant to be piped/redirected, so the IR text
// belongs on stdout. Mirrors core.flushInterpOutput's raw-write route.
_ = std.c.write(1, ir_str, len);
_ = std.c.write(1, "\n", 1);
}
/// Emit the module as an object file to disk.