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

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

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Apr 18, 2026, 19:17 UTC
Message-ID
<aePY1x9uO39p6WDI@fruit.crustytoothpaste.net>
In-Reply-To
<AA6F33AD-25C2-4AB0-A624-35C7B0BE0F66@gmail.com>
On 2026-04-18 at 12:17:10, Ben Knoble wrote:
Show 14 quoted lines
> 
> > Le 18 avr. 2026 à 02:50, Jeff King <peff@peff.net> a écrit :
> > Thinking on this a little more, it is a shame we cannot easily enable
> > this for dash. That would hit most CI jobs, but also the local builds of
> > most developers. And finding problems early and locally often saves a
> > lot of time versus finding them in CI.
> > 
> > Unfortunately I could not find a way to detect whether we are running
> > dash at all, let alone a recent version. But what if we let the user
> > tell us? Something like:
> 
> I was just wishing for similar! I imagine it would be useful for folks
> who occasionally test Zsh’s POSIX mode and want to see how it handles
> -e

I hard-coded this on with a bunch of shells in Debian unstable using the below script. zsh, busybox, and dash passed, while mksh, lksh, and posh failed. (The latter are all pdksh variants, I believe, so they are an important set of shells to consider.)

Note that the script symlinks the shell to `sh` so that everyone will be on their best POSIX behaviour.

---- #!/bin/sh

dir=$(mktemp -d) trap 'rm -fr "$dir"' EXIT

sh="$1" ln -sf "$sh" "$dir/sh"

make -j12 all && (cd t && GIT_PROVE_OPTS=-j12 GIT_TEST_DEFAULT_HASH=sha256 PATH="$dir:$PATH" SHELL_PATH="$dir/sh" make prove) ----

Having said that, I actually think that mksh may be right in at least one case. For instance, this diff seems required for mksh to pass t1410 and I believe this is actually the right thing to do:

----
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
index ce71f9a30a..f289fc11e9 100755
--- a/t/t1410-reflog.sh
+++ b/t/t1410-reflog.sh
@@ -23,7 +23,7 @@ check_have () {
 }
 
 check_fsck () {
-	git fsck --full >fsck.output
+	git fsck --full >fsck.output || true
 	case "$1" in
 	'')
 		test_must_be_empty fsck.output ;;
----

I haven't checked the other cases under mksh, but I think it may be a
fruitful source of things to look at.  And if you find a bug, I'm sure
the maintainer would happily accept a bug report in the Debian BTS.
-- 
brian m. carlson (they/them)
Toronto, Ontario, CA
Previous: Patrick SteinhardtNext: Jeff King
Message 20 of 23 in “t: detect errors outside of test cases”
  1. 00/12 t: detect errors outside of test casesPatrick Steinhardt, Apr 17, 2026
  2. 01/12 t: prepare `test_match_signal ()` calls for `set -e`Patrick Steinhardt, Apr 17, 2026
  3. 02/12 t: prepare `test_must_fail ()` for `set -e`Patrick Steinhardt, Apr 17, 2026
  4. 03/12 t: prepare `stop_git_daemon ()` for `set -e`Patrick Steinhardt, Apr 17, 2026
  5. 04/12 t: prepare `git config --unset` calls for `set -e`Patrick Steinhardt, Apr 17, 2026
  6. 05/12 t: prepare conditional test execution for `set -e`Patrick Steinhardt, Apr 17, 2026
  7. 06/12 t: prepare execution of potentially failing commands for `set -e`Patrick Steinhardt, Apr 17, 2026
  8. 07/12 t: prepare `test_when_finished ()`/`test_atexit()` for `set -e`Patrick Steinhardt, Apr 17, 2026
  9. 08/12 t0008: silence error in subshell when using `grep -v`Patrick Steinhardt, Apr 17, 2026
  10. 09/12 t1301: don't fail in case setfacl(1) doesn't exist or failsPatrick Steinhardt, Apr 17, 2026
  11. 10/12 t6002: fix use of `expr` with `set -e`Patrick Steinhardt, Apr 17, 2026
  12. 11/12 t9902: fix use of `read` with `set -e`Patrick Steinhardt, Apr 17, 2026
  13. 12/12 t: detect errors outside of test casesPatrick Steinhardt, Apr 17, 2026
  14. Jeff KingApr 18, 2026
  15. Ben KnobleApr 18, 2026
  16. Jeff KingApr 18, 2026
  17. Junio C HamanoApr 18, 2026
  18. Jeff KingApr 18, 2026
  19. Patrick SteinhardtApr 20, 2026
  20. brian m. carlsonApr 18, 2026
  21. Jeff KingApr 18, 2026
  22. brian m. carlsonApr 18, 2026
  23. Jeff KingApr 19, 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.