From 5ce1b1b3e7b81f9eb2c3277e2939636711dce4cf Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 17:15:40 -1000 Subject: Check the manual against the keys cgit accepts --- tests/t0004-docs.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/t0004-docs.sh b/tests/t0004-docs.sh index 1df71bc..2c0b614 100755 --- a/tests/t0004-docs.sh +++ b/tests/t0004-docs.sh @@ -34,6 +34,41 @@ test_expect_success 'every key the reference config sets is documented' ' test_must_be_empty undocumented ' +# Each documented key is given an empty value, the global ones ahead of the +# repository and the repo.* ones after it, along with one key of each kind +# that cgit does not know, which shows the warning would be seen. +test_expect_success 'cgit accepts every key the manual documents' ' + { + grep -v "^repo\." manual-keys | + sed -e "s/^mimetype\.$/mimetype.txt/" -e "s/$/=/" && + echo "no-such-key=" && + echo "repo.url=docs" && + grep "^repo\." manual-keys | grep -v "^repo\.url$" | + sed -e "s/^repo\.module-link\.$/repo.module-link.sub/" -e "s/$/=/" && + echo "repo.no-such-key=" + } >keysrc && + cgit_rc keysrc "url=" >keys.out 2>keys.err && + grep "Unknown" keys.err >unknown && + test_write_lines "[cgit] Unknown config key: no-such-key" \ + "[cgit] Unknown repo config key: no-such-key" >expect && + test_cmp expect unknown +' + +# The names are read off the comparisons apply_config and cgit_repo_config +# make, the latter written without the repo. prefix. +test_expect_success 'the manual documents every key cgit accepts' ' + sed -n "/^static void apply_config(/,/^}/p" "$ROOT/source/cgit.c" | + sed -n "s/.*strcmp(name, \"\([^\"]*\)\").*/\1/p" >accepted && + sed -n "/^void cgit_repo_config(/,/^}/p" "$ROOT/source/cgit.c" | + sed -n "s/.*strcmp(name, \"\([^\"]*\)\").*/repo.\1/p" >>accepted && + echo mimetype.\ >>accepted && + echo repo.module-link.\ >>accepted && + test_line_count -gt 100 accepted && + sort -u -o accepted accepted && + comm -23 accepted manual-keys >undocumented && + test_must_be_empty undocumented +' + # A scanned repository inherits the global settings above scan-path, so the # sample keeps none below it. test_expect_success 'the reference config scans after every global setting' ' -- cgit 2.12.1