mirror of
https://github.com/xroche/httrack.git
synced 2026-07-28 11:32:48 +03:00
Under `set -e` a failing command in an EXIT trap becomes the script's exit status, so a hiccup while tearing down fixtures fails a test whose assertions all passed. That is what turned `57_local-proxy-connect.test` red on the Windows x64 leg of #765: five OK lines, no FAIL, exit 1. Every EXIT trap in the suite now runs teardown with errexit off, and the signal traps keep their own `trap` line, since sharing `set +e` with HUP/INT/QUIT/PIPE/TERM would leave errexit off for the rest of a signalled run and let a torn-down test still report success. A `|| true` on the `rm` would have been smaller, but it throws away the only diagnostic, and the evidence does not say which teardown command failed: a blocked `rm -rf` on the Windows runner exits 1 and prints "Device or resource busy", while the log shows exit 1 and nothing at all. The sharing violation in the issue is the plausible mechanism rather than a confirmed one, so whatever it really is now prints its own error. `99_teardown-status.test` pins the semantics both ways and scans the suite so a new test cannot reintroduce the shape, the leaky combined trap included. The `return 0` that three `cleanup()` bodies ended with never protected anything, since errexit fires at the failing command before it is reached. Closes #773 Signed-off-by: Xavier Roche <roche@httrack.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
33 lines
1.3 KiB
Bash
33 lines
1.3 KiB
Bash
#!/bin/bash
|
|
# An ARC entry's HTTP reason phrase must survive a proxytrack --convert
|
|
# round-trip; it used to be clipped to sizeof(char*) - 1 bytes.
|
|
|
|
set -euo pipefail
|
|
|
|
dir=$(mktemp -d)
|
|
trap 'set +e; rm -rf "$dir"' EXIT
|
|
|
|
printf 'HTTP/1.1 404 Not Found Here At All\r\nContent-Type: text/html\r\nLast-Modified: Wed, 01 Jan 2025 00:00:00 GMT\r\nContent-Length: 5\r\n\r\n' >"$dir/hdr"
|
|
printf 'hello' >"$dir/body"
|
|
alen=$(($(wc -c <"$dir/hdr") + $(wc -c <"$dir/body")))
|
|
|
|
# ARC 1.0: filedesc record and version block, then per entry
|
|
# <nl> <URL-record> <nl> <headers> <body>; the record's last field is that length.
|
|
{
|
|
printf 'filedesc://t.arc 0.0.0.0 20250101000000 text/plain 200 - - 0 t.arc 9\n'
|
|
printf '2 0 test\n'
|
|
printf '\n\n'
|
|
printf 'http://example.com/page.html 0.0.0.0 20250101000000 text/html 404 - - 0 t.arc %d\n' "$alen"
|
|
cat "$dir/hdr" "$dir/body"
|
|
} >"$dir/in.arc"
|
|
|
|
proxytrack --convert "$dir/out.arc" "$dir/in.arc" >/dev/null 2>&1
|
|
|
|
# HTTP/1.0 is the writer's own prefix (the input says 1.1), so a verbatim copy
|
|
# of the input cannot satisfy this match.
|
|
grep -aqF 'HTTP/1.0 404 Not Found Here At All' "$dir/out.arc" || {
|
|
echo "reason phrase lost in the ARC round-trip:" >&2
|
|
grep -a '^HTTP/' "$dir/out.arc" >&2 || echo "(no status line at all)" >&2
|
|
exit 1
|
|
}
|