1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#!/bin/bash
# Copyright 2022-2024 Julian Gilbey <jdg@debian.org>
# License: MIT License
# Determine whether every test passes in at least one pytest run.
# We run the command given on the command line at most MAX_PYTEST_RUNS,
# stopping if a pytest run is successful.
interpreter=$1
MAX_PYTEST_RUNS=5
# Remove any old log files
rm -f pytest_log.txt
run=1
while [ $run -le $MAX_PYTEST_RUNS ]
do
echo "*** STARTING RUN $run: $* $exclusions"
set -o pipefail
"$@" | tee -a pytest_log.txt
ret=$?
set +o pipefail
if [ $ret -eq 0 ]
then
echo "*** END OF RUN $run: ALL TESTS RUN HAVE NOW PASSED/XFAILED ***"
rm -f pytest_log.txt
exit 0
fi
echo "*** END OF RUN $run: NOT ALL TESTS HAVE YET PASSED/XFAILED ***"
run=$(($run + 1))
done
echo "*** SOME TESTS FAILED/ERRORED EVERY RUN, ABORTING ***"
rm -f pytest_log.txt
exit 1
|