| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | # Copyright 2022-2024 Julian Gilbey <[email protected]> |
| 4 | # License: MIT License (Expat) |
| 5 | |
| 6 | # Determine whether every test passes in at least one pytest run. |
| 7 | # We run the command given on the command line at most MAX_PYTEST_RUNS, |
| 8 | # stopping if a pytest run is successful. |
| 9 | |
| 10 | get_exclusions_script=$1 |
| 11 | source=$2 |
| 12 | shift 2 |
| 13 | interpreter=$1 |
| 14 | exclusions=$($get_exclusions_script $source $interpreter) |
| 15 | |
| 16 | MAX_PYTEST_RUNS=5 |
| 17 | |
| 18 | NO_TESTS_EXITCODE=$(python3scip-shell system . . python3. -c "from pytest import ExitCode; print(int(ExitCode.NO_TESTS_COLLECTED))") |
| 19 | |
| 20 | run=1 |
| 21 | while [scip-shell system . . `[`. $run -le $MAX_PYTEST_RUNS ] |
| 22 | do |
| 23 | if [scip-shell system . . `[`. $run -eq 1 ] |
| 24 | then |
| 25 | runopts="-rsfE" |
| 26 | else |
| 27 | runopts="-rfE --last-failed --last-failed-no-failures none" |
| 28 | fi |
| 29 | echoscip-shell system . . echo. "*** STARTING RUN $run: $* $runopts $exclusions" |
| 30 | "$@" $runopts $exclusions |
| 31 | ret=$? |
| 32 | if [scip-shell system . . `[`. $ret -eq 0 -o $ret -eq $NO_TESTS_EXITCODE ] |
| 33 | then |
| 34 | echoscip-shell system . . echo. "*** END OF RUN $run: ALL TESTS RUN HAVE NOW PASSED/XFAILED ***" |
| 35 | exit 0 |
| 36 | fi |
| 37 | echoscip-shell system . . echo. "*** END OF RUN $run: NOT ALL TESTS HAVE YET PASSED/XFAILED ***" |
| 38 | run=$(($run + 1)) |
| 39 | done |
| 40 | |
| 41 | echoscip-shell system . . echo. "*** SOME TESTS FAILED/ERRORED EVERY RUN, ABORTING ***" |
| 42 | exit 1 |