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

[PATCH/RFC] test-lib: clean up trash* directories on SIGINT

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 11, 2010, 09:51 UTC
Message-ID
<AANLkTimnrLlprdScYDKHs_lIvFKc3K0n8U5vTzG_df2k@mail.gmail.com>

Is there any reason not to remove trash directories on SIGINT? It's annoying that trash directories are left when I cancel a test run.

I can submit an actual patch along these lines once Junio applies some of my other stuff which will probably conflict with any finalized patch.

Is "trap 'foo' INT" a bashism? Is "trap 'foo' SIGINT" more portable? How about the exit code from an INT handler, what should it be?

diff --git a/t/test-lib.sh b/t/test-lib.sh
index ac496aa..e4a0fc9 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -222,6 +222,17 @@ die () {
 GIT_EXIT_OK=
 trap 'die' EXIT

+git_interrupted () {
+       test -d "$remove_trash" &&
+       cd "$(dirname "$remove_trash")" &&
+       rm -rf "$(basename "$remove_trash")"
+
+       # What my shell normal exits on on sigint
+       exit 130
+}
+
+trap 'git_interrupted' INT
+
 # The semantics of the editor variables are that of invoking
 # sh -c "$EDITOR \"$@\"" files ...
 #
Next: Andreas Schwab
Message 1 of 7 in “test-lib: clean up trash* directories on SIGINT”
  1. test-lib: clean up trash* directories on SIGINTÆvar Arnfjörð Bjarmason, Jul 11, 2010
  2. Andreas SchwabJul 11, 2010
  3. Nicolas PitreJul 12, 2010
  4. Ævar Arnfjörð BjarmasonJul 12, 2010
  5. Jonathan NiederJul 12, 2010
  6. Ævar Arnfjörð BjarmasonJul 12, 2010
  7. Jonathan NiederJul 12, 2010

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.