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

[PATCH] t0005: test git exit code from signal death

From
Jeff King <peff@peff.net>
Date
Jun 1, 2013, 17:24 UTC
Message-ID
<20130601172441.GB19234@sigill.intra.peff.net>
In-Reply-To
<CAMP44s2cBGc+uKH0t-KZko-5GYkZUK54+7wiYbWim55B7KGaGA@mail.gmail.com>
On Sat, Jun 01, 2013 at 10:01:49AM -0500, Felipe Contreras wrote:
> Anyway, if you care so much about the current behavior, why isn't
> there any tests that check for this?
> 
> My patch passes *all* the tests.

The test suite has never been (and probably never will be) a complete specification of git's behavior. Noticing that a desired behavior is not in the test suite is an opportunity to improve its coverage, not argue that a change which breaks the desired behavior must therefore be acceptable.

We could do something like the patch below, with two caveats:
  1. The test immediately before it checks for exit codes other than
     "143" on various platforms. I do not know to what degree we need to
     deal with that here. Git is doing the interpretation here rather
     than the shell, so the ksh case should not matter. But I do not
     know what part of Windows converts the exit code to 3. Do we need
     to be looking for 3? Or 131 (128+3)?
  2. The test detects a total breakage of the exit code, like the one
     caused by your patch. But I do not know if it would reliably detect
     us failing to convert the code at all, as the shell running the
     test harness would presumably convert it to shell-convention
     itself. Getting around that would require a custom C program
     checking the status returned by waitpid().
     On the other hand, perhaps it is not the conversion we care about;
     as long as we end up with 143, we are fine. We just want to make
     sure that signal death is recorded in _one_ of the potential signal
     formats. So we do not care if git or the shell did the conversion,
     as long as we end up with 143. The real breakage is exiting with
     code 15, which is losing information.
-- >8 --
Subject: [PATCH] t0005: test git exit code from signal death

When a sub-process dies with a signal, we convert the exit code to the shell convention of 128+sig. Callers of git may be relying on this behavior, so let's make sure it does not break.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t0005-signals.sh | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/t/t0005-signals.sh b/t/t0005-signals.sh
index 93e58c0..63f9764 100755
--- a/t/t0005-signals.sh
+++ b/t/t0005-signals.sh
@@ -20,4 +20,11 @@ test_expect_success 'sigchain works' '
 	test_cmp expect actual
 '
 
+test_expect_success 'signals are propagated using shell convention' '
+	# we use exec here to avoid any sub-shell interpretation
+	# of the exit code
+	git config alias.sigterm "!exec test-sigchain" &&
+	test_expect_code 143 git sigterm
+'
+
 test_done
-- 
1.8.3.rc1.2.g12db477
Previous: Felipe ContrerasNext: Felipe Contreras
Message 12 of 15 in “run-command: simplify wait_or_whine”
  1. run-command: simplify wait_or_whineFelipe Contreras, Jun 1, 2013
  2. Duy NguyenJun 1, 2013
  3. Felipe ContrerasJun 1, 2013
  4. Duy NguyenJun 1, 2013
  5. Felipe ContrerasJun 1, 2013
  6. Thomas RastJun 1, 2013
  7. Felipe ContrerasJun 1, 2013
  8. Duy NguyenJun 1, 2013
  9. Felipe ContrerasJun 1, 2013
  10. Duy NguyenJun 1, 2013
  11. Felipe ContrerasJun 1, 2013
  12. t0005: test git exit code from signal deathJeff King, Jun 1, 2013
  13. Felipe ContrerasJun 1, 2013
  14. Jeff KingJun 1, 2013
  15. Felipe ContrerasJun 1, 2013

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.