|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -logfile=./testdox.xml |
| 3 | +logfile=./junit.xml |
4 | 4 |
|
5 | | -if test -f "$logfile"; then |
6 | | - echo "Logfile found. Searching for failed tests..." |
| 5 | +if [ -f "./vendor/bin/pest" ]; then |
| 6 | + runner="./vendor/bin/pest" |
| 7 | +else |
| 8 | + runner="./vendor/bin/phpunit" |
| 9 | +fi |
7 | 10 |
|
8 | | - # Strip out everything except the failed tests just in |
9 | | - # case they were run using a different tool or script |
10 | | - xmlstarlet tr ./vendor/chrisdicarlo/phpunit-failed-runner/prune.xsl testdox.xml > testdoxTMP.xml |
11 | | - mv testdoxTMP.xml testdox.xml |
| 11 | +if test -f "$logfile"; then |
| 12 | + echo -e "Logfile found. Searching for previously failing tests... \U23F3" |
12 | 13 |
|
13 | | - failed_tests="$(xmlstarlet tr --omit-decl ./vendor/chrisdicarlo/phpunit-failed-runner/failed-tests.xsl testdox.xml)" |
| 14 | + count_failed_tests="$(xmlstarlet tr ./vendor/chrisdicarlo/phpunit-failed-runner/prune.xsl junit.xml | xmlstarlet tr --omit-decl ./vendor/chrisdicarlo/phpunit-failed-runner/count-failed.xsl)" |
14 | 15 |
|
15 | | - if [ "$failed_tests" = "" ]; then |
16 | | - echo "No failed tests! Great job!" |
| 16 | + if [ "$count_failed_tests" = "0" ]; then |
| 17 | + echo -e "No failed tests! Great job! \U1F44D \U1F389" |
| 18 | + rm "$logfile" |
| 19 | + exit 0 |
17 | 20 | else |
18 | | - echo "Found failed tests, filtering..." |
19 | | - ./vendor/bin/phpunit --filter "'$failed_tests'" |
| 21 | + echo -e "Found $count_failed_tests previously failing tests, filtering... \U1F97A" |
| 22 | + filter=$(xmlstarlet tr ./vendor/chrisdicarlo/phpunit-failed-runner/prune.xsl junit.xml | xmlstarlet tr --omit-decl ./vendor/chrisdicarlo/phpunit-failed-runner/failed-tests.xsl); "$runner" --filter "$filter" --log-junit junit.xml |
20 | 23 | fi |
21 | 24 | else |
22 | | - echo "Logfile not found. Running the full test suite..." |
23 | | - ./vendor/bin/phpunit |
24 | | -fi |
25 | | - |
26 | | -# Strip out everything except the failed tests |
27 | | -xmlstarlet tr ./vendor/chrisdicarlo/phpunit-failed-runner/prune.xsl testdox.xml > testdoxTMP.xml |
28 | | -mv testdoxTMP.xml testdox.xml |
29 | | - |
30 | | -# If there are no more failed tests, remove the log file |
31 | | -count_failed_tests="$(xmlstarlet tr --omit-decl ./vendor/chrisdicarlo/phpunit-failed-runner/count-failed.xsl testdox.xml)" |
32 | | - |
33 | | -if [ "$count_failed_tests" = "0" ]; then |
34 | | - rm ./testdox.xml |
| 25 | + echo -e "Logfile not found. Running the full test suite... \U1F91E" |
| 26 | + "$runner" --log-junit junit.xml |
35 | 27 | fi |
36 | 28 |
|
37 | 29 | exit 0 |
0 commit comments