Skip to content

Commit be72b49

Browse files
Unique-Usmangitster
authored andcommitted
t/t1517: automate git subcmd -h tests outside a repository
Replace manual `-h` tests with a loop over all subcommands using `git --list-cmds=main`. This ensures consistent coverage of `-h` behavior outside a repo and future-proofs the test by covering new commands automatically. Known exceptions are skipped or marked as expected failures. Suggested-by: Patrick Steinhardt <[email protected]> Helped-by: Junio C Hamano <[email protected]> Helped-by: D. Ben Knoble <[email protected]> Signed-off-by: Usman Akinyemi <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 866e6a3 commit be72b49

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

t/t1517-outside-repo.sh

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ test_expect_success LIBCURL 'remote-http outside repository' '
109109

110110
test_expect_success 'update-server-info does not crash with -h' '
111111
test_expect_code 129 git update-server-info -h >usage &&
112-
test_grep "[Uu]sage: git update-server-info " usage &&
113-
test_expect_code 129 nongit git update-server-info -h >usage &&
114112
test_grep "[Uu]sage: git update-server-info " usage
115113
'
116114

@@ -120,5 +118,26 @@ test_expect_success 'prune does not crash with -h' '
120118
test_expect_code 129 nongit git prune -h >usage &&
121119
test_grep "[Uu]sage: git prune " usage
122120
'
121+
for cmd in $(git --list-cmds=main)
122+
do
123+
cmd=${cmd%.*} # strip .sh, .perl, etc.
124+
case "$cmd" in
125+
archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
126+
difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
127+
http-backend | http-fetch | http-push | init-db | \
128+
merge-octopus | merge-one-file | merge-resolve | mergetool | \
129+
mktag | p4 | p4.py | pickaxe | remote-ftp | remote-ftps | \
130+
remote-http | remote-https | replay | send-email | \
131+
sh-i18n--envsubst | shell | show | stage | submodule | svn | \
132+
upload-archive--writer | upload-pack | web--browse | whatchanged)
133+
expect_outcome=expect_failure ;;
134+
*)
135+
expect_outcome=expect_success ;;
136+
esac
137+
test_$expect_outcome "'git $cmd -h' outside a repository" '
138+
test_expect_code 129 nongit git $cmd -h >usage &&
139+
test_grep "[Uu]sage: git $cmd " usage
140+
'
141+
done
123142

124143
test_done

0 commit comments

Comments
 (0)