tests: make the error-ordering check explicit about absent lines
commit efdd15f4931d9018cb191e4a1b6e421e14e3f2d1 · parent b6ebe86871
· browse this tree
Ximianth, 2026-10-19 11:54:49 UTC
The order comparison leaned on a set -e exemption subtlety and failed with a test(1) syntax error when the detail line was missing; now a missing line is a plain comparison failure.
diff --git a/tests/test-errors.sh b/tests/test-errors.sh index 493eb8f..1e8933b 100755 --- a/tests/test-errors.sh +++ b/tests/test-errors.sh @@ -24,9 +24,10 @@ EXPECT success "our message leads, with the patch path relative and quoted" -- \ grep -q "^patchette: 'topic¦fancy/teach-gizmo-to-hum.patch': diff does not apply onto its parent$" "$work/out" EXPECT success "git's own stderr follows, indented as detail" -- \ grep -q "^ error: patch failed" "$work/out" -ours=$(grep -nm1 '^patchette:' "$work/out") && ours=${ours%%:*} -detail=$(grep -nm1 '^ error:' "$work/out") && detail=${detail%%:*} -EXPECT success "and in that order" -- \ - test "$ours" -lt "$detail" +ours=$(grep -nm1 '^patchette:' "$work/out" || true) +detail=$(grep -nm1 '^ error:' "$work/out" || true) +order=disordered +if [[ -n $ours && -n $detail && ${ours%%:*} -lt ${detail%%:*} ]]; then order=ordered; fi +EXPECT equal "and in that order" -- "$order" "ordered" exit "$RESULT"