Skip to content

Commit e5e6667

Browse files
avargitster
authored andcommitted
tests: assert *.txt SYNOPSIS and -h output
Add a test to assert basic compliance with the CodingGuidelines in the SYNOPSIS and builtin -h output. For now we only assert that the "-h" output doesn't have "\t" characters, as a very basic syntax check. Subsequent commits will expand on the checks here as various issues are fixed, but let's first add the test scaffolding. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 79f2338 commit e5e6667

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

t/t0450-txt-doc-vs-help.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh
2+
3+
test_description='assert (unbuilt) Documentation/*.txt and -h output'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
6+
. ./test-lib.sh
7+
8+
test_expect_success 'setup: list of builtins' '
9+
git --list-cmds=builtins >builtins
10+
'
11+
12+
help_to_synopsis () {
13+
builtin="$1" &&
14+
out_dir="out/$builtin" &&
15+
out="$out_dir/help.synopsis" &&
16+
if test -f "$out"
17+
then
18+
echo "$out" &&
19+
return 0
20+
fi &&
21+
mkdir -p "$out_dir" &&
22+
test_expect_code 129 git $builtin -h >"$out.raw" 2>&1 &&
23+
sed -n \
24+
-e '1,/^$/ {
25+
/^$/d;
26+
s/^usage: //;
27+
s/^ *or: //;
28+
p;
29+
}' <"$out.raw" >"$out" &&
30+
echo "$out"
31+
}
32+
33+
HT=" "
34+
35+
while read builtin
36+
do
37+
# -h output assertions
38+
test_expect_success "$builtin -h output has no \t" '
39+
h2s="$(help_to_synopsis "$builtin")" &&
40+
! grep "$HT" "$h2s"
41+
'
42+
done <builtins
43+
44+
test_done

0 commit comments

Comments
 (0)