test(runner): make example suite checkout-location independent

Diagnostics embed the absolute source path, but normalize() only scrubbed
hex addresses, so expected snapshots baked in the canonical checkout path
(/Users/agra/projects/sx/...). The suite only passed when run from that exact
directory; from a git worktree all 44 path-printing diagnostics mismatched.

Collapse any absolute `.../examples/` or `.../issues/` prefix to the repo-
relative form. The rule runs through normalize(), which is applied identically
to both expected and actual output, so it can only reconcile path noise — it
cannot desync an otherwise-matching pair. No snapshots regenerated.

Suite now reports 350 passed / 0 failed from a worktree as well as the
canonical tree.
This commit is contained in:
agra
2026-06-02 11:18:12 +03:00
parent bd01d2224d
commit 795ce3dc7d

View File

@@ -31,8 +31,16 @@ if [[ "${1:-}" == "--update" ]]; then
UPDATE=1
fi
# Normalize stdout/stderr for snapshot diffing. Applied identically to both
# expected and actual, so it can only reconcile location/host noise — never
# desync an otherwise-matching pair. The path rule collapses any absolute
# `.../examples/` or `.../issues/` prefix (diagnostics embed the source path)
# down to the repo-relative form, so snapshots are checkout-location independent
# (canonical tree vs. a git worktree).
normalize() {
sed 's/0x[0-9a-f]\{4,\}/0xADDR/g'
sed -E \
-e 's/0x[0-9a-f]{4,}/0xADDR/g' \
-e 's#(/[^[:space:]]*)?/(examples|issues)/#\2/#g'
}
# Normalize `sx ir` output for snapshot diffing (host-specific noise + LLVM