3 test_description
='assert (unbuilt) Documentation/*.txt and -h output
5 Run this with --debug to see a summary of where we still fail to make
6 the two versions consistent with one another.'
8 TEST_PASSES_SANITIZE_LEAK
=true
11 test_expect_success
'setup: list of builtins' '
12 git --list-cmds=builtins >builtins
15 test_expect_success
'list of txt and help mismatches is sorted' '
16 sort -u "$TEST_DIRECTORY"/t0450/txt-help-mismatches >expect &&
17 if ! test_cmp expect "$TEST_DIRECTORY"/t0450/txt-help-mismatches
19 BUG "please keep the list of txt and help mismatches sorted"
25 out_dir
="out/$builtin" &&
26 out
="$out_dir/help.synopsis" &&
32 mkdir
-p "$out_dir" &&
33 test_expect_code
129 git
$builtin -h >"$out.raw" 2>&1 &&
40 }' <"$out.raw" >"$out" &&
45 echo "$GIT_BUILD_DIR/Documentation/git-$1.txt"
50 out_dir
="out/$builtin" &&
51 out
="$out_dir/txt.synopsis" &&
57 b2t
="$(builtin_to_txt "$builtin")" &&
59 -E '/^\[(verse|synopsis)\]$/,/^$/ {
61 /^\[(verse|synopsis)\]$/d;
63 s/'\''(git[ a-z-]*)'\''/\1/g;
71 check_dashed_labels
() {
72 ! grep -E "<[^>_-]+_" "$1"
79 len
=$
(printf "git %s " "$builtin" |
wc -c) &&
80 pad
=$
(printf "%${len}s" "") &&
82 sed "s/^[ $HT][ $HT]*/$pad/"
88 # -h output assertions
89 test_expect_success
"$builtin -h output has no \t" '
90 h2s="$(help_to_synopsis "$builtin")" &&
94 test_expect_success
"$builtin -h output has dashed labels" '
95 check_dashed_labels "$(help_to_synopsis "$builtin")"
98 test_expect_success
"$builtin -h output has consistent spacing" '
99 h2s="$(help_to_synopsis "$builtin")" &&
106 sort -u help >help.ws &&
109 test_line_count = 1 help.ws
113 txt
="$(builtin_to_txt "$builtin")" &&
114 preq
="$(echo BUILTIN_TXT_$builtin | tr '[:lower:]-' '[:upper:]_')" &&
118 test_set_prereq
"$preq"
121 # *.txt output assertions
122 test_expect_success
"$preq" "$builtin *.txt SYNOPSIS has dashed labels" '
123 check_dashed_labels "$(txt_to_synopsis "$builtin")"
126 # *.txt output consistency assertions
128 if grep -q "^$builtin$" "$TEST_DIRECTORY"/t0450
/txt-help-mismatches
134 test_expect_
$result "$preq" "$builtin -h output and SYNOPSIS agree" '
135 t2s="$(txt_to_synopsis "$builtin")" &&
136 if test "$builtin" = "merge-tree"
138 test_when_finished "rm -f t2s.new" &&
139 sed -e '\''s/ (deprecated)$//g'\'' <"$t2s" >t2s.new
142 h2s="$(help_to_synopsis "$builtin")" &&
144 # The *.txt and -h use different spacing for the
145 # alignment of continued usage output, normalize it.
146 align_after_nl "$builtin" <"$t2s" >txt &&
147 align_after_nl "$builtin" <"$h2s" >help &&
151 if test_have_prereq
"$preq" && test -e txt
&& test -e help
154 if test_cmp txt help >cmp 2>/dev/null
156 echo "=== DONE: $builtin ==="
158 echo "=== TODO: $builtin ===" &&
163 # Not in test_expect_success in case --run is being
165 rm -f txt
help tmp
2>/dev
/null
169 test_debug
'say "$(cat failing)"'