1#!/bin/sh
23
test_description='help'
45
. ./test-lib.sh
67
configure_help () {
8test_config help.format html &&
910
# Unless the path has "://" in it, Git tries to make sure
11# the documentation directory locally exists. Avoid it as
12# we are only interested in seeing an attempt to correctly
13# invoke a help browser in this test.
14test_config help.htmlpath test://html &&
1516
# Name a custom browser
17test_config browser.test.cmd ./test-browser &&
18test_config help.browser test
19}
2021
test_expect_success "setup" '
22# Just write out which page gets requested
23write_script test-browser <<-\EOF
24echo "$*" >test-browser.log
25EOF
26'
2728
test_expect_success "works for commands and guides by default" '
29configure_help &&
30git help status &&
31echo "test://html/git-status.html" >expect &&
32test_cmp expect test-browser.log &&
33git help revisions &&
34echo "test://html/gitrevisions.html" >expect &&
35test_cmp expect test-browser.log
36'
3738
test_expect_success "--exclude-guides does not work for guides" '
39>test-browser.log &&
40test_must_fail git help --exclude-guides revisions &&
41test_must_be_empty test-browser.log
42'
4344
test_expect_success "--help does not work for guides" "
45cat <<-EOF >expect &&
46git: 'revisions' is not a git command. See 'git --help'.
47EOF
48test_must_fail git revisions --help 2>actual &&
49test_i18ncmp expect actual
50"
5152
test_expect_success 'git help' '
53git help >help.output &&
54test_i18ngrep "^ clone " help.output &&
55test_i18ngrep "^ add " help.output &&
56test_i18ngrep "^ log " help.output &&
57test_i18ngrep "^ commit " help.output &&
58test_i18ngrep "^ fetch " help.output
59'
6061
test_expect_success 'generate builtin list' '
62git --list-builtins >builtins
63'
6465
while read builtin
66do
67test_expect_success "$builtin can handle -h" '
68test_expect_code 129 git $builtin -h >output 2>&1 &&
69test_i18ngrep usage output
70'
71done <builtins
7273
test_done