1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
test_description='Check the configuration documents'
CGIT_TEST_NO_CREATE_REPOS=YesPlease
. ./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.<ext>/" |
sort -u >example-keys &&
sed -n "s/^#\{0,1\}\(repo\.module-link\)\..*=.*/\1.<path>/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 'cgit accepts every key the manual documents' '
{
grep -v "^repo\." manual-keys |
sed -e "s/^mimetype\.<ext>$/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\.<path>$/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
'
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.\<ext\> >>accepted &&
echo repo.module-link.\<path\> >>accepted &&
test_line_count -gt 100 accepted &&
sort -u -o accepted accepted &&
comm -23 accepted manual-keys >undocumented &&
test_must_be_empty undocumented
'
test_expect_success 'the reference config changes nothing as it ships' '
mkrepo repos/sample 1 >/dev/null &&
{
echo "repo.url=sample" &&
echo "repo.path=$PWD/repos/sample/.git"
} >alonerc &&
cat "$ROOT/custom/cgitrc" alonerc >samplerc &&
for url in "" sample/ sample/log/
do
cgit_ok alonerc "url=$url" >alone.out &&
cgit_ok samplerc "url=$url" >sample.out &&
strip_headers <alone.out >expect &&
strip_headers <sample.out >actual &&
test_grep "data-page=" actual &&
test_cmp expect actual || return 1
done
'
test_expect_success 'the reference config scans after every global setting' '
sed -n "/^#\{0,1\}scan-path=/,\$p" "$ROOT/custom/cgitrc" |
sed -n "s/^#\{0,1\}\([a-z][a-zA-Z0-9.<>-]*\)=.*/\1/p" |
grep -v "^repo\." >after-scan-path &&
echo scan-path >expect &&
test_cmp expect after-scan-path
'
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 &&
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 &&
sort -c repo-order
'
test_done
|