git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v5 00/12] t: detect errors outside of test cases

From
Patrick Steinhardt <ps@pks.im>
Date
Apr 20, 2026, 07:27 UTC
Message-ID
<20260420-b4-pks-tests-with-set-e-v5-0-7d3d68292f6b@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 v5:
  - Allow opting in via `GIT_TEST_USE_SET_E=yes` and enable this option
    for Linux CI jobs.
  - Another fix for a potentially-failing command.
  - Link to v4: https://patch.msgid.link/20260417-b4-pks-tests-with-set-e-v4-0-44d43efdafb1@pks.im
Changes in v4:
  - Simplify how we read a multi-line variable value.
  - Link to v3: https://patch.msgid.link/20260416-b4-pks-tests-with-set-e-v3-0-7a90e5dccadd@pks.im
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.im
Changes 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.im
Thanks!
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 cases
 ci/run-build-and-tests.sh          |  6 ++++++
 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/t1410-reflog.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              |  6 ++----
 t/test-lib-functions.sh            | 12 ++++++------
 t/test-lib.sh                      | 35 +++++++++++++++++++++++++++++++----
 24 files changed, 109 insertions(+), 70 deletions(-)
Range-diff versus v4:
 1:  c6503a6ecc =  1:  9f5238f960 t: prepare `test_match_signal ()` calls for `set -e`
 2:  792e674fe2 =  2:  7c1beb70dc t: prepare `test_must_fail ()` for `set -e`
 3:  106cf12fa0 =  3:  f209a2ecbb t: prepare `stop_git_daemon ()` for `set -e`
 4:  1a5ac9b5d8 =  4:  7b6f7091f8 t: prepare `git config --unset` calls for `set -e`
 5:  ecb6f07131 =  5:  e265d86fa0 t: prepare conditional test execution for `set -e`
 6:  4468b5ef08 !  6:  04978dda41 t: prepare execution of potentially failing commands for `set -e`
    @@ t/lib-httpd.sh: start_httpd() {
      		cat "$HTTPD_ROOT_PATH"/error.log >&4 2>/dev/null
      		test_skip_or_die GIT_TEST_HTTPD "web server setup failed"
     
    + ## t/t1410-reflog.sh ##
    +@@ t/t1410-reflog.sh: check_have () {
    + }
    + 
    + check_fsck () {
    +-	git fsck --full >fsck.output
    ++	git fsck --full >fsck.output || true
    + 	case "$1" in
    + 	'')
    + 		test_must_be_empty fsck.output ;;
    +
      ## t/t3901-i18n-patch.sh ##
     @@ t/t3901-i18n-patch.sh: check_encoding () {
      		8859)
 7:  a188ac9564 =  7:  3c07c82032 t: prepare `test_when_finished ()`/`test_atexit()` for `set -e`
 8:  963b9f4a82 =  8:  43d67af0e5 t0008: silence error in subshell when using `grep -v`
 9:  510d235080 =  9:  822857fd35 t1301: don't fail in case setfacl(1) doesn't exist or fails
10:  550d9042bc = 10:  ad24432195 t6002: fix use of `expr` with `set -e`
11:  9b23e69584 = 11:  88c8b888e1 t9902: fix use of `read` with `set -e`
12:  55fc58c1ec <  -:  ---------- t: detect errors outside of test cases
 -:  ---------- > 12:  0de0c56caa t: detect errors outside of test cases

--- base-commit: 8c9303b1ffae5b745d1b0a1f98330cf7944d8db0 change-id: 20260410-b4-pks-tests-with-set-e-3ae479b24b51

Previous: Junio C HamanoNext: Patrick Steinhardt
Message 67 of 95 in “t: detect errors outside of test cases”
  1. 00/12 t: detect errors outside of test casesPatrick Steinhardt, Apr 13, 2026
  2. 01/12 t: prepare `test_match_signal ()` calls for `set -e`Patrick Steinhardt, Apr 13, 2026
  3. Junio C HamanoApr 13, 2026
  4. Patrick SteinhardtApr 14, 2026
  5. Junio C HamanoApr 14, 2026
  6. 02/12 t: prepare `test_must_fail ()` for `set -e`Patrick Steinhardt, Apr 13, 2026
  7. Junio C HamanoApr 13, 2026
  8. Patrick SteinhardtApr 14, 2026
  9. Jeff KingApr 14, 2026
  10. Junio C HamanoApr 14, 2026
  11. Patrick SteinhardtApr 15, 2026
  12. Jeff KingApr 16, 2026
  13. 03/12 t: prepare `stop_git_daemon ()` for `set -e`Patrick Steinhardt, Apr 13, 2026
  14. Junio C HamanoApr 13, 2026
  15. 04/12 t: prepare `git config --unset` calls for `set -e`Patrick Steinhardt, Apr 13, 2026
  16. Junio C HamanoApr 13, 2026
  17. 05/12 t: prepare conditional test execution for `set -e`Patrick Steinhardt, Apr 13, 2026
  18. Junio C HamanoApr 13, 2026
  19. 06/12 t: prepare execution of potentially failing commands for `set -e`Patrick Steinhardt, Apr 13, 2026
  20. Junio C HamanoApr 13, 2026
  21. Patrick SteinhardtApr 14, 2026
  22. Junio C HamanoApr 14, 2026
  23. Junio C HamanoApr 13, 2026
  24. Junio C HamanoApr 14, 2026
  25. Patrick SteinhardtApr 14, 2026
  26. Patrick SteinhardtApr 14, 2026
  27. Junio C HamanoApr 14, 2026
  28. Jeff KingApr 14, 2026
  29. Jeff KingApr 14, 2026
  30. Jeff KingApr 14, 2026
  31. Patrick SteinhardtApr 15, 2026
  32. Jeff KingApr 16, 2026
  33. Patrick SteinhardtApr 16, 2026
  34. Junio C HamanoApr 16, 2026
  35. Jeff KingApr 18, 2026
  36. Junio C HamanoApr 15, 2026
  37. 07/12 t: prepare `test_when_finished ()`/`test_atexit()` for `set -e`Patrick Steinhardt, Apr 13, 2026
  38. Junio C HamanoApr 13, 2026
  39. Patrick SteinhardtApr 14, 2026
  40. 08/12 t0008: silence error in subshell when using `grep -v`Patrick Steinhardt, Apr 13, 2026
  41. Junio C HamanoApr 13, 2026
  42. Patrick SteinhardtApr 14, 2026
  43. 09/12 t1301: don't fail in case setfacl(1) doesn't exist or failsPatrick Steinhardt, Apr 13, 2026
  44. 10/12 t6002: fix use of `expr` with `set -e`Patrick Steinhardt, Apr 13, 2026
  45. 11/12 t9902: fix use of `read` with `set -e`Patrick Steinhardt, Apr 13, 2026
  46. 12/12 t: detect errors outside of test casesPatrick Steinhardt, Apr 13, 2026
  47. Junio C HamanoApr 13, 2026
  48. Junio C HamanoApr 13, 2026
  49. Junio C HamanoApr 13, 2026
  50. 00/12 t: detect errors outside of test casesPatrick Steinhardt, Apr 16, 2026
  51. 01/12 t: prepare `test_match_signal ()` calls for `set -e`Patrick Steinhardt, Apr 16, 2026
  52. 02/12 t: prepare `test_must_fail ()` for `set -e`Patrick Steinhardt, Apr 16, 2026
  53. 03/12 t: prepare `stop_git_daemon ()` for `set -e`Patrick Steinhardt, Apr 16, 2026
  54. 04/12 t: prepare `git config --unset` calls for `set -e`Patrick Steinhardt, Apr 16, 2026
  55. 05/12 t: prepare conditional test execution for `set -e`Patrick Steinhardt, Apr 16, 2026
  56. 06/12 t: prepare execution of potentially failing commands for `set -e`Patrick Steinhardt, Apr 16, 2026
  57. 07/12 t: prepare `test_when_finished ()`/`test_atexit()` for `set -e`Patrick Steinhardt, Apr 16, 2026
  58. 08/12 t0008: silence error in subshell when using `grep -v`Patrick Steinhardt, Apr 16, 2026
  59. 09/12 t1301: don't fail in case setfacl(1) doesn't exist or failsPatrick Steinhardt, Apr 16, 2026
  60. 10/12 t6002: fix use of `expr` with `set -e`Patrick Steinhardt, Apr 16, 2026
  61. 11/12 t9902: fix use of `read` with `set -e`Patrick Steinhardt, Apr 16, 2026
  62. SZEDER GáborApr 16, 2026
  63. Junio C HamanoApr 16, 2026
  64. Patrick SteinhardtApr 17, 2026
  65. 12/12 t: detect errors outside of test casesPatrick Steinhardt, Apr 16, 2026
  66. Junio C HamanoApr 16, 2026
  67. 00/12 t: detect errors outside of test casesPatrick Steinhardt, Apr 20, 2026
  68. 01/12 t: prepare `test_match_signal ()` calls for `set -e`Patrick Steinhardt, Apr 20, 2026
  69. 02/12 t: prepare `test_must_fail ()` for `set -e`Patrick Steinhardt, Apr 20, 2026
  70. 03/12 t: prepare `stop_git_daemon ()` for `set -e`Patrick Steinhardt, Apr 20, 2026
  71. 04/12 t: prepare `git config --unset` calls for `set -e`Patrick Steinhardt, Apr 20, 2026
  72. 05/12 t: prepare conditional test execution for `set -e`Patrick Steinhardt, Apr 20, 2026
  73. 06/12 t: prepare execution of potentially failing commands for `set -e`Patrick Steinhardt, Apr 20, 2026
  74. 07/12 t: prepare `test_when_finished ()`/`test_atexit()` for `set -e`Patrick Steinhardt, Apr 20, 2026
  75. 08/12 t0008: silence error in subshell when using `grep -v`Patrick Steinhardt, Apr 20, 2026
  76. 09/12 t1301: don't fail in case setfacl(1) doesn't exist or failsPatrick Steinhardt, Apr 20, 2026
  77. 10/12 t6002: fix use of `expr` with `set -e`Patrick Steinhardt, Apr 20, 2026
  78. 11/12 t9902: fix use of `read` with `set -e`Patrick Steinhardt, Apr 20, 2026
  79. 12/12 t: detect errors outside of test casesPatrick Steinhardt, Apr 20, 2026
  80. Junio C HamanoApr 20, 2026
  81. Jeff KingApr 21, 2026
  82. Patrick SteinhardtApr 21, 2026
  83. 00/12 t: detect errors outside of test casesPatrick Steinhardt, Apr 21, 2026
  84. 01/12 t: prepare `test_match_signal ()` calls for `set -e`Patrick Steinhardt, Apr 21, 2026
  85. 02/12 t: prepare `test_must_fail ()` for `set -e`Patrick Steinhardt, Apr 21, 2026
  86. 03/12 t: prepare `stop_git_daemon ()` for `set -e`Patrick Steinhardt, Apr 21, 2026
  87. 04/12 t: prepare `git config --unset` calls for `set -e`Patrick Steinhardt, Apr 21, 2026
  88. 05/12 t: prepare conditional test execution for `set -e`Patrick Steinhardt, Apr 21, 2026
  89. 06/12 t: prepare execution of potentially failing commands for `set -e`Patrick Steinhardt, Apr 21, 2026
  90. 07/12 t: prepare `test_when_finished ()`/`test_atexit()` for `set -e`Patrick Steinhardt, Apr 21, 2026
  91. 08/12 t0008: silence error in subshell when using `grep -v`Patrick Steinhardt, Apr 21, 2026
  92. 09/12 t1301: don't fail in case setfacl(1) doesn't exist or failsPatrick Steinhardt, Apr 21, 2026
  93. 10/12 t6002: fix use of `expr` with `set -e`Patrick Steinhardt, Apr 21, 2026
  94. 11/12 t9902: fix use of `read` with `set -e`Patrick Steinhardt, Apr 21, 2026
  95. 12/12 t: detect errors outside of test casesPatrick Steinhardt, Apr 21, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.