test harness: add -Dname to scope the corpus to specific examples

`zig build test -Dname=examples/0625-foo.sx[,examples/0626-bar.sx]` runs ONLY the
named example(s) — full repo-relative .sx paths, comma-separated (a leading `./`
is tolerated). Empty = run everything (unchanged default).

Why: a full `-Dupdate-goldens` re-runs and rewrites all ~690 snapshots, so one
flaky/host-divergent example (AOT links, cross-arch `target` examples) can clobber
a good snapshot. `-Dname` regenerates only the named example(s) and touches
nothing else. It also busts the cached test-run result — the corpus enumerates
.sx/expected files at runtime, so a bare snapshot edit alone is otherwise served
from cache.

- build.zig: new `name` option threaded onto corpus_paths.
- corpus_run.test.zig: `nameMatchesFilter` + a per-example skip in the run loop.
- CLAUDE.md: document the targeted-regen workflow under Snapshot integrity.
This commit is contained in:
agra
2026-06-17 14:55:06 +03:00
parent 0b4c50b187
commit 88c4cbcfa5
3 changed files with 54 additions and 0 deletions

View File

@@ -218,6 +218,20 @@ pub fn build(b: *std.Build) void {
"Regenerate example/issue snapshots instead of verifying them (use with `zig build test`)",
) orelse false;
corpus_opts.addOption(bool, "update_goldens", update_goldens);
// `zig build test -Dname=examples/0213-foo.sx[,examples/0214-bar.sx]` restricts
// the corpus runner to ONLY the named example(s) — full repo-relative `.sx`
// paths, comma-separated. Empty = run every example. Use it to verify or
// regenerate (-Dupdate-goldens) a specific example without re-running (or
// clobbering the snapshots of) the rest of the corpus. Because the value is
// baked into the corpus options module, changing it also busts the cached
// test-run result (the runner enumerates .sx/expected files at RUNTIME, so a
// bare snapshot edit alone would otherwise be served from cache).
const name_filter = b.option(
[]const u8,
"name",
"Run only the named example(s): comma-separated repo-relative .sx paths (e.g. examples/0213-foo.sx)",
) orelse "";
corpus_opts.addOption([]const u8, "name", name_filter);
mod.addOptions("corpus_paths", corpus_opts);
const mod_tests = b.addTest(.{