Skip to content

Commit bf7eed7

Browse files
avargitster
authored andcommitted
help tests: test "git" and "git help [-a|-g] spacing
There's logic in "help.c"'s "print_cmd_by_category()" to emit "help" output with particular spacing, which doesn't make much sense when emitting only one section with "help -g". Let's add tests for the current spacing in preparation for a subsequent whitespace formatting fix, and make sure that that fix doesn't cause regressions for the "git" and "git help" output. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cd87ce7 commit bf7eed7

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

t/t0012-help.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,51 @@ test_expect_success 'git help --config-sections-for-completion' '
138138
test_cmp human.munged sections
139139
'
140140

141+
test_section_spacing () {
142+
cat >expect &&
143+
"$@" >out &&
144+
grep -E "(^[^ ]|^$)" out >actual
145+
}
146+
147+
test_section_spacing_trailer () {
148+
test_section_spacing "$@" &&
149+
test_expect_code 1 git >out &&
150+
sed -n '/list available subcommands/,$p' <out >>expect
151+
}
152+
153+
154+
for cmd in git "git help"
155+
do
156+
test_expect_success "'$cmd' section spacing" '
157+
test_section_spacing_trailer git help <<-\EOF &&
158+
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
159+
160+
These are common Git commands used in various situations:
161+
162+
start a working area (see also: git help tutorial)
163+
164+
work on the current change (see also: git help everyday)
165+
166+
examine the history and state (see also: git help revisions)
167+
168+
grow, mark and tweak your common history
169+
170+
collaborate (see also: git help workflows)
171+
172+
EOF
173+
test_cmp expect actual
174+
'
175+
done
176+
177+
test_expect_success "'git help -g' section spacing" '
178+
test_section_spacing_trailer git help -g <<-\EOF &&
179+
180+
The Git concept guides are:
181+
182+
EOF
183+
test_cmp expect actual
184+
'
185+
141186
test_expect_success 'generate builtin list' '
142187
mkdir -p sub &&
143188
git --list-cmds=builtins >builtins

0 commit comments

Comments
 (0)