Skip to content

Commit 3bdc424

Browse files
committed
Call teardowns in cleanup only when interrupted
This is an attempt to fix issue kward#112.
1 parent ebc4baa commit 3bdc424

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

shunit2

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ __shunit_reportGenerated=${SHUNIT_FALSE} # Is report generated.
130130
__shunit_script='' # Filename of unittest script (standalone mode).
131131
__shunit_skip=${SHUNIT_FALSE} # Is skipping enabled.
132132
__shunit_suite='' # Suite of tests to execute.
133-
__shunit_clean=${SHUNIT_FALSE} # _shunit_cleanup() was already called.
134133

135134
# ANSI colors (populated by _shunit_configureColor()).
136135
__shunit_ansi_none=''
@@ -1006,22 +1005,17 @@ _shunit_cleanup() {
10061005
_shunit_error "unrecognized trap value (${_shunit_name_})"
10071006
;;
10081007
esac
1008+
10091009
if ${__SHUNIT_BUILTIN} [ "${_shunit_name_}" != 'EXIT' ]; then
10101010
_shunit_warn "trapped and now handling the (${_shunit_name_}) signal"
1011-
fi
1012-
1013-
# Do our work.
1014-
if ${__SHUNIT_BUILTIN} [ ${__shunit_clean} -eq ${SHUNIT_FALSE} ]; then
10151011
# Ensure tear downs are only called once.
1016-
__shunit_clean=${SHUNIT_TRUE}
1017-
10181012
tearDown || _shunit_warn 'tearDown() returned non-zero return code.'
10191013
oneTimeTearDown || \
10201014
_shunit_warn 'oneTimeTearDown() returned non-zero return code.'
1021-
1022-
command rm -fr "${__shunit_tmpDir}"
10231015
fi
10241016

1017+
command rm -fr "${__shunit_tmpDir}"
1018+
10251019
if ${__SHUNIT_BUILTIN} [ "${_shunit_name_}" != 'EXIT' ]; then
10261020
# Handle all non-EXIT signals.
10271021
trap - 0 # Disable EXIT trap.

0 commit comments

Comments
 (0)