#!/bin/sh # Checks what the configuration parser reports on stderr. A key it does not # know, a repo key before any repository and a filter override without its # enabling flag are each ignored with a warning naming the key, and a config # cgit fully understands stays silent. test_description='Check configuration diagnostics' . ./setup.sh test_expect_success 'set up configs' ' { echo "virtual-root=/" && echo "cache-size=0" && echo "no-such-key=1" && echo "repo.url=diag" && echo "repo.path=$PWD/repos/foo/.git" && echo "repo.no-such-repo-key=1" } >diagrc && { echo "virtual-root=/" && echo "cache-size=0" && echo "repo.desc=early" && echo "repo.url=diag" && echo "repo.path=$PWD/repos/foo/.git" && echo "repo.about-filter=exec:/bin/true" } >earlyrc ' test_expect_success 'unknown keys are reported and the page still renders' ' CGIT_CONFIG="$PWD/diagrc" QUERY_STRING="url=diag/" cgit >tmp 2>err && grep "Status: 200" tmp && grep "Unknown config key: no-such-key" err && grep "Unknown repo config key: no-such-repo-key" err ' test_expect_success 'a repo key before any repo.url is reported' ' CGIT_CONFIG="$PWD/earlyrc" QUERY_STRING="url=diag/" cgit >tmp 2>err && grep "Status: 200" tmp && grep "Ignoring repo.desc before any repo.url" err ' test_expect_success 'a filter override without its flag is reported' ' grep "Ignoring repo about-filter: enable-filter-overrides is not set" err ' test_expect_success 'a fully understood config stays silent' ' cgit_url "foo/" >tmp 2>err && grep "Status: 200" tmp && ! grep "\[cgit\]" err ' test_done