Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
In case of failure test suite executes finalization steps. Resolves #7
Browse files Browse the repository at this point in the history
joergboe committed Jan 6, 2020

Verified

This commit was signed with the committer’s verified signature.
JonasKunz Jonas Kunz
1 parent 5bfcf3c commit d2c1e1e
Showing 3 changed files with 41 additions and 5 deletions.
37 changes: 32 additions & 5 deletions bin/suite.sh
Original file line number Diff line number Diff line change
@@ -26,7 +26,8 @@ declare -r TTTI_sigspec='TERM'
#start time
declare -r TTTT_suiteStartTime=$(date -u +%s)
#state
declare TTTT_executionState='initializing'
TTTT_executionState='initializing'
TTTT_suiteFinalized=''

# Function handle SIGINT
handleSigint() {
@@ -119,7 +120,36 @@ if [[ $TTRO_suiteIndex -ne 0 ]]; then
TTXX_searchPath="$TTRO_inputDirSuite $TTXX_searchPath"
export TTXX_searchPath
fi
# TODO: it that required here?
TTTF_fixPropsVars
############################
declare -i TTTI_executedTestFinSteps=0
#test finalization function
suiteFinalization() {
#unset the errtrace too to avoid unnecessary error traps
set +o errexit; set +o nounset; set +o errtrace
isDebug && printDebug "$FUNCNAME"
if [[ $TTTT_executionState == 'initializing' ]]; then
return 0
fi
if [[ -z $TTTT_suiteFinalized ]]; then
TTTT_suiteFinalized='true'

TTTF_executeSteps 'Suite' 'Finalization' 'FINS' 'TTRO_finsSuite' 'testFinalization' '' 'TTPR_noFinsSuite' 'TTTI_executedTestFinSteps'
else
isDebug && printDebug "No execution suiteFinalization suite $TTRO_suite variant '$TTRO_variantSuite'"
fi
return 0
}

suiteExitFunction() {
set +o errexit; set +o nounset; set +o errtrace
printInfo "$FUNCNAME"
if ! TTTF_isSkip; then
suiteFinalization
fi
}
trap suiteExitFunction EXIT

# enter working dir
cd "$TTRO_workDirSuite"
@@ -848,10 +878,7 @@ unset timeout variantCount variantList

#test suite finalization
TTTT_executionState='finalization'
declare -i TTTI_executedTestFinSteps=0
#unset the errtrace too to avoid unnecessary error traps
set +o errexit; set +o nounset; set +o errtrace
TTTF_executeSteps 'Suite' 'Finalization' 'FINS' 'TTRO_finSuite' 'testFinalization' '' 'TTPR_noFinsSuite' 'TTTI_executedTestFinSteps'
suiteFinalization

#-------------------------------------------------------
#put results to results file for information purose only
3 changes: 3 additions & 0 deletions test/errorSuite/Suite1/TestSuite.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Demonstrate error during suite initialization -> no finalization steps are executed

FINS="echo '########### Suite finalization ############'"

dsvgfsdfgsd
dfsbvgsdf
6 changes: 6 additions & 0 deletions test/errorSuite/Suite2/TestSuite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Demonstrate error during suite preparation -> 1 finalization steps are executed
PREPS='false'

FINS=( "echo '########### Suite finalization 1 ############'"
"echo '########### Suite finalization 2 ############'"
)

0 comments on commit d2c1e1e

Please sign in to comment.