help tests: test --config-for-completion option & output

Add a regression test for the --config-for-completion option, this was tested for indirectly with the test added in 7a09a8f093e (completion: add tests for 'git config' completion, 2019-08-13), but let's do it directly here as well. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Sep 22, 2021 at 00:40 UTC 5a5f04d86b870bfec1c8cfefa8207a4e110fa128
1 file changed +16 -1
t/t0012-help.sh
+16 -1
@@ -41,7 +41,8 @@ test_expect_success 'invalid usage' '
41 test_expect_code 129 git help -g add &&
42 test_expect_code 129 git help -a -g &&
43
44 - test_expect_code 129 git help -g -c
44 + test_expect_code 129 git help -g -c &&
45 + test_expect_code 0 git help --config-for-completion add
46 '
47
48 test_expect_success "works for commands and guides by default" '
@@ -96,6 +97,20 @@ test_expect_success 'git help -c' '
97 test_cmp expect actual
98 '
99
100 +test_expect_success 'git help --config-for-completion' '
101 + git help -c >human &&
102 + grep -E \
103 + -e "^[^.]+\.[^.]+$" \
104 + -e "^[^.]+\.[^.]+\.[^.]+$" human |
105 + sed -e "s/\*.*//" -e "s/<.*//" |
106 + sort -u >human.munged &&
107 +
108 + git help --config-for-completion >vars &&
109 + sort -u <vars >vars.new &&
110 + mv vars.new vars &&
111 + test_cmp human.munged vars
112 +'
113 +
114 test_expect_success 'generate builtin list' '
115 git --list-cmds=builtins >builtins
116 '