From 5e8fa64031bcfd6bb726bbeb078cbaa566ae8d97 Mon Sep 17 00:00:00 2001 From: Chris Di Carlo Date: Thu, 3 Mar 2022 13:55:04 -0500 Subject: [PATCH 1/3] Add pest integration --- phpunit-failed-runner | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/phpunit-failed-runner b/phpunit-failed-runner index 04cdead..a6d45eb 100755 --- a/phpunit-failed-runner +++ b/phpunit-failed-runner @@ -2,6 +2,12 @@ logfile=./testdox.xml +if [ -f "./vendor/bin/pest" ]; then + runner="./vendor/bin/pest" +else + runner="./vendor/bin/phpunit" +fi + if test -f "$logfile"; then echo "Logfile found. Searching for failed tests..." @@ -16,11 +22,11 @@ if test -f "$logfile"; then echo "No failed tests! Great job!" else echo "Found failed tests, filtering..." - ./vendor/bin/phpunit --filter "'$failed_tests'" + "$runner" --filter "'$failed_tests'" fi else echo "Logfile not found. Running the full test suite..." - ./vendor/bin/phpunit + "$runner" fi # Strip out everything except the failed tests From 47db1279f6321e3bad451dbaf052adf86cca1420 Mon Sep 17 00:00:00 2001 From: Chris Di Carlo Date: Tue, 22 Nov 2022 20:13:21 -0500 Subject: [PATCH 2/3] Refactor to fix bugs when filtering Pest tests --- count-failed.xsl | 3 ++- failed-tests.xsl | 33 +++++++++++++++++++++++++++++++-- phpunit-failed-runner | 36 +++++++++++------------------------- prune.xsl | 21 +++++++++++++++------ 4 files changed, 59 insertions(+), 34 deletions(-) diff --git a/count-failed.xsl b/count-failed.xsl index b3112f7..b94e6f1 100644 --- a/count-failed.xsl +++ b/count-failed.xsl @@ -1,5 +1,6 @@ + - + diff --git a/failed-tests.xsl b/failed-tests.xsl index 14ed3cd..7fd896d 100644 --- a/failed-tests.xsl +++ b/failed-tests.xsl @@ -6,7 +6,36 @@ - + + + + + + + + + + + | + + + + + + + + + + + + + + + + + + + diff --git a/phpunit-failed-runner b/phpunit-failed-runner index a6d45eb..2665bff 100755 --- a/phpunit-failed-runner +++ b/phpunit-failed-runner @@ -1,6 +1,6 @@ #!/bin/bash -logfile=./testdox.xml +logfile=./junit.xml if [ -f "./vendor/bin/pest" ]; then runner="./vendor/bin/pest" @@ -9,35 +9,21 @@ else fi if test -f "$logfile"; then - echo "Logfile found. Searching for failed tests..." + echo -e "Logfile found. Searching for previously failing tests... \U23F3" - # Strip out everything except the failed tests just in - # case they were run using a different tool or script - xmlstarlet tr ./vendor/chrisdicarlo/phpunit-failed-runner/prune.xsl testdox.xml > testdoxTMP.xml - mv testdoxTMP.xml testdox.xml + 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)" - failed_tests="$(xmlstarlet tr --omit-decl ./vendor/chrisdicarlo/phpunit-failed-runner/failed-tests.xsl testdox.xml)" - - if [ "$failed_tests" = "" ]; then - echo "No failed tests! Great job!" + if [ "$count_failed_tests" = "0" ]; then + echo -e "No failed tests! Great job! \U1F44D \U1F389" + rm "$logfile" + exit 0 else - echo "Found failed tests, filtering..." - "$runner" --filter "'$failed_tests'" + echo -e "Found $count_failed_tests previously failing tests, filtering... \U1F97A" + 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 fi else - echo "Logfile not found. Running the full test suite..." - "$runner" -fi - -# Strip out everything except the failed tests -xmlstarlet tr ./vendor/chrisdicarlo/phpunit-failed-runner/prune.xsl testdox.xml > testdoxTMP.xml -mv testdoxTMP.xml testdox.xml - -# If there are no more failed tests, remove the log file -count_failed_tests="$(xmlstarlet tr --omit-decl ./vendor/chrisdicarlo/phpunit-failed-runner/count-failed.xsl testdox.xml)" - -if [ "$count_failed_tests" = "0" ]; then - rm ./testdox.xml + echo -e "Logfile not found. Running the full test suite... \U1F91E" + "$runner" --log-junit junit.xml fi exit 0 diff --git a/prune.xsl b/prune.xsl index 1d30085..bfd9dc5 100644 --- a/prune.xsl +++ b/prune.xsl @@ -1,13 +1,22 @@ - - - - - + + + + - + + + + + + + + + :: + + From 53e10310214cfd014cc3ffd1745c5296ec06f5d5 Mon Sep 17 00:00:00 2001 From: Chris Di Carlo Date: Tue, 22 Nov 2022 20:53:26 -0500 Subject: [PATCH 3/3] Remove unneeded Github actions config --- .github/workflows/main.yml | 36 ------------------------------------ .styleci.yml | 4 ---- 2 files changed, 40 deletions(-) delete mode 100644 .github/workflows/main.yml delete mode 100644 .styleci.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index e51e362..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Tests - -on: [push, pull_request] - -jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest, windows-latest] - php: [8.0, 7.4] - stability: [prefer-lowest, prefer-stable] - - name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo - coverage: none - - - name: Setup problem matchers - run: | - echo "::add-matcher::${{ runner.tool_cache }}/php.json" - echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Install dependencies - run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - - name: Execute tests - run: vendor/bin/phpunit diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index f4d3cbc..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,4 +0,0 @@ -preset: laravel - -disabled: - - single_class_element_per_statement