Re: [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests outside a repository

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Usman

On 21/07/2025 12:55, Usman Akinyemi wrote:

diff --git a/t/t1517-outside-repo.sh b/t/t1517-outside-repo.sh
index 6824581317..9fcebb7d94 100755
--- a/t/t1517-outside-repo.sh
+++ b/t/t1517-outside-repo.sh
@@ -110,8 +110,29 @@ test_expect_success LIBCURL 'remote-http outside repository' '
  test_expect_success 'update-server-info does not crash with -h' '
  	test_expect_code 129 git update-server-info -h >usage &&
  	test_grep "[Uu]sage: git update-server-info " usage &&
-	test_expect_code 129 nongit git update-server-info -h >usage &&
-	test_grep "[Uu]sage: git update-server-info " usage
  '
+for cmd in $(git --list-cmds=main)

This lists all the git commands in $PATH which is causing "make test" to fail when I run it locally as it is testing all my local "git-*" scripts most of which apparently fail this test. If there isn't already we should add a option that lists the commands only in $GIT_EXEC_PATH and use it here.

Also when I run the test with '-i' it does not stop at the first failure. I'm not sure what's causing that as I thought test_expect_success should exit on failure even when it is called in a loop.

Thanks

Phillip

+do
+	cmd=${cmd%.*} # strip .sh, .perl, etc.
+	case "$cmd" in
+	archimport | cvsexportcommit | cvsimport | cvsserver | daemon | \
+	difftool--helper | filter-branch | fsck-objects | get-tar-commit-id | \
+	http-backend | http-fetch | http-push | init-db | instaweb.sh | \
+	merge-octopus | merge-one-file | merge-resolve | mergetool | \
+	mktag | p4 | p4.py | pickaxe | quiltimport | remote-ftp | remote-ftps | \
+	remote-http | remote-https | replay | request-pull | send-email | \
+	sh-i18n--envsubst | shell | show | stage | submodule | svn | \
+	upload-archive--writer | upload-pack | web--browse | whatchanged)
+		expect_outcome=expect_failure ;;
+	*)
+		expect_outcome=expect_success ;;
+	esac
+	test_$expect_outcome "'git $cmd -h' outside a repository" '
+		test_expect_code 129 nongit git $cmd -h >usage &&
+		echo "Hello" &&
+		test_grep "[Uu]sage: git $cmd " usage
+	'
+done
+
  test_done





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux