[PATCH v3 00/12] t: detect errors outside of test cases
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Apr 16, 2026, 11:19 UTC
- Message-ID
- <20260416-b4-pks-tests-with-set-e-v3-0-7a90e5dccadd@pks.im>
- In-Reply-To
- <20260413-b4-pks-tests-with-set-e-v1-0-5b83763a0e84@pks.im>
Hi,
this is a follow-up to the recent discussion we had around `set -e` to make our tests more robust and basically supersedes Junio's [1].
I've tested the patches with both Bash and Dash, and all tests are passing on my machine with both of them. CI seems to be happy, as well. But I would expect that this change probably has some fallout, even though I hope that it's generally going to be small and contained.
This series is based on 8c9303b1ff (Merge branch 'jc/no-writev-does-not-work', 2026-04-10).
I've created an MR with GitLab [2] and a PR with GitHub [3] to verify that these changes work on both platforms.
Changes in v3:
- Adapt `linux-TEST-vars` job to use Bash instead of Dash. Ubuntu
packet mirrors seem to be having problems, so I wasn't able to get
past installing dependencies in any jobs. All to say that I couldn't
verify that this works as expected :/
- Link to v2: https://patch.msgid.link/20260415-b4-pks-tests-with-set-e-v2-0-4e4904a96f15@pks.imChanges in v2:
- Use `ret=0; $command || ret=$?` pattern.
- Restore `echo 0` in SIGPIPE tests.
- Fix "lib-git-svn.sh" to gracefully handle the case where SVN Perl
modules aren't installed.
- Use `|| :` consistently instead of `|| true`.
- Fix up a couple of tests that fail on FreeBSD 15. The test suite is
now passing on this system, too.
- Only enable `set -e` on Bash 5 and newer.
- Link to v1: https://patch.msgid.link/20260413-b4-pks-tests-with-set-e-v1-0-5b83763a0e84@pks.imThanks!
Patrick
[1]: <20260325062114.2067946-1-gitster@pobox.com> [2]: https://gitlab.com/gitlab-org/git/-/merge_requests/541 [3]: https://github.com/git/git/pull/2270
---
Patrick Steinhardt (12):
t: prepare `test_match_signal ()` calls for `set -e`
t: prepare `test_must_fail ()` for `set -e`
t: prepare `stop_git_daemon ()` for `set -e`
t: prepare `git config --unset` calls for `set -e`
t: prepare conditional test execution for `set -e`
t: prepare execution of potentially failing commands for `set -e`
t: prepare `test_when_finished ()`/`test_atexit()` for `set -e`
t0008: silence error in subshell when using `grep -v`
t1301: don't fail in case setfacl(1) doesn't exist or fails
t6002: fix use of `expr` with `set -e`
t9902: fix use of `read` with `set -e`
t: detect errors outside of test casesci/run-build-and-tests.sh | 5 +++++ t/lib-git-daemon.sh | 8 +++++--- t/lib-git-svn.sh | 7 +++---- t/lib-httpd.sh | 3 +-- t/t0005-signals.sh | 4 ++-- t/t0008-ignores.sh | 4 ++-- t/t1301-shared-repo.sh | 2 +- t/t3600-rm.sh | 2 +- t/t3901-i18n-patch.sh | 3 ++- t/t4032-diff-inter-hunk-context.sh | 14 ++++++++------ t/t5000-tar-tree.sh | 4 ++-- t/t6002-rev-list-bisect.sh | 17 ++++++++++------- t/t7422-submodule-output.sh | 2 +- t/t7450-bad-git-dotfiles.sh | 24 +++++++++++++----------- t/t7508-status.sh | 4 ++-- t/t9138-git-svn-authors-prog.sh | 4 ++-- 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/t9902-completion.sh | 2 +- t/test-lib-functions.sh | 12 ++++++------ t/test-lib.sh | 19 +++++++++++++++---- 23 files changed, 90 insertions(+), 66 deletions(-)
Range-diff versus v2:
1: 5685131f51 = 1: 97c51d03f7 t: prepare `test_match_signal ()` calls for `set -e`
2: 7459f569ee = 2: e1e2f83d1d t: prepare `test_must_fail ()` for `set -e`
3: 4077ee4b7f = 3: 441444895e t: prepare `stop_git_daemon ()` for `set -e`
4: 095c9b5b38 = 4: 5084b4627a t: prepare `git config --unset` calls for `set -e`
5: 0cdf15d405 = 5: 4608aef6ee t: prepare conditional test execution for `set -e`
6: 12f85b2c18 = 6: 9f10b21410 t: prepare execution of potentially failing commands for `set -e`
7: 50dc57081d = 7: c9584e9b56 t: prepare `test_when_finished ()`/`test_atexit()` for `set -e`
8: e223383e82 = 8: 778a555bb2 t0008: silence error in subshell when using `grep -v`
9: ad084a9d37 = 9: ba4b513722 t1301: don't fail in case setfacl(1) doesn't exist or fails
10: 39a01a5e06 = 10: 5f5db73fdb t6002: fix use of `expr` with `set -e`
11: 060d094d3f = 11: 03d0e9c089 t9902: fix use of `read` with `set -e`
12: 73a21590b1 ! 12: bd300ab2f8 t: detect errors outside of test cases
@@ Commit message
Signed-off-by: Patrick Steinhardt <ps@pks.im>
+ ## ci/run-build-and-tests.sh ##
+@@ ci/run-build-and-tests.sh: fedora-breaking-changes-musl|linux-breaking-changes)
+ MESONFLAGS="$MESONFLAGS -Drust=enabled"
+ ;;
+ linux-TEST-vars)
++ # Ubuntu uses Dash by default, but we only enable use of `set -e`
++ # when using Bash 5+. Ensure that we have at least one CI job that uses
++ # it.
++ export TEST_SHELL_PATH=/usr/bin/bash
++
+ export OPENSSL_SHA1_UNSAFE=YesPlease
+ export GIT_TEST_SPLIT_INDEX=yes
+ export GIT_TEST_FULL_IN_PACK_ARRAY=true
+
## t/test-lib.sh ##
@@
# You should have received a copy of the GNU General Public License--- base-commit: 8c9303b1ffae5b745d1b0a1f98330cf7944d8db0 change-id: 20260410-b4-pks-tests-with-set-e-3ae479b24b51