Browse Source

Handle ^C during execution gracefully

and do cleanup after ourselves whilst making sure the exit code of the
"main" script reflects the state of the tests.

Only successful return code is after all tests have run to completion
succesfully.
master
haavee 6 months ago
parent
commit
f143fd61ca
  1. 21
      main

21
main

@ -54,10 +54,23 @@ git submodule update
# If we're running from here it's us who set the tempdir
tempdir=`${python} -c 'from __future__ import print_function; import tempfile; print(tempfile.mkdtemp());'`
# now we can install cleanup
trap 'cleanup' 0 1 2 3 6 15
cleanup()
# now we can install cleanup routines for interrupted and normal process exit
trap 'cleanup_sig' 1 2 3 6 15
trap 'cleanup_normal' 0
cleanup_sig()
{
# we was interrupted - remove the whole tempdir
rm -rf ${tempdir}
exit 1
}
cleanup_normal()
{
# if cleanup_sig has run, the temp dir doesn't exist anymore
if [ ! -d ${tempdir} ]; then
exit 1;
fi
# If, after all tests have run, the tempdir is empty, it means all tests ran succesfully
if [ -z "$(ls -A ${tempdir})" ]; then
# empty == success
@ -65,7 +78,7 @@ cleanup()
exit 0;
fi
# not empty => #FAIL
exit -1
exit 1
}
for f in `find . -type f -a -name test*.py`; do

Loading…
Cancel
Save