mirror of
https://github.com/git/git.git
synced 2024-11-05 00:37:55 +01:00
d691551192
Since commit 99caeed05
(Let 'git <command> -h' show usage
without a git dir, 2009-11-09), the git wrapper handles "-h"
specially, skipping any repository setup but still calling
the builtin's cmd_foo() function. This means that every
cmd_foo() must be ready to handle this case, but we don't
have any systematic tests. This led to "git am -h" being
broken for some time without anybody noticing.
This patch just tests that "git foo -h" works for every
builtin, where we see a 129 exit code (the normal code for
our usage() helper), and that the word "usage" appears in
the output.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
64 lines
1.5 KiB
Bash
Executable file
64 lines
1.5 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='help'
|
|
|
|
. ./test-lib.sh
|
|
|
|
configure_help () {
|
|
test_config help.format html &&
|
|
|
|
# Unless the path has "://" in it, Git tries to make sure
|
|
# the documentation directory locally exists. Avoid it as
|
|
# we are only interested in seeing an attempt to correctly
|
|
# invoke a help browser in this test.
|
|
test_config help.htmlpath test://html &&
|
|
|
|
# Name a custom browser
|
|
test_config browser.test.cmd ./test-browser &&
|
|
test_config help.browser test
|
|
}
|
|
|
|
test_expect_success "setup" '
|
|
# Just write out which page gets requested
|
|
write_script test-browser <<-\EOF
|
|
echo "$*" >test-browser.log
|
|
EOF
|
|
'
|
|
|
|
test_expect_success "works for commands and guides by default" '
|
|
configure_help &&
|
|
git help status &&
|
|
echo "test://html/git-status.html" >expect &&
|
|
test_cmp expect test-browser.log &&
|
|
git help revisions &&
|
|
echo "test://html/gitrevisions.html" >expect &&
|
|
test_cmp expect test-browser.log
|
|
'
|
|
|
|
test_expect_success "--exclude-guides does not work for guides" '
|
|
>test-browser.log &&
|
|
test_must_fail git help --exclude-guides revisions &&
|
|
test_must_be_empty test-browser.log
|
|
'
|
|
|
|
test_expect_success "--help does not work for guides" "
|
|
cat <<-EOF >expect &&
|
|
git: 'revisions' is not a git command. See 'git --help'.
|
|
EOF
|
|
test_must_fail git revisions --help 2>actual &&
|
|
test_i18ncmp expect actual
|
|
"
|
|
|
|
test_expect_success 'generate builtin list' '
|
|
git --list-builtins >builtins
|
|
'
|
|
|
|
while read builtin
|
|
do
|
|
test_expect_success "$builtin can handle -h" '
|
|
test_expect_code 129 git $builtin -h >output 2>&1 &&
|
|
test_i18ngrep usage output
|
|
'
|
|
done <builtins
|
|
|
|
test_done
|