Diff options
-rwxr-xr-xtests/t0003-cache.sh24
1 file changed, 8 insertions, 16 deletions
diff --git a/tests/t0003-cache.sh b/tests/t0003-cache.sh
index 06cdd99..5cf0250 100755
--- a/tests/t0003-cache.sh
+++ b/tests/t0003-cache.sh
@@ -31,8 +31,7 @@ test_expect_success 'verify cache-size=0' '
rm -f cache/* &&
set_cache_size 0 &&
request_all_pages &&
- ls cache >output &&
- test_line_count = 0 output
+ test_dir_is_empty cache
'
test_expect_success 'verify cache-size=1' '
@@ -128,8 +127,7 @@ test_expect_success 'an over-long cache key leaves no slot behind' '
long=$(awk "BEGIN{s=\"\";for(i=0;i<6000;i++)s=s \"k\"; print s}") &&
CGIT_CONFIG="$PWD/bigkeyrc" QUERY_STRING="url=bigpage/&q=$long" cgit >key.out 2>key.err &&
grep "</html>" key.out &&
- ls cache3 >key.slots &&
- test_line_count = 0 key.slots
+ test_dir_is_empty cache3
'
test_expect_success 'an ordinary key still fills a slot' '
@@ -163,8 +161,7 @@ test_expect_success 'an error after output began ends the page with it and cache
CGIT_CONFIG="$PWD/brokenrc" QUERY_STRING="url=broken/commit/&id=$tip" cgit >broken.out &&
grep "Not a commit" broken.out &&
test $(grep -c "^Status:" broken.out) = 1 &&
- ls cache4 >broken.slots &&
- test_line_count = 0 broken.slots
+ test_dir_is_empty cache4
'
# An error page reports a condition the repository may grow out of, and a
@@ -176,8 +173,7 @@ test_expect_success 'an error page leaves no slot behind' '
CGIT_CONFIG="$PWD/bigkeyrc" \
QUERY_STRING="url=bigpage/commit/&id=0123456789abcdef0123456789abcdef01234567" cgit >error.out &&
grep "Not a commit" error.out &&
- ls cache3 >error.slots &&
- test_line_count = 0 error.slots
+ test_dir_is_empty cache3
'
# The dumb transport serves files that already sit on the disk, so a copy in
@@ -188,8 +184,7 @@ test_expect_success 'a clone file leaves no slot behind' '
grep "refs/heads/master" clone.out &&
CGIT_CONFIG="$PWD/bigkeyrc" QUERY_STRING="url=bigpage/objects/info/packs" cgit >packs.out &&
grep "^Status: 200" packs.out &&
- ls cache3 >clone.slots &&
- test_line_count = 0 clone.slots
+ test_dir_is_empty cache3
'
# A response past cache-max-slot-size is served whole but kept nowhere, both
@@ -204,8 +199,7 @@ test_expect_success 'a response over cache-max-slot-size is served but not kept'
} >slotsizerc &&
CGIT_CONFIG="$PWD/slotsizerc" QUERY_STRING="url=bigpage/tree/big.txt" cgit >big.unkept &&
tail -c 200 big.unkept | grep "</html>" &&
- ls cache3 >unkept.slots &&
- test_line_count = 0 unkept.slots &&
+ test_dir_is_empty cache3 &&
CGIT_CONFIG="$PWD/slotsizerc" QUERY_STRING="url=bigpage/" cgit >/dev/null &&
ls cache3 >kept.slots &&
test_line_count = 1 kept.slots
@@ -219,8 +213,7 @@ test_expect_success 'an expired slot is dropped when its refill is too large' '
touch -t 200001010000 cache3/* &&
CGIT_CONFIG="$PWD/slotsizerc" QUERY_STRING="url=bigpage/tree/big.txt" cgit >big.refill &&
tail -c 200 big.refill | grep "</html>" &&
- ls cache3 >refill.slots &&
- test_line_count = 0 refill.slots
+ test_dir_is_empty cache3
'
# The summary page keeps a ttl of its own, while every other page that follows
@@ -234,8 +227,7 @@ test_expect_success 'pages following a branch take the dynamic ttl' '
} >dynamicrc &&
CGIT_CONFIG="$PWD/dynamicrc" QUERY_STRING="url=bigpage/log/" cgit >/dev/null &&
CGIT_CONFIG="$PWD/dynamicrc" QUERY_STRING="url=bigpage/log/&h=master" cgit >/dev/null &&
- ls cache3 >dynamic.slots &&
- test_line_count = 0 dynamic.slots &&
+ test_dir_is_empty cache3 &&
CGIT_CONFIG="$PWD/dynamicrc" QUERY_STRING="url=bigpage/" cgit >/dev/null &&
CGIT_CONFIG="$PWD/dynamicrc" QUERY_STRING="url=bigpage/summary/" cgit >/dev/null &&
ls cache3 >summary.slots &&