File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed
Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -125,9 +125,10 @@ function stop_gpg_agent {
125125 ' /gpg-agent/ { if ( $0 !~ "awk" ) { system("kill "$1) } }' >> " $TEST_OUTPUT_FILE " 2>&1
126126 else
127127 local ps_is_busybox
128- ps_is_busybox=_exe_is_busybox ' ps'
128+ ps_is_busybox=$( _exe_is_busybox ' ps' )
129129 if [[ $ps_is_busybox -eq ' 1' ]]; then
130- echo ' # git-secret: tests: not stopping gpg-agent on busybox' >&3
130+ # On Alpine/busybox, ps doesn't show command arguments, so use gpgconf instead
131+ gpgconf --homedir " $TEST_GPG_HOMEDIR " --kill gpg-agent >> " $TEST_OUTPUT_FILE " 2>&1 || true
131132 else
132133 ps -wx -U " $username " | gawk \
133134 ' /gpg-agent --homedir/ { if ( $0 !~ "awk" ) { system("kill "$1) } }' >> " $TEST_OUTPUT_FILE " 2>&1
@@ -246,6 +247,12 @@ function remove_git_repository {
246247function set_state_initial {
247248 cd " $BATS_TMPDIR " || exit 1
248249 rm -rf " ${BATS_TMPDIR:? } /*"
250+ # Safety net: remove hidden dirs that may persist from a prior failed teardown.
251+ # The rm above is a no-op (glob inside double quotes is literal), so we must
252+ # explicitly clean up dot-dirs to prevent 'already initialized' errors.
253+ rm -rf " ${BATS_TMPDIR:? } /${_SECRETS_DIR} "
254+ rm -rf " ${BATS_TMPDIR:? } /.git"
255+ rm -rf " ${BATS_TMPDIR:? } /.gitignore"
249256}
250257
251258
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ function setup {
2222
2323
2424function teardown {
25- rm " $FILE_TO_HIDE "
25+ rm -f " $FILE_TO_HIDE "
2626
2727 uninstall_fixture_full_key " $TEST_DEFAULT_USER " " $FINGERPRINT "
2828 unset_current_state
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ function setup {
2626
2727
2828function teardown {
29- rm " $FILE_TO_HIDE "
29+ rm -f " $FILE_TO_HIDE "
3030
3131 uninstall_fixture_full_key " $TEST_DEFAULT_USER " " $FINGERPRINT "
3232 unset_current_state
You can’t perform that action at this time.
0 commit comments