Skip to content

Commit dfe90e8

Browse files
larsxschneiderpeff
authored andcommitted
git-p4: add trap to kill p4d on test exit
Sometimes the "prove" test runner hangs on test exit because p4d is still running. Add a trap to always kill "p4d" on test exit. You can reproduce the problem by commenting "P4D_TIMEOUT" in "lib-git-p4.sh" and running "prove ./t9800-git-p4-basic.sh". Signed-off-by: Lars Schneider <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 842adde commit dfe90e8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

t/lib-git-p4.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ cli="$TRASH_DIRECTORY/cli"
7474
git="$TRASH_DIRECTORY/git"
7575
pidfile="$TRASH_DIRECTORY/p4d.pid"
7676

77+
# Sometimes "prove" seems to hang on exit because p4d is still running
78+
cleanup() {
79+
if test -f "$pidfile"
80+
then
81+
kill -9 $(cat "$pidfile") 2>/dev/null && exit 255
82+
fi
83+
}
84+
trap cleanup EXIT
85+
7786
# git p4 submit generates a temp file, which will
7887
# not get cleaned up if the submission fails. Don't
7988
# clutter up /tmp on the test machine.

0 commit comments

Comments
 (0)