Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ the operational checklist: toolchain, invariants, and how to ship a change.
check`, or `PATH="<bld>/src:$PATH"` for a manual run.
- Give new `.test` scripts `set -e`: the older ones predate the rule, so several
`local-crawl.sh` calls with no `set -e` report PASS on any non-last failure.
- Run teardown with errexit off: `trap 'set +e; cleanup' EXIT`. Under `set -e` a
failing cleanup command becomes the test's exit status (#773). Keep the other
signals on their own `trap` line, or errexit stays off for the rest of the run.
The guard also resets `$?`, so save it first if teardown reads it.
- Never assert with `cmd | grep -q MARKER && fail`. Under `pipefail` the
pipeline is non-zero both when `cmd` fails and when `grep -q` matches early
and SIGPIPEs it, so the `&&` never fires and a probe that proved nothing reads
Expand Down
3 changes: 2 additions & 1 deletion tests/01_engine-changes.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
set -euo pipefail

tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/httrack_changes_st.XXXXXX") || exit 1
trap 'rm -rf "$tmpdir"' EXIT HUP INT QUIT PIPE TERM
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() {
Expand Down
3 changes: 2 additions & 1 deletion tests/01_engine-cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
set -euo pipefail

tmp=$(mktemp -d "${TMPDIR:-/tmp}/httrack_cmdline.XXXXXX") || exit 1
trap 'rm -rf "$tmp"' EXIT HUP INT QUIT PIPE TERM
trap 'set +e; rm -rf "$tmp"' EXIT
trap 'rm -rf "$tmp"' HUP INT QUIT PIPE TERM

echo '<html><body>hello</body></html>' >"$tmp/index.html"

Expand Down
2 changes: 1 addition & 1 deletion tests/01_engine-cookieimport.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ set -euo pipefail
# cookies *@*.txt) from a long, non-ASCII folder through the UTF-8/long-path
# file wrappers (#133,#630).
dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

httrack -O /dev/null -#test=cookieimport "$dir" | grep -q "cookieimport:.*OK"
2 changes: 1 addition & 1 deletion tests/01_engine-direnum.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ set -euo pipefail
# Drives -#test=direnum: enumerate a long+non-ASCII directory through the
# opendir/readdir wrappers, checking each child round-trips as UTF-8 (#133,#630).
dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

httrack -O /dev/null -#test=direnum "$dir" | grep -q "direnum:.*OK"
3 changes: 2 additions & 1 deletion tests/01_engine-doitlog.test
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ case "$bin" in
esac

tmp=$(mktemp -d "${TMPDIR:-/tmp}/httrack_doitlog.XXXXXX") || exit 1
trap 'rm -rf "$tmp"' EXIT HUP INT QUIT PIPE TERM
trap 'set +e; rm -rf "$tmp"' EXIT
trap 'rm -rf "$tmp"' HUP INT QUIT PIPE TERM

site="$tmp/site"
out="$tmp/out"
Expand Down
3 changes: 2 additions & 1 deletion tests/01_engine-filelist.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
set -euo pipefail

tmp=$(mktemp -d "${TMPDIR:-/tmp}/httrack_filelist.XXXXXX") || exit 1
trap 'rm -rf "$tmp"' EXIT HUP INT QUIT PIPE TERM
trap 'set +e; rm -rf "$tmp"' EXIT
trap 'rm -rf "$tmp"' HUP INT QUIT PIPE TERM

echo '<html><body>hi</body></html>' >"$tmp/index.html"

Expand Down
2 changes: 1 addition & 1 deletion tests/01_engine-footer-overflow.test
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ MINGW* | MSYS* | CYGWIN*) exit 77 ;;
esac

dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

# A few-hundred-char file path (kept well under the URL length limit) makes the
# {path} field long.
Expand Down
2 changes: 1 addition & 1 deletion tests/01_engine-fsize.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
set -euo pipefail

dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

rc=0
out=$(httrack -#test=fsize "$dir") || rc=$?
Expand Down
3 changes: 2 additions & 1 deletion tests/01_engine-growsize.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ echo "$out"
test "$out" == "growsize self-test OK"

tmp=$(mktemp -d "${TMPDIR:-/tmp}/httrack_growsize.XXXXXX")
trap 'rm -rf "$tmp"' EXIT HUP INT QUIT PIPE TERM
trap 'set +e; rm -rf "$tmp"' EXIT
trap 'rm -rf "$tmp"' HUP INT QUIT PIPE TERM

echo '<html><body>hi</body></html>' >"$tmp/index.html"
printf -- '-*/zzmarker*\n' >"$tmp/rules.txt"
Expand Down
2 changes: 1 addition & 1 deletion tests/01_engine-longpath-io.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ set -euo pipefail
# Drives -#test=longpath: a >MAX_PATH round trip exercising hts_pathToUCS2's
# \\?\ prefixing on Windows (#133); a positive control on POSIX.
dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

httrack -O /dev/null -#test=longpath "$dir" | grep -q "longpath:.*OK"
2 changes: 1 addition & 1 deletion tests/01_engine-makeindex.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -euo pipefail
# hts_finish_makeindex writes the footer and gates the refresh meta on a single
# first link (guards the macro->function extraction).
dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

httrack -O /dev/null -#test=makeindex "$dir" run |
grep -q "makeindex self-test OK"
2 changes: 1 addition & 1 deletion tests/01_engine-mirror-io.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ set -euo pipefail
# (>MAX_PATH) and non-ASCII, exercising the mirror I/O wrappers the engine's
# raw file ops now route to on Windows (#133, #630). Positive control on POSIX.
dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

httrack -O /dev/null -#test=mirrorio "$dir" | grep -q "mirrorio:.*OK"
3 changes: 2 additions & 1 deletion tests/01_engine-parse.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
set -euo pipefail

tmp=$(mktemp -d "${TMPDIR:-/tmp}/httrack_parse.XXXXXX") || exit 1
trap 'rm -rf "$tmp"' EXIT HUP INT QUIT PIPE TERM
trap 'set +e; rm -rf "$tmp"' EXIT
trap 'rm -rf "$tmp"' HUP INT QUIT PIPE TERM

# a minimal valid 1x1 GIF, reused for every referenced asset
gif() {
Expand Down
3 changes: 2 additions & 1 deletion tests/01_engine-rcfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ case "$bin" in
esac

tmp=$(mktemp -d "${TMPDIR:-/tmp}/httrack_rcfile.XXXXXX") || exit 1
trap 'rm -rf "$tmp"' EXIT HUP INT QUIT PIPE TERM
trap 'set +e; rm -rf "$tmp"' EXIT
trap 'rm -rf "$tmp"' HUP INT QUIT PIPE TERM

# HTS_HTTRACKRC is ".httrackrc" on POSIX but "httrackrc" on Windows: write both,
# each platform reads the one it knows.
Expand Down
2 changes: 1 addition & 1 deletion tests/01_engine-reconcile.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set -eu

dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

out=$(httrack -#test=reconcile "$dir")

Expand Down
2 changes: 1 addition & 1 deletion tests/01_engine-renameover.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -euo pipefail
# fix (#779). The selftest prints the regime it detected; pin it per platform so
# a leg cannot pass having tested the other half.
dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

case "$(uname -s)" in
MINGW* | MSYS_NT*) want=fallback ;; # native rename() refuses an existing target
Expand Down
2 changes: 1 addition & 1 deletion tests/01_engine-savename.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ httrack_bin=$(cd "$(dirname "$(command -v httrack)")" && pwd)/httrack

# scratch dir: body= and cached= write temp files (st-savename-body.tmp, hts-cache/)
scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
trap 'set +e; rm -rf "$scratch"' EXIT
cd "$scratch"

run() {
Expand Down
2 changes: 1 addition & 1 deletion tests/01_engine-structcheck.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
set -euo pipefail

dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

httrack -O /dev/null -#test=structcheck "$dir" |
grep -q "structcheck self-test OK"
3 changes: 2 additions & 1 deletion tests/01_engine-threadwait.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
set -euo pipefail

tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/httrack_threadwait_st.XXXXXX") || exit 1
trap 'rm -rf "$tmpdir"' EXIT HUP INT QUIT PIPE TERM
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() {
Expand Down
2 changes: 1 addition & 1 deletion tests/01_engine-topindex.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -euo pipefail
# hts_buildtopindex takes a system-charset path but verif_backblue below it
# expects utf-8, mangling a non-ASCII project dir on Windows (#216, #217).
dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

httrack -O /dev/null -#test=topindex "$dir" run |
grep -q "topindex self-test OK"
2 changes: 1 addition & 1 deletion tests/01_zlib-acceptencoding.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail

# Accept-Encoding (#450): advertise gzip+deflate; decode gzip/zlib/raw-deflate.
dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

httrack -O /dev/null -#test=acceptencoding "$dir" run |
grep -q "acceptencoding self-test OK"
2 changes: 1 addition & 1 deletion tests/01_zlib-cache-corrupt.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set -eu

dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

# the smashed-header case logs expected "Corrupted cache entry" warnings on
# stdout; the verdict is the last line
Expand Down
2 changes: 1 addition & 1 deletion tests/01_zlib-cache-golden.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test -e "$fixture/hts-cache/new.zip" || {
}

dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

# Read against a private copy so the source tree is never touched (a read
# session does not write, but copying keeps the test hermetic). Create the dir
Expand Down
2 changes: 1 addition & 1 deletion tests/01_zlib-cache-legacy.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
set -eu

dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

# the refusal errors land on stdout (no log file); pin them and the verdict
out=$(httrack -#test=cache-legacy "$dir" 2>/dev/null)
Expand Down
2 changes: 1 addition & 1 deletion tests/01_zlib-cache-writefail.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
set -eu

dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

out=$(httrack -#test=cache-writefail "$dir")

Expand Down
2 changes: 1 addition & 1 deletion tests/01_zlib-cache.test
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
set -eu

dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

# The working directory is a required argument; without it the test prints a
# usage line to stderr and returns non-zero.
Expand Down
2 changes: 1 addition & 1 deletion tests/01_zlib-contentcodings.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail

# brotli/zstd decode, unknown codings, and the decoded-size budget.
dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

httrack -O /dev/null -#test=contentcodings "$dir" run |
grep -q "contentcodings self-test OK"
2 changes: 1 addition & 1 deletion tests/01_zlib-repair-shift.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
set -eu

dir=$(mktemp -d)
trap 'rm -rf "$dir"' EXIT
trap 'set +e; rm -rf "$dir"' EXIT

out=$(httrack -#test=zip-repair-shift "$dir")

Expand Down
2 changes: 1 addition & 1 deletion tests/01_zlib-savename-cached.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set -euo pipefail
httrack_bin=$(cd "$(dirname "$(command -v httrack)")" && pwd)/httrack

scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
trap 'set +e; rm -rf "$scratch"' EXIT
cd "$scratch"

name() {
Expand Down
2 changes: 1 addition & 1 deletion tests/01_zlib-warc-cdx.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -euo pipefail
httrack_bin=$(cd "$(dirname "$(command -v httrack)")" && pwd)/httrack

scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
trap 'set +e; rm -rf "$scratch"' EXIT

out=$("$httrack_bin" -O /dev/null -#test=warc-cdx "$scratch/")
echo "$out"
Expand Down
2 changes: 1 addition & 1 deletion tests/01_zlib-warc-wacz.test
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if ! "$httrack_bin" -#test 2>&1 | grep -q '^ warc-wacz'; then
fi

scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
trap 'set +e; rm -rf "$scratch"' EXIT

out=$("$httrack_bin" -O /dev/null -#test=warc-wacz "$scratch/")
echo "$out"
Expand Down
2 changes: 1 addition & 1 deletion tests/01_zlib-warc.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set -euo pipefail
httrack_bin=$(cd "$(dirname "$(command -v httrack)")" && pwd)/httrack

scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
trap 'set +e; rm -rf "$scratch"' EXIT

for t in warc warc-trunc warc-ftp warc-rotate warc-verbatim; do
out=$("$httrack_bin" -O /dev/null "-#test=$t" "$scratch/")
Expand Down
2 changes: 1 addition & 1 deletion tests/02_manpage-regen.test
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ command -v httrack >/dev/null 2>&1 || {
tmp=$(mktemp) || exit 1
committed_clean=$(mktemp) || exit 1
generated_clean=$(mktemp) || exit 1
trap 'rm -f "$tmp" "$committed_clean" "$generated_clean"' EXIT
trap 'set +e; rm -f "$tmp" "$committed_clean" "$generated_clean"' EXIT

README="$top_srcdir/README" bash "$gen" httrack >"$tmp" 2>/dev/null || {
echo "makeman.sh failed" >&2
Expand Down
2 changes: 1 addition & 1 deletion tests/02_update-cache.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set -euo pipefail

site=$(mktemp -d)
out=$(mktemp -d)
trap 'rm -rf "$site" "$out"' EXIT
trap 'set +e; rm -rf "$site" "$out"' EXIT

cat >"$site/index.html" <<EOF
<a href="a.html">a</a> <a href="sub/b.html">b</a>
Expand Down
2 changes: 1 addition & 1 deletion tests/100_local-purge-longpath.test
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test -n "$httrack_bin" || {
httrack_bin=$(cd "$(dirname "$httrack_bin")" && pwd)/$(basename "$httrack_bin")

work=$(mktemp -d)
trap 'kill -9 "${spid:-}" 2>/dev/null || true; rm -rf "$work"' EXIT
trap 'set +e; kill -9 "${spid:-}" 2>/dev/null || true; rm -rf "$work"' EXIT

mkdir -p "$work/root" "$work/proj"

Expand Down
3 changes: 2 additions & 1 deletion tests/102_local-ftp-refetch.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ cleanup() {
stop_server "$serverpid"
rm -rf "$tmpdir"
}
trap cleanup EXIT HUP INT QUIT PIPE TERM
trap 'set +e; cleanup' EXIT
trap cleanup HUP INT QUIT PIPE TERM

root="${tmpdir}/root"
out="${tmpdir}/crawl"
Expand Down
Loading
Loading