summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-05-30 05:19:30 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-05 02:43:33 (GMT)
commitd691551192ac845747694258ccae9ffeeb6bdd58 (patch)
treeb5f794dac42c070dfb1c8e83b37e39ddd118a08a /t
parent8893fd95b66cbd6566136a289dd05fcf4e547281 (diff)
downloadgit-d691551192ac845747694258ccae9ffeeb6bdd58.zip
git-d691551192ac845747694258ccae9ffeeb6bdd58.tar.gz
git-d691551192ac845747694258ccae9ffeeb6bdd58.tar.bz2
t0012: test "-h" with builtins
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>
Diffstat (limited to 't')
-rwxr-xr-xt/t0012-help.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/t/t0012-help.sh b/t/t0012-help.sh
index 8faba2e..487b92a 100755
--- a/t/t0012-help.sh
+++ b/t/t0012-help.sh
@@ -49,4 +49,16 @@ test_expect_success "--help does not work for guides" "
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