From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 06/12] t: prepare execution of potentially failing commands for `set -e`
Date: Mon, 13 Apr 2026 10:09:27 -0700 [thread overview]
Message-ID: <xmqqtsteiy7s.fsf@gitster.g> (raw)
In-Reply-To: <20260413-b4-pks-tests-with-set-e-v1-6-5b83763a0e84@pks.im> (Patrick Steinhardt's message of "Mon, 13 Apr 2026 11:49:27 +0200")
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.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> t/lib-git-svn.sh | 3 +--
> t/lib-httpd.sh | 3 +--
> t/t9200-git-cvsexportcommit.sh | 3 +--
> t/t9400-git-cvsserver-server.sh | 5 +++--
> t/t9401-git-cvsserver-crlf.sh | 4 ++--
> t/t9402-git-cvsserver-refs.sh | 4 ++--
> t/test-lib.sh | 4 ++--
> 7 files changed, 12 insertions(+), 14 deletions(-)
>
> diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
> index 2fde2353fd..07d86ea244 100644
> --- a/t/lib-git-svn.sh
> +++ b/t/lib-git-svn.sh
> @@ -15,8 +15,7 @@ GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn
> SVN_TREE=$GIT_SVN_DIR/svn-tree
> test_set_port SVNSERVE_PORT
>
> -svn >/dev/null 2>&1
> -if test $? -ne 1
> +if ! svn help >/dev/null 2>&1
> then
> skip_all='skipping git svn tests, svn not found'
> test_done
> diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
> index 4c76e813e3..fc646447d5 100644
> --- a/t/lib-httpd.sh
> +++ b/t/lib-httpd.sh
> @@ -235,11 +235,10 @@ start_httpd() {
>
> test_atexit stop_httpd
>
> - "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
> + if ! "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
> -f "$TEST_PATH/apache.conf" $HTTPD_PARA \
> -c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start \
> >&3 2>&4
> - if test $? -ne 0
> then
> cat "$HTTPD_ROOT_PATH"/error.log >&4 2>/dev/null
> test_skip_or_die GIT_TEST_HTTPD "web server setup failed"
> diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh
> index 14cbe96527..581cf3d28f 100755
> --- a/t/t9200-git-cvsexportcommit.sh
> +++ b/t/t9200-git-cvsexportcommit.sh
> @@ -11,8 +11,7 @@ if ! test_have_prereq PERL; then
> test_done
> fi
>
> -cvs >/dev/null 2>&1
> -if test $? -ne 1
> +if ! cvs version >/dev/null 2>&1
> then
> skip_all='skipping git cvsexportcommit tests, cvs not found'
> test_done
> diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
> index e499c7f955..4b45398bab 100755
> --- a/t/t9400-git-cvsserver-server.sh
> +++ b/t/t9400-git-cvsserver-server.sh
> @@ -17,12 +17,13 @@ if ! test_have_prereq PERL; then
> skip_all='skipping git cvsserver tests, perl not available'
> test_done
> fi
> -cvs >/dev/null 2>&1
> -if test $? -ne 1
> +
> +if ! cvs version >/dev/null 2>&1
> then
> skip_all='skipping git-cvsserver tests, cvs not found'
> test_done
> fi
> +
> perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
> skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
> test_done
> diff --git a/t/t9401-git-cvsserver-crlf.sh b/t/t9401-git-cvsserver-crlf.sh
> index a34805acdc..6b4cbb1651 100755
> --- a/t/t9401-git-cvsserver-crlf.sh
> +++ b/t/t9401-git-cvsserver-crlf.sh
> @@ -60,12 +60,12 @@ check_status_options() {
> return $stat
> }
>
> -cvs >/dev/null 2>&1
> -if test $? -ne 1
> +if ! cvs version >/dev/null 2>&1
> then
> skip_all='skipping git-cvsserver tests, cvs not found'
> test_done
> fi
> +
> if ! test_have_prereq PERL
> then
> skip_all='skipping git-cvsserver tests, perl not available'
> diff --git a/t/t9402-git-cvsserver-refs.sh b/t/t9402-git-cvsserver-refs.sh
> index 2ee41f9443..65f2ceedec 100755
> --- a/t/t9402-git-cvsserver-refs.sh
> +++ b/t/t9402-git-cvsserver-refs.sh
> @@ -68,12 +68,12 @@ check_diff() {
>
> #########
>
> -cvs >/dev/null 2>&1
> -if test $? -ne 1
> +if ! cvs version >/dev/null 2>&1
> then
> skip_all='skipping git-cvsserver tests, cvs not found'
> test_done
> fi
> +
> if ! test_have_prereq PERL
> then
> skip_all='skipping git-cvsserver tests, perl not available'
> 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
next prev parent reply other threads:[~2026-04-13 17:09 UTC|newest]
Thread overview: 133+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 9:49 [PATCH 00/12] t: detect errors outside of test cases Patrick Steinhardt
2026-04-13 9:49 ` [PATCH 01/12] t: prepare `test_match_signal ()` calls for `set -e` Patrick Steinhardt
2026-04-13 16:26 ` Junio C Hamano
2026-04-14 7:23 ` Patrick Steinhardt
2026-04-14 17:49 ` Junio C Hamano
2026-04-13 9:49 ` [PATCH 02/12] t: prepare `test_must_fail ()` " Patrick Steinhardt
2026-04-13 16:33 ` Junio C Hamano
2026-04-14 7:23 ` Patrick Steinhardt
2026-04-14 6:23 ` Jeff King
2026-04-14 17:41 ` Junio C Hamano
2026-04-15 6:58 ` Patrick Steinhardt
2026-04-16 5:40 ` Jeff King
2026-04-13 9:49 ` [PATCH 03/12] t: prepare `stop_git_daemon " Patrick Steinhardt
2026-04-13 16:53 ` Junio C Hamano
2026-04-13 9:49 ` [PATCH 04/12] t: prepare `git config --unset` calls " Patrick Steinhardt
2026-04-13 16:59 ` Junio C Hamano
2026-04-13 9:49 ` [PATCH 05/12] t: prepare conditional test execution " Patrick Steinhardt
2026-04-13 17:04 ` Junio C Hamano
2026-04-13 9:49 ` [PATCH 06/12] t: prepare execution of potentially failing commands " Patrick Steinhardt
2026-04-13 17:09 ` Junio C Hamano [this message]
2026-04-14 7:23 ` Patrick Steinhardt
2026-04-14 13:41 ` Junio C Hamano
2026-04-13 22:32 ` Junio C Hamano
2026-04-14 1:09 ` Junio C Hamano
2026-04-14 7:23 ` Patrick Steinhardt
2026-04-14 7:23 ` Patrick Steinhardt
2026-04-14 13:40 ` Junio C Hamano
2026-04-14 22:03 ` Jeff King
2026-04-14 22:52 ` Jeff King
2026-04-14 23:08 ` Jeff King
2026-04-15 6:48 ` Patrick Steinhardt
2026-04-16 5:49 ` Jeff King
2026-04-16 8:03 ` Patrick Steinhardt
2026-04-16 14:34 ` Junio C Hamano
2026-04-18 8:01 ` Jeff King
2026-04-15 15:31 ` Junio C Hamano
2026-04-13 9:49 ` [PATCH 07/12] t: prepare `test_when_finished ()`/`test_atexit()` " Patrick Steinhardt
2026-04-13 17:23 ` Junio C Hamano
2026-04-14 7:24 ` Patrick Steinhardt
2026-04-13 9:49 ` [PATCH 08/12] t0008: silence error in subshell when using `grep -v` Patrick Steinhardt
2026-04-13 17:28 ` Junio C Hamano
2026-04-14 7:23 ` Patrick Steinhardt
2026-04-13 9:49 ` [PATCH 09/12] t1301: don't fail in case setfacl(1) doesn't exist or fails Patrick Steinhardt
2026-04-13 9:49 ` [PATCH 10/12] t6002: fix use of `expr` with `set -e` Patrick Steinhardt
2026-04-13 9:49 ` [PATCH 11/12] t9902: fix use of `read` " Patrick Steinhardt
2026-04-13 9:49 ` [PATCH 12/12] t: detect errors outside of test cases Patrick Steinhardt
2026-04-13 17:29 ` Junio C Hamano
2026-04-13 21:33 ` [PATCH 00/12] " Junio C Hamano
2026-04-13 21:46 ` Junio C Hamano
2026-04-15 13:06 ` [PATCH v2 " Patrick Steinhardt
2026-04-15 13:06 ` [PATCH v2 01/12] t: prepare `test_match_signal ()` calls for `set -e` Patrick Steinhardt
2026-04-15 13:06 ` [PATCH v2 02/12] t: prepare `test_must_fail ()` " Patrick Steinhardt
2026-04-15 13:06 ` [PATCH v2 03/12] t: prepare `stop_git_daemon " Patrick Steinhardt
2026-04-15 13:06 ` [PATCH v2 04/12] t: prepare `git config --unset` calls " Patrick Steinhardt
2026-04-15 13:06 ` [PATCH v2 05/12] t: prepare conditional test execution " Patrick Steinhardt
2026-04-15 13:06 ` [PATCH v2 06/12] t: prepare execution of potentially failing commands " Patrick Steinhardt
2026-04-15 13:06 ` [PATCH v2 07/12] t: prepare `test_when_finished ()`/`test_atexit()` " Patrick Steinhardt
2026-04-15 13:06 ` [PATCH v2 08/12] t0008: silence error in subshell when using `grep -v` Patrick Steinhardt
2026-04-15 13:06 ` [PATCH v2 09/12] t1301: don't fail in case setfacl(1) doesn't exist or fails Patrick Steinhardt
2026-04-15 13:06 ` [PATCH v2 10/12] t6002: fix use of `expr` with `set -e` Patrick Steinhardt
2026-04-15 13:06 ` [PATCH v2 11/12] t9902: fix use of `read` " Patrick Steinhardt
2026-04-15 13:06 ` [PATCH v2 12/12] t: detect errors outside of test cases Patrick Steinhardt
2026-04-16 6:00 ` Jeff King
2026-04-16 10:46 ` Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 00/12] " Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 01/12] t: prepare `test_match_signal ()` calls for `set -e` Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 02/12] t: prepare `test_must_fail ()` " Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 03/12] t: prepare `stop_git_daemon " Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 04/12] t: prepare `git config --unset` calls " Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 05/12] t: prepare conditional test execution " Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 06/12] t: prepare execution of potentially failing commands " Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 07/12] t: prepare `test_when_finished ()`/`test_atexit()` " Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 08/12] t0008: silence error in subshell when using `grep -v` Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 09/12] t1301: don't fail in case setfacl(1) doesn't exist or fails Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 10/12] t6002: fix use of `expr` with `set -e` Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 11/12] t9902: fix use of `read` " Patrick Steinhardt
2026-04-16 20:12 ` SZEDER Gábor
2026-04-16 20:42 ` Junio C Hamano
2026-04-17 9:44 ` Patrick Steinhardt
2026-04-16 11:19 ` [PATCH v3 12/12] t: detect errors outside of test cases Patrick Steinhardt
2026-04-16 16:06 ` Junio C Hamano
2026-04-17 10:50 ` [PATCH v4 00/12] " Patrick Steinhardt
2026-04-17 10:50 ` [PATCH v4 01/12] t: prepare `test_match_signal ()` calls for `set -e` Patrick Steinhardt
2026-04-17 10:50 ` [PATCH v4 02/12] t: prepare `test_must_fail ()` " Patrick Steinhardt
2026-04-17 10:50 ` [PATCH v4 03/12] t: prepare `stop_git_daemon " Patrick Steinhardt
2026-04-17 10:50 ` [PATCH v4 04/12] t: prepare `git config --unset` calls " Patrick Steinhardt
2026-04-17 10:50 ` [PATCH v4 05/12] t: prepare conditional test execution " Patrick Steinhardt
2026-04-17 10:50 ` [PATCH v4 06/12] t: prepare execution of potentially failing commands " Patrick Steinhardt
2026-04-17 10:50 ` [PATCH v4 07/12] t: prepare `test_when_finished ()`/`test_atexit()` " Patrick Steinhardt
2026-04-17 10:50 ` [PATCH v4 08/12] t0008: silence error in subshell when using `grep -v` Patrick Steinhardt
2026-04-17 10:50 ` [PATCH v4 09/12] t1301: don't fail in case setfacl(1) doesn't exist or fails Patrick Steinhardt
2026-04-17 10:50 ` [PATCH v4 10/12] t6002: fix use of `expr` with `set -e` Patrick Steinhardt
2026-04-17 10:50 ` [PATCH v4 11/12] t9902: fix use of `read` " Patrick Steinhardt
2026-04-17 10:50 ` [PATCH v4 12/12] t: detect errors outside of test cases Patrick Steinhardt
2026-04-18 6:50 ` Jeff King
2026-04-18 12:17 ` Ben Knoble
2026-04-18 17:44 ` Jeff King
2026-04-18 19:24 ` Junio C Hamano
2026-04-18 21:05 ` Jeff King
2026-04-20 6:11 ` Patrick Steinhardt
2026-04-18 19:17 ` brian m. carlson
2026-04-18 21:30 ` Jeff King
2026-04-18 21:54 ` brian m. carlson
2026-04-19 2:10 ` Jeff King
2026-04-20 7:27 ` [PATCH v5 00/12] " Patrick Steinhardt
2026-04-20 7:27 ` [PATCH v5 01/12] t: prepare `test_match_signal ()` calls for `set -e` Patrick Steinhardt
2026-04-20 7:27 ` [PATCH v5 02/12] t: prepare `test_must_fail ()` " Patrick Steinhardt
2026-04-20 7:27 ` [PATCH v5 03/12] t: prepare `stop_git_daemon " Patrick Steinhardt
2026-04-20 7:27 ` [PATCH v5 04/12] t: prepare `git config --unset` calls " Patrick Steinhardt
2026-04-20 7:27 ` [PATCH v5 05/12] t: prepare conditional test execution " Patrick Steinhardt
2026-04-20 7:27 ` [PATCH v5 06/12] t: prepare execution of potentially failing commands " Patrick Steinhardt
2026-04-20 7:27 ` [PATCH v5 07/12] t: prepare `test_when_finished ()`/`test_atexit()` " Patrick Steinhardt
2026-04-20 7:27 ` [PATCH v5 08/12] t0008: silence error in subshell when using `grep -v` Patrick Steinhardt
2026-04-20 7:27 ` [PATCH v5 09/12] t1301: don't fail in case setfacl(1) doesn't exist or fails Patrick Steinhardt
2026-04-20 7:27 ` [PATCH v5 10/12] t6002: fix use of `expr` with `set -e` Patrick Steinhardt
2026-04-20 7:27 ` [PATCH v5 11/12] t9902: fix use of `read` " Patrick Steinhardt
2026-04-20 7:27 ` [PATCH v5 12/12] t: detect errors outside of test cases Patrick Steinhardt
2026-04-20 16:19 ` [PATCH v5 00/12] " Junio C Hamano
2026-04-21 3:00 ` Jeff King
2026-04-21 5:41 ` Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 " Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 01/12] t: prepare `test_match_signal ()` calls for `set -e` Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 02/12] t: prepare `test_must_fail ()` " Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 03/12] t: prepare `stop_git_daemon " Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 04/12] t: prepare `git config --unset` calls " Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 05/12] t: prepare conditional test execution " Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 06/12] t: prepare execution of potentially failing commands " Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 07/12] t: prepare `test_when_finished ()`/`test_atexit()` " Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 08/12] t0008: silence error in subshell when using `grep -v` Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 09/12] t1301: don't fail in case setfacl(1) doesn't exist or fails Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 10/12] t6002: fix use of `expr` with `set -e` Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 11/12] t9902: fix use of `read` " Patrick Steinhardt
2026-04-21 7:34 ` [PATCH v6 12/12] t: detect errors outside of test cases 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=xmqqtsteiy7s.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/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.