mirror of
https://github.com/xroche/httrack.git
synced 2026-07-28 03:22:12 +03:00
Under set -e a failing command in an EXIT trap becomes the script's exit status, so a cleanup hiccup fails a test whose assertions all passed. Run teardown with errexit off, on EXIT only: sharing set +e with the signal traps would leave errexit off for the rest of a signalled run, where a torn-down test could still report success. A failing teardown command still prints its own diagnostic, so nothing is silenced. The return 0 that three cleanup() bodies ended with never protected anything: errexit fires at the failing command before it is reached. Closes #773 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Xavier Roche <xroche@gmail.com>
32 lines
830 B
Bash
32 lines
830 B
Bash
#!/bin/bash
|
|
#
|
|
|
|
set -euo pipefail
|
|
|
|
tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/httrack_changes_st.XXXXXX") || exit 1
|
|
trap 'set +e; rm -rf "$tmpdir"' EXIT
|
|
trap 'rm -rf "$tmpdir"' HUP INT QUIT PIPE TERM
|
|
|
|
# No pipe into grep: SIGPIPE would mask a failing exit status.
|
|
expect_ok() {
|
|
local label="$1" out
|
|
shift
|
|
out=$("$@" 2>&1) || {
|
|
echo "FAIL: ${label} exited non-zero: ${out}"
|
|
exit 1
|
|
}
|
|
case "$out" in
|
|
*"${label}: OK"*) ;;
|
|
*)
|
|
echo "FAIL: ${out}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# --changes bucket accounting and JSON escaping (#714).
|
|
expect_ok "changes self-test" httrack -O "${tmpdir}/o1" -#test=changes run
|
|
# The report must hold against a transfer thread the crawl never joins.
|
|
expect_ok "changes-race self-test" httrack -O "${tmpdir}/o2" \
|
|
-#test=changes-race "${tmpdir}/race"
|