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

[PATCH v2 01/12] t: prepare `test_match_signal ()` calls for `set -e`

From
Patrick Steinhardt <ps@pks.im>
Date
Apr 15, 2026, 13:06 UTC
Message-ID
<20260415-b4-pks-tests-with-set-e-v2-1-4e4904a96f15@pks.im>
In-Reply-To
<20260415-b4-pks-tests-with-set-e-v2-0-4e4904a96f15@pks.im>

We have a couple of calls to `test_match_signal ()` where we execute a Git command and expect it to die with a specific signal. These calls will essentially execute the process in a subshell via `foo; echo $?`, but as we expect `foo` to fail this will cause the overall subshell to fail once we `set -e`.

Fix this issue by using `foo && echo 0 || echo $?` instead.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/t0005-signals.sh | 4 ++--
 t/t3600-rm.sh      | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/t/t0005-signals.sh b/t/t0005-signals.sh
index afba0fc3fc..84319cf169 100755
--- a/t/t0005-signals.sh
+++ b/t/t0005-signals.sh
@@ -42,12 +42,12 @@ test_expect_success 'create blob' '
 '
 
 test_expect_success !MINGW 'a constipated git dies with SIGPIPE' '
-	OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
+	OUT=$( ((large_git && echo 0 1>&3 || echo $? 1>&3) | :) 3>&1 ) &&
 	test_match_signal 13 "$OUT"
 '
 
 test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' '
-	OUT=$( ((trap "" PIPE && large_git; echo $? 1>&3) | :) 3>&1 ) &&
+	OUT=$( ((trap "" PIPE && large_git && echo 0 1>&3 || echo $? 1>&3) | :) 3>&1 ) &&
 	test_match_signal 13 "$OUT"
 '
 
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 1f16e6b522..a371ea690e 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -260,7 +260,7 @@ test_expect_success 'choking "git rm" should not let it die with cruft (induce S
 
 test_expect_success !MINGW 'choking "git rm" should not let it die with cruft (induce and check SIGPIPE)' '
 	choke_git_rm_setup &&
-	OUT=$( ((trap "" PIPE && git rm -n "some-file-*"; echo $? 1>&3) | :) 3>&1 ) &&
+	OUT=$( ((trap "" PIPE && git rm -n "some-file-*" && echo 0 1>&3 || echo $? 1>&3) | :) 3>&1 ) &&
 	test_match_signal 13 "$OUT" &&
 	test_path_is_missing .git/index.lock
 '
-- 
2.54.0.rc2.529.gd9106f7525.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 2 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.