From f240c453ead8f9bee4aed66819e0c55ca0eb9f62 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 09:14:38 -1000 Subject: Keep cgit's status where the cache tests pipe it Piping cgit into cat threw away its exit status, so a crash or valgrind's 126 could not fail the no-key and negative ttl tests. Under ulimit -f 0 not even a status file can be written, so that status goes down the pipe with the page. The negative ttl test also leaned on the list an earlier test left, and its last check passed on a missing file. --- tests/t0003-cache.sh | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index a0cff72..acc9496 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -448,16 +448,17 @@ test_expect_success SANITY 'a refresh that cannot lock serves the expired slot a # A lock file that cannot take the key goes with its lock, rather than # staying behind locked while the page renders uncached. The limit is on -# files, so the log goes through the pipe as well. +# files, so the log and cgit's exit status go through the pipe as well. test_expect_success 'a slot lock that cannot take its key is let go' ' rm -rf cache3 && mkdir cache3 && ( trap "" XFSZ && ulimit -f 0 && - cgit_rc bigkeyrc "url=bigpage/" 2>&1 + { cgit_rc bigkeyrc "url=bigpage/" 2>&1; echo "exit status $?"; } ) | cat >nokey.out && - grep "" nokey.out && - grep "Unable to write .*\.lock" nokey.out && + test_grep "^exit status 0$" nokey.out && + test_grep "" nokey.out && + test_grep "Unable to write .*\.lock" nokey.out && test_dir_is_empty cache3 ' @@ -642,22 +643,32 @@ test_expect_success 'every setting the scan depends on keeps its own list' ' # A negative ttl never expires, so a list however old is served and kept. A # rebuild runs in a child holding the request's copy of fd 9, so cat reaching # the end of that pipe means any rebuild is done, as the positive ttl after -# it shows. +# it shows. The ttl is not part of the list's name, so both configs share +# the list, which is scanned afresh here. test_expect_success 'a negative cache-scan-ttl never expires the list' ' { echo "cache-scan-ttl=-1" && cat scanrc } >foreverrc && + rm -f "cache5/$scanned_rc" && + cgit_ok scanrc "url=" >/dev/null && + test_path_is_file "cache5/$scanned_rc" && { echo "repo.url=kept" && echo "repo.path=$PWD/scanned/one/.git" } >>"cache5/$scanned_rc" && touch -t 200001010000 "cache5/$scanned_rc" && - cgit_rc foreverrc "url=" 9>&1 >forever.out | cat && - grep ">kept" forever.out && - grep "^repo.url=kept$" "cache5/$scanned_rc" && - cgit_rc scanrc "url=" 9>&1 >/dev/null | cat && - ! grep "^repo.url=kept$" "cache5/$scanned_rc" + { cgit_rc foreverrc "url=" 9>&1 >forever.out 2>forever.err; echo $? >forever.status; } | cat && + test "$(cat forever.status)" = 0 && + test_must_be_empty forever.err && + test_grep ">kept" forever.out && + test_grep "^repo.url=kept$" "cache5/$scanned_rc" && + { cgit_rc scanrc "url=" 9>&1 >rescan.out 2>rescan.err; echo $? >rescan.status; } | cat && + test "$(cat rescan.status)" = 0 && + test_must_be_empty rescan.err && + test_grep ">kept" rescan.out && + test_grep "^repo.url=one$" "cache5/$scanned_rc" && + test_grep ! "^repo.url=kept$" "cache5/$scanned_rc" ' # A repository the scan found without a description goes into the list -- cgit 2.12.1