Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Report a cgitrc or include that cannot be read
A missing or unreadable cgitrc left only "No repositories found" and an
empty log, the commonest first mistake with no trace of its cause. A
scanned repository's own cgitrc stays quiet, since most have none.
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/t0205-config.sh | 37 |
1 file changed, 37 insertions, 0 deletions
diff --git a/tests/t0205-config.sh b/tests/t0205-config.sh index 32c260e..12087e7 100755 --- a/tests/t0205-config.sh +++ b/tests/t0205-config.sh @@ -106,4 +106,41 @@ test_expect_success 'a NUL inside a comment does not end it' ' ! grep Smuggled tmp ' +# cgitrc and the files it includes are meant to be there, so one that cannot +# be read is logged rather than left to show an empty index. +test_expect_success 'a config file that cannot be read is reported' ' + CGIT_CONFIG="$PWD/no-such-rc" QUERY_STRING="url=" cgit >tmp 2>err && + grep "No repositories found" tmp && + grep "Unable to read config file $PWD/no-such-rc: No such file or directory" err && + mkdir rc-dir && + CGIT_CONFIG="$PWD/rc-dir" QUERY_STRING="url=" cgit >tmp 2>err && + grep "Unable to read config file $PWD/rc-dir: Is a directory" err && + { + echo "include=$PWD/no-such-include" && + cat diagrc + } >includerc && + cgit_rc includerc "url=diag/" >tmp 2>err && + grep "Status: 200" tmp && + grep "Unable to read config file $PWD/no-such-include: No such file or directory" err +' + +# A scanned repository's own cgitrc is optional, so a scan says nothing when +# one is missing, and neither does reading the scan back from the cache. +test_expect_success 'a scan says nothing of the files it may lack' ' + git clone -q --bare repos/foo/.git quiet/foo.git && + mkdir quiet-cache && + { + echo "virtual-root=/" && + echo "cache-root=$PWD/quiet-cache" && + echo "cache-size=64" && + echo "cache-index-ttl=0" && + echo "scan-path=$PWD/quiet" + } >quietrc && + cgit_rc quietrc "url=" >tmp 2>err && + grep ">foo.git</a>" tmp && + cgit_rc quietrc "url=" >tmp 2>>err && + grep ">foo.git</a>" tmp && + test_must_be_empty err +' + test_done |
