From b0443a2caa7ae478e54f4a8abb0579c57ea109d2 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 6 Sep 2026 18:03:41 -1000 Subject: Add a consistency test for the config documents --- tests/t0004-docs.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 tests/t0004-docs.sh (limited to 'tests') diff --git a/tests/t0004-docs.sh b/tests/t0004-docs.sh new file mode 100755 index 0000000..ef12493 --- /dev/null +++ b/tests/t0004-docs.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +# Checks that the configuration documents stay consistent with each other. +# The manual documents every key the reference config sets, the reference +# config sets every key the manual documents, and both settings sections of +# the manual keep their entries sorted so a reader can find a key by +# scanning. An audit found the two files drifting apart, so this pins them +# together. + +test_description='Check the configuration documents' +. ./setup.sh + +ROOT="$TEST_OUTPUT_DIRECTORY/.." + +test_expect_success 'extract the key lists' ' + sed -n "/^Global settings$/,/^Repository-specific cgitrc file$/p" \ + "$ROOT/MANUAL.txt" | + sed -n "s/^\([a-z][a-zA-Z0-9.<>-]*\)::$/\1/p" | + sort >manual-keys && + sed -n "s/^#\{0,1\}\([a-z][a-zA-Z0-9.<>-]*\)=.*/\1/p" \ + "$ROOT/custom/cgitrc" | + sed -e "s/^mimetype\..*/mimetype./" | + sort -u >example-keys && + sed -n "s/^#\{0,1\}\(repo\.module-link\)\..*=.*/\1./p" \ + "$ROOT/custom/cgitrc" >>example-keys && + sort -o example-keys example-keys && + test -s manual-keys && test -s example-keys +' + +test_expect_success 'the reference config sets every documented key' ' + comm -23 manual-keys example-keys >missing && + test_must_be_empty missing +' + +test_expect_success 'every key the reference config sets is documented' ' + comm -13 manual-keys example-keys >undocumented && + test_must_be_empty undocumented +' + +test_expect_success 'the manual lists its global settings in order' ' + sed -n "/^Global settings$/,/^Repository settings$/p" \ + "$ROOT/MANUAL.txt" | + sed -n "s/^\([a-z][a-zA-Z0-9.<>-]*\)::$/\1/p" >global-order && + LC_ALL=C sort -c global-order +' + +test_expect_success 'the manual lists its repository settings in order' ' + sed -n "/^Repository settings$/,/^Repository-specific cgitrc file$/p" \ + "$ROOT/MANUAL.txt" | + sed -n "s/^\(repo\.[a-zA-Z0-9.<>-]*\)::$/\1/p" >repo-order && + LC_ALL=C sort -c repo-order +' + +test_done -- cgit v2.8.0