Ralf Thielow | af74128 | 2016-08-26 19:58:35 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='help' |
| 4 | |
| 5 | . ./test-lib.sh |
| 6 | |
| 7 | configure_help () { |
| 8 | test_config help.format html && |
| 9 | |
| 10 | # 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. |
| 14 | test_config help.htmlpath test://html && |
| 15 | |
| 16 | # Name a custom browser |
| 17 | test_config browser.test.cmd ./test-browser && |
| 18 | test_config help.browser test |
| 19 | } |
| 20 | |
| 21 | test_expect_success "setup" ' |
| 22 | # Just write out which page gets requested |
| 23 | write_script test-browser <<-\EOF |
| 24 | echo "$*" >test-browser.log |
| 25 | EOF |
| 26 | ' |
| 27 | |
Nguyễn Thái Ngọc Duy | 63eae83 | 2018-05-20 20:40:01 +0200 | [diff] [blame] | 28 | # make sure to exercise these code paths, the output is a bit tricky |
| 29 | # to verify |
| 30 | test_expect_success 'basic help commands' ' |
| 31 | git help >/dev/null && |
Nguyễn Thái Ngọc Duy | 26c7d06 | 2018-09-29 08:08:14 +0200 | [diff] [blame] | 32 | git help -a --no-verbose >/dev/null && |
Nguyễn Thái Ngọc Duy | 63eae83 | 2018-05-20 20:40:01 +0200 | [diff] [blame] | 33 | git help -g >/dev/null && |
Nguyễn Thái Ngọc Duy | 26c7d06 | 2018-09-29 08:08:14 +0200 | [diff] [blame] | 34 | git help -a >/dev/null |
Nguyễn Thái Ngọc Duy | 63eae83 | 2018-05-20 20:40:01 +0200 | [diff] [blame] | 35 | ' |
| 36 | |
Ralf Thielow | af74128 | 2016-08-26 19:58:35 +0200 | [diff] [blame] | 37 | test_expect_success "works for commands and guides by default" ' |
| 38 | configure_help && |
| 39 | git help status && |
| 40 | echo "test://html/git-status.html" >expect && |
| 41 | test_cmp expect test-browser.log && |
| 42 | git help revisions && |
| 43 | echo "test://html/gitrevisions.html" >expect && |
| 44 | test_cmp expect test-browser.log |
| 45 | ' |
| 46 | |
| 47 | test_expect_success "--exclude-guides does not work for guides" ' |
| 48 | >test-browser.log && |
| 49 | test_must_fail git help --exclude-guides revisions && |
| 50 | test_must_be_empty test-browser.log |
| 51 | ' |
| 52 | |
Ralf Thielow | 2c6b6d9 | 2016-08-26 19:58:36 +0200 | [diff] [blame] | 53 | test_expect_success "--help does not work for guides" " |
| 54 | cat <<-EOF >expect && |
| 55 | git: 'revisions' is not a git command. See 'git --help'. |
| 56 | EOF |
| 57 | test_must_fail git revisions --help 2>actual && |
| 58 | test_i18ncmp expect actual |
| 59 | " |
| 60 | |
Nguyễn Thái Ngọc Duy | cfb22a0 | 2018-05-10 10:46:42 +0200 | [diff] [blame] | 61 | test_expect_success 'git help' ' |
| 62 | git help >help.output && |
| 63 | test_i18ngrep "^ clone " help.output && |
| 64 | test_i18ngrep "^ add " help.output && |
| 65 | test_i18ngrep "^ log " help.output && |
| 66 | test_i18ngrep "^ commit " help.output && |
| 67 | test_i18ngrep "^ fetch " help.output |
| 68 | ' |
Nguyễn Thái Ngọc Duy | 1b81d8c | 2018-05-20 20:40:02 +0200 | [diff] [blame] | 69 | test_expect_success 'git help -g' ' |
| 70 | git help -g >help.output && |
| 71 | test_i18ngrep "^ attributes " help.output && |
| 72 | test_i18ngrep "^ everyday " help.output && |
| 73 | test_i18ngrep "^ tutorial " help.output |
| 74 | ' |
Nguyễn Thái Ngọc Duy | cfb22a0 | 2018-05-10 10:46:42 +0200 | [diff] [blame] | 75 | |
Jeff King | d691551 | 2017-05-30 01:19:30 -0400 | [diff] [blame] | 76 | test_expect_success 'generate builtin list' ' |
Nguyễn Thái Ngọc Duy | 0089521 | 2018-05-20 20:39:57 +0200 | [diff] [blame] | 77 | git --list-cmds=builtins >builtins |
Jeff King | d691551 | 2017-05-30 01:19:30 -0400 | [diff] [blame] | 78 | ' |
| 79 | |
| 80 | while read builtin |
| 81 | do |
| 82 | test_expect_success "$builtin can handle -h" ' |
| 83 | test_expect_code 129 git $builtin -h >output 2>&1 && |
| 84 | test_i18ngrep usage output |
| 85 | ' |
| 86 | done <builtins |
| 87 | |
Ralf Thielow | af74128 | 2016-08-26 19:58:35 +0200 | [diff] [blame] | 88 | test_done |