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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Feb 21, 2022 at 20:38 UTC
bf7eed75b90756c960da4828476b669a358df05b
1 file changed
+45
t/t0012-help.sh
+45
@@ -138,6 +138,51 @@ test_expect_success 'git help --config-sections-for-completion' '
138
test_cmp human.munged sections
139
'
140
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
+
186
test_expect_success 'generate builtin list' '
187
mkdir -p sub &&
188
git --list-cmds=builtins >builtins