Re: [PATCH 06/12] t: prepare execution of potentially failing commands for `set -e`
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Apr 14, 2026, 07:23 UTC
- Message-ID
- <ad3riiF5QWuMmUeT@pks.im>
- In-Reply-To
- <xmqqtsteiy7s.fsf@gitster.g>
On Mon, Apr 13, 2026 at 10:09:27AM -0700, Junio C Hamano wrote:
Show 22 quoted lines
> Patrick Steinhardt <ps@pks.im> writes: > > > Several of our tests verify whether a certain binary can be executed, > > potentially skipping tests in case we cannot, for example because the > > binary doesn't exist. In those cases we often run the binary outside of > > any conditionally. > > > > This will start to fail once we enable `set -e`, as that will cause us > > to bail out the test immediately. Improve these tests by executing them > > inside of a conditional instead. > > OK. "svn help" and "cvs version" do exit with status 0 and the > rewrites that use them make sense. I wonder if we can do something > similar to "git" instead of relying on "git<RETURN>" to exit with 1, > perhaps ... > > $ git version >/dev/null; echo $? > 0 > > ... by using "git version" in the test-lib.sh change? > > Other than that looking very good.
I'm a bit confused. We do exactly that in "test-lib.sh" now, see the below hunk that is part of this patch. Am I missing something?
Patrick
Show 15 quoted lines
> > diff --git a/t/test-lib.sh b/t/test-lib.sh
> > index 70fd3e9baf..81380fe978 100644
> > --- a/t/test-lib.sh
> > +++ b/t/test-lib.sh
> > @@ -143,8 +143,8 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
> > ################################################################
> > # It appears that people try to run tests without building...
> > GIT_BINARY="${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X"
> > -"$GIT_BINARY" >/dev/null
> > -if test $? != 1
> > +
> > +if ! "$GIT_BINARY" version >/dev/null
> > then
> > if test -n "$GIT_TEST_INSTALLED"
> > then