From 795ce3dc7d55b3483d051afd1d48e303b003abbc Mon Sep 17 00:00:00 2001 From: agra Date: Tue, 2 Jun 2026 11:18:12 +0300 Subject: [PATCH] test(runner): make example suite checkout-location independent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tests/run_examples.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/run_examples.sh b/tests/run_examples.sh index 4829aa4..264cb33 100755 --- a/tests/run_examples.sh +++ b/tests/run_examples.sh @@ -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