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
Jeff King <peff@peff.net>
Date
Apr 18, 2026, 21:30 UTC
Message-ID
<20260418213043.GB9632@coredump.intra.peff.net>
In-Reply-To
<aePY1x9uO39p6WDI@fruit.crustytoothpaste.net>
On Sat, Apr 18, 2026 at 07:17:43PM +0000, brian m. carlson wrote:
> 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:
I think mksh is wrong here, if it is flagging this fsck call.
Show 13 quoted lines
> 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 ;;

If check_fsck() were run by itself then yes, this would be a problem. But it is always run inside a test snippet, and there "set -e" should always be suppressed because test_expect_success does:

  if test_run_ "$test_body"

So we are inside a conditional, and the usual global "set -e" suppression should happen. It sounds like it is not happening in your version of mksh, but I was unable to get t1410 to fail at all using mksh 59c-43 (from Debian unstable) or 59c-41 (from stable).

And it is a good thing that this "if" suppression is here, or else tests who fail the final component of the &&-chain would cause the shell to exit. The simplest case is just:

  test_expect_success 'bad' 'false'

If "set -e" were in effect, then the whole script would bail upon seeing that "false".

-Peff
Previous: brian m. carlsonNext: brian m. carlson
Message 21 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.