From dcabb1c63b19850b09769f0857b0ce91c6a47ad2 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Wed, 10 Mar 2021 12:58:07 +0000 Subject: [PATCH] Pick system-level testing from #5784 --- .../tests.yaml | 5 +- .github/workflows/system_tests.yaml | 49 +++++++++++++++++++ .../dont-execute-code/composer.json | 7 +++ .../system-tests/dont-execute-code/rector.php | 17 +++++++ .../dont-execute-code/src/OutputInterface.php | 7 +++ .../parse-php7-code/composer.json | 7 +++ tests/system-tests/parse-php7-code/rector.php | 17 +++++++ .../system-tests/parse-php7-code/src/Foo.php | 12 +++++ .../parse-php8-code/composer.json | 7 +++ tests/system-tests/parse-php8-code/rector.php | 17 +++++++ .../system-tests/parse-php8-code/src/Foo.php | 10 ++++ 11 files changed, 153 insertions(+), 2 deletions(-) rename .github/{workflows => inactive_workflows}/tests.yaml (92%) create mode 100644 .github/workflows/system_tests.yaml create mode 100644 tests/system-tests/dont-execute-code/composer.json create mode 100644 tests/system-tests/dont-execute-code/rector.php create mode 100644 tests/system-tests/dont-execute-code/src/OutputInterface.php create mode 100644 tests/system-tests/parse-php7-code/composer.json create mode 100644 tests/system-tests/parse-php7-code/rector.php create mode 100644 tests/system-tests/parse-php7-code/src/Foo.php create mode 100644 tests/system-tests/parse-php8-code/composer.json create mode 100644 tests/system-tests/parse-php8-code/rector.php create mode 100644 tests/system-tests/parse-php8-code/src/Foo.php diff --git a/.github/workflows/tests.yaml b/.github/inactive_workflows/tests.yaml similarity index 92% rename from .github/workflows/tests.yaml rename to .github/inactive_workflows/tests.yaml index 81bad9e72624..f5530c6ed3cf 100644 --- a/.github/workflows/tests.yaml +++ b/.github/inactive_workflows/tests.yaml @@ -1,6 +1,7 @@ name: Tests -on: ['push'] +on: + pull_request: null jobs: tests: @@ -28,4 +29,4 @@ jobs: - run: composer install --no-progress --ansi if: "matrix.dependencies != 'lowest'" - - run: tests/system-tests/run-tests.sh + - run: vendor/bin/phpunit diff --git a/.github/workflows/system_tests.yaml b/.github/workflows/system_tests.yaml new file mode 100644 index 000000000000..c4f5d7994f27 --- /dev/null +++ b/.github/workflows/system_tests.yaml @@ -0,0 +1,49 @@ +name: System Tests + +on: ['push'] + +jobs: + system_tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [ '7.4', '8.0' ] + + name: PHP ${{ matrix.php }} system tests + steps: + - uses: actions/checkout@v2 + + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none # disable xdebug, pcov + + - name: Install dependencies for Rector + run: composer install --no-progress --ansi + + # This workflow runs system tests: Use the Rector application from the source + # checkout to process "fixture" projects in tests/system-tests + # to see if those can be processed successfully + + - name: Generate Composer autoloaders in fixture directories + run: | + for FIXTURE in `find tests/system-tests -mindepth 1 -maxdepth 1 -type d`; do + (cd $FIXTURE; composer install --no-progress --ansi) + done + + - name: Run system tests + run: | + HAS_FAILURES=0 + + for FIXTURE in `find tests/system-tests -mindepth 1 -maxdepth 1 -type d`; do + echo "-----> Running $FIXTURE <-----" + if (cd $FIXTURE; ../../../bin/rector process --dry-run --clear-cache); then + echo "-----> Result: OK <-----" + else + echo "-----> Result: FAILED <-----" + HAS_FAILURES=1 + fi + done + + exit $HAS_FAILURES diff --git a/tests/system-tests/dont-execute-code/composer.json b/tests/system-tests/dont-execute-code/composer.json new file mode 100644 index 000000000000..39fa78e1b21a --- /dev/null +++ b/tests/system-tests/dont-execute-code/composer.json @@ -0,0 +1,7 @@ +{ + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\Output\\": "src" + } + } +} diff --git a/tests/system-tests/dont-execute-code/rector.php b/tests/system-tests/dont-execute-code/rector.php new file mode 100644 index 000000000000..c95c284b4483 --- /dev/null +++ b/tests/system-tests/dont-execute-code/rector.php @@ -0,0 +1,17 @@ +parameters(); + $parameters->set(Option::PATHS, [__DIR__.'/src']); + $parameters->set(Option::SKIP, [__DIR__.'/vendor']); + + $parameters->set(Option::SETS, [SetList::PHP_53]); +}; + diff --git a/tests/system-tests/dont-execute-code/src/OutputInterface.php b/tests/system-tests/dont-execute-code/src/OutputInterface.php new file mode 100644 index 000000000000..cc851338659a --- /dev/null +++ b/tests/system-tests/dont-execute-code/src/OutputInterface.php @@ -0,0 +1,7 @@ +parameters(); + $parameters->set(Option::PATHS, [__DIR__.'/src']); + $parameters->set(Option::SKIP, [__DIR__.'/vendor']); + + $parameters->set(Option::SETS, [SetList::PHP_53]); +}; + diff --git a/tests/system-tests/parse-php7-code/src/Foo.php b/tests/system-tests/parse-php7-code/src/Foo.php new file mode 100644 index 000000000000..2c24d393628e --- /dev/null +++ b/tests/system-tests/parse-php7-code/src/Foo.php @@ -0,0 +1,12 @@ +parameters(); + $parameters->set(Option::PATHS, [__DIR__.'/src']); + $parameters->set(Option::SKIP, [__DIR__.'/vendor']); + + $parameters->set(Option::SETS, [SetList::PHP_53]); +}; + diff --git a/tests/system-tests/parse-php8-code/src/Foo.php b/tests/system-tests/parse-php8-code/src/Foo.php new file mode 100644 index 000000000000..5e0a91462648 --- /dev/null +++ b/tests/system-tests/parse-php8-code/src/Foo.php @@ -0,0 +1,10 @@ +