Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call teardowns in cleanup only when interrupted #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions shunit2
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ __shunit_reportGenerated=${SHUNIT_FALSE} # Is report generated.
__shunit_script='' # Filename of unittest script (standalone mode).
__shunit_skip=${SHUNIT_FALSE} # Is skipping enabled.
__shunit_suite='' # Suite of tests to execute.
__shunit_clean=${SHUNIT_FALSE} # _shunit_cleanup() was already called.

# ANSI colors (populated by _shunit_configureColor()).
__shunit_ansi_none=''
Expand Down Expand Up @@ -1006,22 +1005,17 @@ _shunit_cleanup() {
_shunit_error "unrecognized trap value (${_shunit_name_})"
;;
esac

if ${__SHUNIT_BUILTIN} [ "${_shunit_name_}" != 'EXIT' ]; then
_shunit_warn "trapped and now handling the (${_shunit_name_}) signal"
fi

# Do our work.
if ${__SHUNIT_BUILTIN} [ ${__shunit_clean} -eq ${SHUNIT_FALSE} ]; then
# Ensure tear downs are only called once.
__shunit_clean=${SHUNIT_TRUE}

tearDown || _shunit_warn 'tearDown() returned non-zero return code.'
oneTimeTearDown || \
_shunit_warn 'oneTimeTearDown() returned non-zero return code.'

command rm -fr "${__shunit_tmpDir}"
fi

command rm -fr "${__shunit_tmpDir}"

if ${__SHUNIT_BUILTIN} [ "${_shunit_name_}" != 'EXIT' ]; then
# Handle all non-EXIT signals.
trap - 0 # Disable EXIT trap.
Expand Down