REGTEST: script: Add the option --keep-logs to keep all log directories

By default a log directory is kept only if the test fails. With this option it
is possible to always keep it. If this option is used, the result of all tests
are displayed (and not only the failing ones).
This commit is contained in:
Christopher Faulet 2018-12-19 10:25:07 +01:00
parent 2a7cf922c1
commit 9c6df5ecb4

View File

@ -22,6 +22,9 @@ _help()
--debug to show test logs on standard ouput (implies --v) --debug to show test logs on standard ouput (implies --v)
run-regtests.sh --debug run-regtests.sh --debug
--keep-logs to keep all log directories (by default kept if test fails)
run-regtests.sh --keep-logs
--varnishtestparams <ARGS>, passes custom ARGS to varnishtest --varnishtestparams <ARGS>, passes custom ARGS to varnishtest
run-regtests.sh --varnishtestparams "-n 10" run-regtests.sh --varnishtestparams "-n 10"
@ -259,6 +262,9 @@ _process() {
verbose="" verbose=""
debug="-v" debug="-v"
;; ;;
--keep-logs)
keep_logs="-L"
;;
--LEVEL) --LEVEL)
LEVEL="$2" LEVEL="$2"
shift shift
@ -295,6 +301,7 @@ REGTESTS=""
jobcount="" jobcount=""
verbose="-q" verbose="-q"
debug="" debug=""
keep_logs="-l"
testlist="" testlist=""
_process "$@"; _process "$@";
@ -412,27 +419,32 @@ if [ -n "$testlist" ]; then
if [ -n "$jobcount" ]; then if [ -n "$jobcount" ]; then
jobcount="-j $jobcount" jobcount="-j $jobcount"
fi fi
cmd="$VARNISHTEST_PROGRAM -l -k -t 10 $verbose $debug $jobcount $varnishtestparams $testlist" cmd="$VARNISHTEST_PROGRAM -k -t 10 $keep_logs $verbose $debug $jobcount $varnishtestparams $testlist"
eval $cmd eval $cmd
_vtresult=$? _vtresult=$?
else else
echo "No tests found that meet the required criteria" echo "No tests found that meet the required criteria"
fi fi
if [ $_vtresult != 0 ]
then
echo "########################## Gathering failed results ##########################" if [ $_vtresult -eq 0 ]; then
# all tests were succesfull, removing tempdir (the last part.)
# ignore errors is the directory is not empty or if it does not exist
rmdir "$TESTDIR" 2>/dev/null
fi
if [ -d "${TESTDIR}" ]; then
echo "########################## Gathering results ##########################"
export TESTDIR export TESTDIR
find "$TESTDIR" -type d -name "vtc.*" -exec sh -c 'for i; do find "$TESTDIR" -type d -name "vtc.*" -exec sh -c 'for i; do
if [ ! -e "$i/LOG" ] ; then continue; fi if [ ! -e "$i/LOG" ] ; then continue; fi
cat <<- EOF | tee -a "$TESTDIR/failedtests.log" cat <<- EOF | tee -a "$TESTDIR/failedtests.log"
$(echo "###### $(cat "$i/INFO") ######") $(echo "###### $(cat "$i/INFO") ######")
$(echo "## test results in: \"$i\"") $(echo "## test results in: \"$i\"")
$(grep -- ---- "$i/LOG") $(grep -- ---- "$i/LOG")
EOF EOF
done' sh {} + done' sh {} +
exit 1
else
# all tests were succesfull, removing tempdir (the last part.)
rmdir "$TESTDIR"
fi fi
exit 0
exit $_vtresult