diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Name the right file and error in the scan logs
A failed stat logged the directory rather than the entry inside it, and a project list that failed to read printed strerror of the flag ferror returns, which names an unrelated error.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/t0303-robustness.sh28
1 file changed, 28 insertions, 0 deletions
diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh
index 3f9c80d..87a85ce 100755
--- a/tests/t0303-robustness.sh
+++ b/tests/t0303-robustness.sh
@@ -655,4 +655,32 @@ test_expect_success 'a chain of single directories is followed a bounded number
test $(grep -o "class=.ls-dir." tmp | wc -l) -le 17
'
+# The line has to carry the read error rather than the flag ferror returns.
+# Linux opens a directory and fails the read, while macOS already refuses the
+# open, so the same error text is expected from either path.
+test_expect_success 'an unreadable project list is named with its error' '
+ mkdir -p projdir &&
+ {
+ echo "virtual-root=/" &&
+ echo "cache-size=0" &&
+ echo "project-list=$PWD/projdir" &&
+ echo "scan-path=$PWD/repos"
+ } >projrc &&
+ CGIT_CONFIG="$PWD/projrc" QUERY_STRING="url=" cgit >tmp 2>err &&
+ grep "project list .*projdir: Is a directory" err
+'
+
+test_expect_success SANITY 'a scan entry that cannot be searched is named in full' '
+ mkdir -p scanperm/locked &&
+ test_when_finished "chmod 755 scanperm/locked" &&
+ chmod 644 scanperm/locked &&
+ {
+ echo "virtual-root=/" &&
+ echo "cache-size=0" &&
+ echo "scan-path=$PWD/scanperm"
+ } >scanpermrc &&
+ CGIT_CONFIG="$PWD/scanpermrc" QUERY_STRING="url=" cgit >tmp 2>err &&
+ grep "Unable to stat .*scanperm/locked/objects: Permission denied" err
+'
+
test_done