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

Re: [PATCH v2 12/12] t: detect errors outside of test cases

From
Jeff King <peff@peff.net>
Date
Apr 16, 2026, 06:00 UTC
Message-ID
<20260416060059.GC646814@coredump.intra.peff.net>
In-Reply-To
<20260415-b4-pks-tests-with-set-e-v2-12-4e4904a96f15@pks.im>
On Wed, Apr 15, 2026 at 03:06:45PM +0200, Patrick Steinhardt wrote:
Show 7 quoted lines
> Improve the status quo by enabling the errexit option so that any such
> unchecked failures will cause us to abort immediately.
> 
> Note that for now, we only enable this option for Bash 5 and newer. This
> is because other shells have wildly different behaviour, and older
> versions of Bash (especially on macOS) are buggy. The list of enabled
> shells may be extended going forward.

OK, we know that this does not cause false positives because all of the tests should pass. It would be nice if we could verify that it catches bugs, too. Doing this:

diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index e4d32bb4d2..5521f21e64 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -980,4 +980,6 @@ test_expect_success 're-init reads matching includeIf.onbranch' '
 	test_cmp expect err
 '
 
+test_expect_foobar 'baz'
+
 test_done

will fail for me, but only if I specially ask to use bash, either
manually or by setting TEST_SHELL_PATH (since /bin/sh is dash on
Debian). Is there something in both GitHub and GitLab CI that will
reliably use an acceptable version of bash?

I guess perhaps Windows, though I don't know what version is used there.
But should we maybe set TEST_SHELL_PATH in at least one of the linux
builds?

-Peff
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 14 of 15 in “t: detect errors outside of test cases”
  1. 00/12 t: detect errors outside of test casesPatrick Steinhardt, Apr 15, 2026
  2. 01/12 t: prepare `test_match_signal ()` calls for `set -e`Patrick Steinhardt, Apr 15, 2026
  3. 02/12 t: prepare `test_must_fail ()` for `set -e`Patrick Steinhardt, Apr 15, 2026
  4. 03/12 t: prepare `stop_git_daemon ()` for `set -e`Patrick Steinhardt, Apr 15, 2026
  5. 04/12 t: prepare `git config --unset` calls for `set -e`Patrick Steinhardt, Apr 15, 2026
  6. 05/12 t: prepare conditional test execution for `set -e`Patrick Steinhardt, Apr 15, 2026
  7. 06/12 t: prepare execution of potentially failing commands for `set -e`Patrick Steinhardt, Apr 15, 2026
  8. 07/12 t: prepare `test_when_finished ()`/`test_atexit()` for `set -e`Patrick Steinhardt, Apr 15, 2026
  9. 08/12 t0008: silence error in subshell when using `grep -v`Patrick Steinhardt, Apr 15, 2026
  10. 09/12 t1301: don't fail in case setfacl(1) doesn't exist or failsPatrick Steinhardt, Apr 15, 2026
  11. 10/12 t6002: fix use of `expr` with `set -e`Patrick Steinhardt, Apr 15, 2026
  12. 11/12 t9902: fix use of `read` with `set -e`Patrick Steinhardt, Apr 15, 2026
  13. 12/12 t: detect errors outside of test casesPatrick Steinhardt, Apr 15, 2026
  14. Jeff KingApr 16, 2026
  15. Patrick SteinhardtApr 16, 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.