From 9f6f9badd1b23b0d92d4d9c3837af2c6207546d4 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 09:27:01 -1000 Subject: Test a scan whose list cannot be written After the write fails the scan runs a second time, and that run adds nothing only because scan-tree.c never resets the directories it has visited. Nothing showed it, so a reset would have listed every repository twice and passed. --- tests/t0003-cache.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh index c7e8369..365e257 100755 --- a/tests/t0003-cache.sh +++ b/tests/t0003-cache.sh @@ -564,6 +564,25 @@ test_expect_success 'set up a cached scan of two repositories' ' test_path_is_file "cache5/$scanned_rc" ' +# A list that cannot be written leaves the request with the scan it made +# before the write failed, so each repository is listed once and nothing is +# left in the cache-root. The limit is on files, so the log and the exit +# status go through the pipe with the page. +test_expect_success 'a scan whose list cannot be written lists each repository once' ' + rm -rf cache9 && mkdir cache9 && + sed "s|^cache-root=.*|cache-root=$PWD/cache9|" scanrc >unwritablerc && + ( + trap "" XFSZ && + ulimit -f 0 && + { cgit_rc unwritablerc "url=" 2>&1; echo "exit status $?"; } + ) | cat >unwritable.out && + test_grep "^exit status 0$" unwritable.out && + test_grep "Unable to write .*/cache9/rc-[0-9a-f]*\.lock" unwritable.out && + test $(grep -c ">one" unwritable.out) = 1 && + test $(grep -c ">two" unwritable.out) = 1 && + test_dir_is_empty cache9 +' + # A request that finds the scan's lock held and has no list to go on scans # in its own process, leaving the file to the holder. That is only another # request at work and no cause for a line in the log. -- cgit 2.12.1