t0301-credential-cache: use 'test_atexit' to stop the credentials helper

Use 'test_atexit' to run cleanup commands to stop the credentials helper at the end of the test script or upon interrupt or failure, as it is shorter, simpler, and more robust than registering such cleanup commands in the trap on EXIT in the test scripts. Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

SZEDER Gábor committed Mar 13, 2019 at 13:24 UTC 3bc2702b883030b138a8c7585d7bc9adb4b4a399
1 file changed +1 -6
t/t0301-credential-cache.sh
+1 -6
@@ -10,7 +10,7 @@ test -z "$NO_UNIX_SOCKETS" || {
10 }
11
12 # don't leave a stale daemon running
13 -trap 'code=$?; git credential-cache exit; (exit $code); die' EXIT
13 +test_atexit 'git credential-cache exit'
14
15 # test that the daemon works with no special setup
16 helper_test cache
@@ -108,9 +108,4 @@ test_expect_success SYMLINKS 'use user socket if user directory is a symlink to
108
109 helper_test_timeout cache --timeout=1
110
111 -# we can't rely on our "trap" above working after test_done,
112 -# as test_done will delete the trash directory containing
113 -# our socket, leaving us with no way to access the daemon.
114 -git credential-cache exit
115 -
111 test_done