git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Usman Akinyemi <usmanakinyemi202@gmail.com>
Cc: git@vger.kernel.org,  chriscool@tuxfamily.org,
	christian.couder@gmail.com,  me@ttaylorr.com,  ps@pks.im
Subject: Re: [PATCH v3 6/7] t/t1517: move verify-commit -h test to t1517
Date: Fri, 11 Jul 2025 09:37:10 -0700	[thread overview]
Message-ID: <xmqqcya63cqx.fsf@gitster.g> (raw)
In-Reply-To: <CAPSxiM_ZZrbFpgvxqYgZ8oeTbRs+HW=rM+9Dud0G_Qr7eq3=FA@mail.gmail.com> (Usman Akinyemi's message of "Fri, 11 Jul 2025 04:29:30 +0530")

Usman Akinyemi <usmanakinyemi202@gmail.com> writes:

>> But in the longer run, we are very much likely that we'd want to
>> test something that needs things that require prerequisites (like
>> "do this only where XYZ is installed") but ought to work outside a
>> repository, which means t1517 would need to pull in things like
>> lib-gpg.sh only because it has a few tests about verify-blah
>> command.  These tend to accumulate over time.
>
> I understand the concern and I felt we should at least decide where to
> put the "verify -h" because, right now, we have some of them in the
> t1517 and also some in their respective test files.

If t1517 were only about "git subcmd -h outside a repository" for
various subcommands, that would be a happy arrangement.  I think we
even have a way to iterate over all Git subcommands, current or
future, so your patch may become "we've sprinkled 'subcmd -h' tests
in various scripts, but now t1517 will do that automatically so
anybody who add a new command do not have to do anything".

But if t1517 currently (before your series) already has other things
tested, that changes the story somewhat.  Especially if we aim for
the automated solution, we may want to move existing tests in 1517
that is not about "subcmd -h" out to different scripts.  Obvious
two choices are:

 - We spread them to existing test scripts for the command being
   tested (e.g. "does patch-id work correctly outside a repo?"
   moves to t4204-patch-id, and "does update-server-info work OK
   inside and outside a repo?" can be split and one half moves to
   t5200-update-server-info).

 - We move them all to a new test script that is dedicated for "do
   various subcommands work outside a repo to do things other than
   responding to '-h'?".

and I would favour the former.

The only reason why you moved these to t1517 is because the set-up
part of that script sets up the ceiling just once properly and let
its tests do as if they are running outsie a repository, and having
to arrange the ceiling correctly to add a few test in various
scripts so that each of these scripts can test their single
subcommand pretending that it is running outside a repository looked
cumbersome, right?  And I do agree with you, if that was the reason,
that it is annoying to have to set up the ceiling manually in each
test script.  But then can we do it less annoying?  We already made
a nongit test helper and it may be good enough to help existing
tests in t1517.

As an illustration, here is what the beginning of the former
approach may look like.


 t/t1517-outside-repo.sh       | 27 +++++++++++++++++++++------
 t/t5200-update-server-info.sh |  5 +++++
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git c/t/t1517-outside-repo.sh w/t/t1517-outside-repo.sh
index 6824581317..c1294d5761 100755
--- c/t/t1517-outside-repo.sh
+++ w/t/t1517-outside-repo.sh
@@ -107,11 +107,26 @@ test_expect_success LIBCURL 'remote-http outside repository' '
 	test_grep "^error: remote-curl" actual
 '
 
-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)
+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 &&
+		test_grep "[Uu]sage: git $cmd " usage
+	'
+done
 
 test_done
diff --git c/t/t5200-update-server-info.sh w/t/t5200-update-server-info.sh
index 8365907055..a551e955b5 100755
--- c/t/t5200-update-server-info.sh
+++ w/t/t5200-update-server-info.sh
@@ -46,4 +46,9 @@ test_expect_success 'midx does not create duplicate pack entries' '
 	test_must_be_empty dups
 '
 
+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_done

  reply	other threads:[~2025-07-11 16:37 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-06 21:41 [PATCH v2 0/7] move builtin help test to t1517 Usman Akinyemi
2025-07-06 21:41 ` [PATCH v2 1/7] t/t1517: move checkout-index -h " Usman Akinyemi
2025-07-06 21:41 ` [PATCH v2 2/7] t/t1517: move for-each-ref " Usman Akinyemi
2025-07-06 21:41 ` [PATCH v2 3/7] t/t1517: move ls-files " Usman Akinyemi
2025-07-06 21:41 ` [PATCH v2 4/7] t/t1517: move pack-refs " Usman Akinyemi
2025-07-06 21:41 ` [PATCH v2 5/7] t/t1517: move send-pack " Usman Akinyemi
2025-07-06 21:41 ` [PATCH v2 6/7] t/t1517: move verify-commit " Usman Akinyemi
2025-07-06 21:41 ` [PATCH v2 7/7] t/t1517: move verify-tag " Usman Akinyemi
2025-07-06 21:50 ` [PATCH v2 0/7] move builtin help " Usman Akinyemi
2025-07-06 21:50   ` [PATCH v3 1/7] t/t1517: move checkout-index -h " Usman Akinyemi
2025-07-06 21:50   ` [PATCH v3 2/7] t/t1517: move for-each-ref " Usman Akinyemi
2025-07-06 21:50   ` [PATCH v3 3/7] t/t1517: move ls-files " Usman Akinyemi
2025-07-06 21:50   ` [PATCH v3 4/7] t/t1517: move pack-refs " Usman Akinyemi
2025-07-06 21:50   ` [PATCH v3 5/7] t/t1517: move send-pack " Usman Akinyemi
2025-07-06 21:50   ` [PATCH v3 6/7] t/t1517: move verify-commit " Usman Akinyemi
2025-07-07 16:12     ` Junio C Hamano
2025-07-10 22:59       ` Usman Akinyemi
2025-07-11 16:37         ` Junio C Hamano [this message]
2025-07-21 11:55           ` [PATCH v4 0/2] refactor t1517 to focus on help output outside a repository Usman Akinyemi
2025-07-21 11:55             ` [PATCH v4 1/2] t/t1517: automate `git subcmd -h` tests " Usman Akinyemi
2025-07-26 14:34               ` D. Ben Knoble
2025-07-26 21:53                 ` Usman Akinyemi
2025-07-30 21:14                   ` D. Ben Knoble
2025-07-28 15:08                 ` Junio C Hamano
2025-08-02 19:56                 ` D. Ben Knoble
2025-08-03  1:27                   ` Usman Akinyemi
2025-07-26 14:37               ` D. Ben Knoble
2025-07-26 14:52                 ` D. Ben Knoble
2025-07-26 21:51                 ` Usman Akinyemi
2025-07-30 21:15                   ` D. Ben Knoble
2025-07-28 15:09                 ` Junio C Hamano
2025-08-26 15:57               ` Phillip Wood
2025-08-28 13:47                 ` D. Ben Knoble
2025-08-29 13:05                   ` Phillip Wood
2025-08-29 13:22                     ` D. Ben Knoble
2025-08-29 16:31                     ` Junio C Hamano
2025-08-30  3:49                       ` Usman Akinyemi
2025-07-21 11:55             ` [PATCH v4 2/2] t5200: move `update-server-info -h` test from t1517 Usman Akinyemi
2025-07-26 16:02               ` D. Ben Knoble
2025-08-03  2:07             ` [PATCH V5 0/3] refactor t1517 to focus on help output outside a repository Usman Akinyemi
2025-08-03  2:07               ` [PATCH V5 1/3] t/t1517: automate `git subcmd -h` tests " Usman Akinyemi
2025-08-03 14:52                 ` D. Ben Knoble
2025-08-03 17:39                   ` Junio C Hamano
2025-08-06  7:20                     ` Usman Akinyemi
2025-08-03  2:07               ` [PATCH V5 2/3] t5200: move `update-server-info -h` test from t1517 Usman Akinyemi
2025-08-03  2:07               ` [PATCH V5 3/3] t5304: move `prune " Usman Akinyemi
2025-08-08  1:06               ` [PATCH v6 0/3] refactor t1517 to focus on help output outside a repository Usman Akinyemi
2025-08-08  1:06                 ` [PATCH v6 1/3] t/t1517: automate `git subcmd -h` tests " Usman Akinyemi
2025-08-08  1:06                 ` [PATCH v6 2/3] t5200: move `update-server-info -h` test from t1517 Usman Akinyemi
2025-08-08  1:06                 ` [PATCH v6 3/3] t5304: move `prune " Usman Akinyemi
2025-08-08 14:53                 ` [PATCH v6 0/3] refactor t1517 to focus on help output outside a repository Junio C Hamano
2025-08-09 14:46                   ` D. Ben Knoble
2025-07-06 21:50   ` [PATCH v3 7/7] t/t1517: move verify-tag -h test to t1517 Usman Akinyemi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqcya63cqx.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=chriscool@tuxfamily.org \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=me@ttaylorr.com \
    --cc=ps@pks.im \
    --cc=usmanakinyemi202@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).