From d387f552fbc3998f7f557c0977ededd1cf7dc2b9 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 15:18:41 -1000 Subject: Check more of the keys the cache hook reads No page asked for with r= was cached, no slot held a head that does not parse as cgit's, and the hook never met a cache root that was missing, so ignoring r=, keeping an unreadable slot, or complaining without a cache all passed. --- tests/t0507-hooks.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/t0507-hooks.sh b/tests/t0507-hooks.sh index 23a7a6d..d4dfb95 100755 --- a/tests/t0507-hooks.sh +++ b/tests/t0507-hooks.sh @@ -58,7 +58,10 @@ test_expect_success 'set up a cache of two repositories and the index' ' done && cgit_rc cachedrc "url=a.git/refs/" >/dev/null && cgit_rc cachedrc "url=b.git/refs/" >/dev/null && + cgit_rc cachedrc "r=a.git&p=log" >/dev/null && + cgit_rc cachedrc "r=b.git&p=log" >/dev/null && echo writer >slots/0123abcd.lock && + printf "not a key\0page" >slots/00000000 && cp -R slots pristine && sort >expect-keys <<-\EOF && 7|http://0|1|/0| @@ -68,6 +71,9 @@ test_expect_success 'set up a cache of two repositories and the index' ' 7|http://0|11|/b.git/log/0| 7|http://0|0|15|url=a.git/refs/ 7|http://0|0|15|url=b.git/refs/ + 7|http://0|0|13|r=a.git&p=log + 7|http://0|0|13|r=b.git&p=log + not a key EOF cached_requests pristine >keys && sort keys >sorted-keys && @@ -146,8 +152,10 @@ do cached_requests slots >left && test_grep "|/b.git/log/" left && test_grep "url=b.git/refs/" left && + test_grep "r=b.git&p=log" left && test_grep ! "a.git" left && test_grep ! "1|/0|" left && + test_grep ! "not a key" left && test_path_is_file slots/0123abcd.lock && ls slots >left-slots && test_grep ! "^rc-" left-slots @@ -191,6 +199,14 @@ do test "$(ls slots)" = 0123abcd.lock ' + test_expect_success "the cache hook does nothing without a cache root under $shell" ' + sed "s|^cache_root=.*|cache_root='\''$PWD/none'\''|" cache-hook >rootless-hook && + grep -Fx "cache_root='\''$PWD/none'\''" rootless-hook && + (cd scan/a.git && $shell ../../rootless-hook 2>../../err) && + test_must_be_empty err && + test_path_is_missing none + ' + test_expect_success SANITY "the cache hook shows a pusher no error under $shell" ' fresh_slots && test_when_finished "chmod 755 slots" && -- cgit 2.12.1