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