From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: Siddharth Shrimali <r.siddharth.shrimali@gmail.com>,
git@vger.kernel.org, abdobngad@gmail.com, bence@ferdinandy.com,
john.a.passaro@gmail.com
Subject: Re: [PATCH 1/3] t7004: drop hardcoded tag count in invalid name test
Date: Mon, 20 Apr 2026 09:13:49 +0200 [thread overview]
Message-ID: <aeXSLcVl_eGFkagr@pks.im> (raw)
In-Reply-To: <xmqqmrz5bhz4.fsf@gitster.g>
On Tue, Apr 14, 2026 at 09:54:23AM -0700, Junio C Hamano wrote:
> Siddharth Shrimali <r.siddharth.shrimali@gmail.com> writes:
>
> > The test 'trying to create a tag with a non-valid name should fail',
> > checked that exactly one tag existed in the repository before and after
> > attempting to create invalid tags.
> >
> > As pointed out by Junio, this makes the test brittle by relying on a
> > specific global tag count. If future tests are added or removed before
> > this test, the expected state changes and this test would break for
> > completely unrelated reasons.
> >
> > Since we already use 'test_must_fail' to guarantee that the invalid
> > tags are rejected by Git, counting the tags before and after is redundant.
> >
> > Drop the 'test_line_count = 1' checks so the test doesn't rely on the
> > exact number of tags left behind by earlier tests.
>
> The only thing I suggested was that relying on exact state before
> this test makes this test brittle. I do not necessarily think
> "redundant" is bad. Having belt-and-suspenders sometimes help.
>
> Alternatively, if we wanted to catch a bug where "git tag" exits
> with a non-zero status, satisfying test_must_fail, but still creates
> the requested tag, then we could do
>
> git tag -l >tags-before &&
> test_must_fail git tag "" &&
> ... random attempts to create with invalid names ...
> test_must_fail git tag "other~tag" &&
> git tag -l >tags-after &&
> test_cmp tags-before tags-after
>
> instead. And that is a belt-and-suspenders approach.
>
> Having said that, the patch is already an improvement, so let's take
> it as is. Unless there are other things we may want to improve in
> this or other patches in the series, that is.
Hm. We now rely on exit code alone, without verifying that the exit code
actually results in the expected behaviour. I'm a bit torn myself
whether this is sensible and a step into the right direction, and I
would have preferred the `test_cmp` piece above that you propose.
Patrick
next prev parent reply other threads:[~2026-04-20 7:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-14 14:18 [PATCH 0/3] t7004: cleanup and modernize brittle tests Siddharth Shrimali
2026-04-14 14:18 ` [PATCH 1/3] t7004: drop hardcoded tag count in invalid name test Siddharth Shrimali
2026-04-14 16:54 ` Junio C Hamano
2026-04-20 7:13 ` Patrick Steinhardt [this message]
2026-04-14 14:18 ` [PATCH 2/3] t7004: dynamically grab expected state in tests Siddharth Shrimali
2026-04-14 17:00 ` Junio C Hamano
2026-04-14 14:18 ` [PATCH 3/3] t7004: avoid subshells to capture git exit codes Siddharth Shrimali
2026-04-21 5:33 ` [PATCH v2 0/3] t7004: cleanup and modernize brittle tests Siddharth Shrimali
2026-04-21 5:33 ` [PATCH v2 1/3] t7004: drop hardcoded tag count for state verification Siddharth Shrimali
2026-04-21 5:33 ` [PATCH v2 2/3] t7004: dynamically grab expected state in tests Siddharth Shrimali
2026-04-21 5:33 ` [PATCH v2 3/3] t7004: avoid subshells to capture git exit codes Siddharth Shrimali
2026-04-21 5:38 ` [PATCH v2 0/3] t7004: cleanup and modernize brittle tests Patrick Steinhardt
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=aeXSLcVl_eGFkagr@pks.im \
--to=ps@pks.im \
--cc=abdobngad@gmail.com \
--cc=bence@ferdinandy.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=john.a.passaro@gmail.com \
--cc=r.siddharth.shrimali@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.