Skip to content

Commit

Permalink
test-lib: translate SIGTERM and SIGHUP to an exit
Browse files Browse the repository at this point in the history
Right now if a test script receives SIGTERM or SIGHUP (e.g., because a
test was hanging and the user 'kill'-ed it or simply closed the
terminal window the test was running in), the shell exits immediately.
This can be annoying if the test script did any global setup, like
starting apache or git-daemon, as it will not have an opportunity to
clean up after itself. A subsequent run of the test won't be able to
start its own daemon, and will either fail or skip the tests.

Instead, let's trap SIGTERM and SIGHUP as well to make sure we do a
clean shutdown, and just chain it to a normal exit (which will trigger
any cleanup).

This patch follows suit of da70654 (t: translate SIGINT to an exit,
2015-03-13), and even stole its commit message as well.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
szeder authored and gitster committed Jan 3, 2019
1 parent 54ea72f commit d45cec4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ die () {

GIT_EXIT_OK=
trap 'die' EXIT
trap 'exit $?' INT
trap 'exit $?' INT TERM HUP

# The user-facing functions are loaded from a separate file so that
# test_perf subshells can have them too
Expand Down

0 comments on commit d45cec4

Please sign in to comment.