From c2b9ede02d114196e76fe672b13da1c4a68fdaf5 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 24 Mar 2024 22:18:03 +0100 Subject: [PATCH] fix tests on Windows --- .appveyor.yml | 6 +- .github/workflows/integration-tests.yml | 230 ----------------- .github/workflows/intl-data-tests.yml | 108 -------- .github/workflows/package-tests.yml | 143 ----------- .github/workflows/unit-tests.yml | 241 ------------------ .../Filesystem/Tests/FilesystemTest.php | 4 +- 6 files changed, 3 insertions(+), 729 deletions(-) delete mode 100644 .github/workflows/integration-tests.yml delete mode 100644 .github/workflows/intl-data-tests.yml delete mode 100644 .github/workflows/package-tests.yml delete mode 100644 .github/workflows/unit-tests.yml diff --git a/.appveyor.yml b/.appveyor.yml index 17723f34aa873..e0f0d1a8b07c1 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -63,9 +63,5 @@ test_script: - copy /Y c:\php\php.ini-min c:\php\php.ini - IF %APPVEYOR_REPO_BRANCH:~-2% neq .x (rm -Rf src\Symfony\Bridge\PhpUnit) - mv src\Symfony\Component\HttpClient\phpunit.xml.dist src\Symfony\Component\HttpClient\phpunit.xml - - php phpunit src\Symfony --exclude-group tty,benchmark,intl-data,network,transient-on-windows || SET X=!errorlevel! - - php phpunit src\Symfony\Component\HttpClient || SET X=!errorlevel! - - copy /Y c:\php\php.ini-max c:\php\php.ini - - php phpunit src\Symfony --exclude-group tty,benchmark,intl-data,network,transient-on-windows || SET X=!errorlevel! - - php phpunit src\Symfony\Component\HttpClient || SET X=!errorlevel! + - php phpunit src\Symfony\Component\Filesystem --exclude-group tty,benchmark,intl-data,network,transient-on-windows || SET X=!errorlevel! - exit %X% diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml deleted file mode 100644 index fc391da49cb46..0000000000000 --- a/.github/workflows/integration-tests.yml +++ /dev/null @@ -1,230 +0,0 @@ -name: Integration - -on: - push: - pull_request: - -defaults: - run: - shell: bash - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -permissions: - contents: read - -jobs: - - tests: - name: Integration - runs-on: Ubuntu-20.04 - - strategy: - matrix: - php: ['8.2'] - fail-fast: false - - services: - postgres: - image: postgres:10.6-alpine - ports: - - 5432:5432 - env: - POSTGRES_PASSWORD: 'password' - ldap: - image: bitnami/openldap - ports: - - 3389:3389 - env: - LDAP_ADMIN_USERNAME: admin - LDAP_ADMIN_PASSWORD: symfony - LDAP_ROOT: dc=symfony,dc=com - LDAP_PORT_NUMBER: 3389 - LDAP_USERS: a - LDAP_PASSWORDS: a - redis: - image: redis:6.2.8 - ports: - - 16379:6379 - redis-authenticated: - image: redis:6.2.8 - ports: - - 16380:6379 - env: - REDIS_ARGS: "--requirepass p@ssword" - redis-cluster: - image: grokzen/redis-cluster:6.2.8 - ports: - - 7000:7000 - - 7001:7001 - - 7002:7002 - - 7003:7003 - - 7004:7004 - - 7005:7005 - - 7006:7006 - env: - STANDALONE: 1 - redis-sentinel: - image: bitnami/redis-sentinel:6.2.8 - ports: - - 26379:26379 - env: - REDIS_MASTER_HOST: redis - REDIS_MASTER_SET: redis_sentinel - REDIS_SENTINEL_QUORUM: 1 - memcached: - image: memcached:1.6.5 - ports: - - 11211:11211 - rabbitmq: - image: rabbitmq:3.8.3 - ports: - - 5672:5672 - mongodb: - image: mongo - ports: - - 27017:27017 - couchbase: - image: couchbase:6.5.1 - ports: - - 8091:8091 - - 8092:8092 - - 8093:8093 - - 8094:8094 - - 11210:11210 - sqs: - image: localstack/localstack:3.0.2 - ports: - - 4566:4566 - zookeeper: - image: wurstmeister/zookeeper:3.4.6 - kafka: - image: wurstmeister/kafka:2.12-2.0.1 - ports: - - 9092:9092 - env: - KAFKA_AUTO_CREATE_TOPICS_ENABLE: false - KAFKA_CREATE_TOPICS: 'test-topic:1:1:compact' - KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1 - KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181' - KAFKA_ADVERTISED_PORT: 9092 - frankenphp: - image: dunglas/frankenphp:1.1.0 - ports: - - 80:80 - volumes: - - ${{ github.workspace }}:/symfony - env: - SERVER_NAME: 'http://localhost' - CADDY_SERVER_EXTRA_DIRECTIVES: | - root * /symfony/src/Symfony/Component/HttpFoundation/Tests/Fixtures/response-functional/ - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install system dependencies - run: | - echo "::group::apt-get update" - sudo wget -O - https://packages.couchbase.com/clients/c/repos/deb/couchbase.key | sudo apt-key add - - echo "deb https://packages.couchbase.com/clients/c/repos/deb/ubuntu2004 focal focal/main" | sudo tee /etc/apt/sources.list.d/couchbase.list - sudo apt-get update - echo "::endgroup::" - - echo "::group::install tools & libraries" - sudo apt-get install librdkafka-dev redis-server libcouchbase-dev - sudo -- sh -c 'echo unixsocket /var/run/redis/redis-server.sock >> /etc/redis/redis.conf' - sudo -- sh -c 'echo unixsocketperm 777 >> /etc/redis/redis.conf' - sudo service redis-server restart - echo "::endgroup::" - - - name: Install pgbouncer - run: | - sudo apt-get install -y pgbouncer - sudo cp src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Fixtures/pgbouncer/pgbouncer.ini /etc/pgbouncer/pgbouncer.ini - sudo cp src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Fixtures/pgbouncer/userlist.txt /etc/pgbouncer/userlist.txt - sudo service pgbouncer restart - sudo su - postgres -c "PGPASSWORD=password psql -Atq -h localhost -p 5432 -U postgres -d postgres -c \"SELECT usename, passwd FROM pg_shadow\"" - - - name: Configure Couchbase - run: | - curl -s -u 'username=Administrator&password=111111@' -X POST http://localhost:8091/node/controller/setupServices -d 'services=kv%2Cn1ql%2Cindex%2Cfts' - curl -s -X POST http://localhost:8091/settings/web -d 'username=Administrator&password=111111%40&port=SAME' - curl -s -u Administrator:111111@ -X POST http://localhost:8091/pools/default/buckets -d 'ramQuotaMB=100&bucketType=ephemeral&name=cache' - curl -s -u Administrator:111111@ -X POST http://localhost:8091/pools/default -d 'memoryQuota=256' - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - coverage: "none" - extensions: "json,couchbase-3.2.2,memcached,mongodb-1.12.0,redis,rdkafka,xsl,ldap,relay" - ini-values: date.timezone=UTC,memory_limit=-1,default_socket_timeout=10,session.gc_probability=0,apc.enable_cli=1,zend.assertions=1 - php-version: "${{ matrix.php }}" - tools: pecl - - - name: Display versions - run: | - php -r 'foreach (get_loaded_extensions() as $extension) echo $extension . " " . phpversion($extension) . PHP_EOL;' - php -i - - - name: Load fixtures - uses: docker://bitnami/openldap - with: - entrypoint: /bin/bash - args: -c "(/opt/bitnami/openldap/bin/ldapwhoami -H ldap://ldap:3389 -D cn=admin,dc=symfony,dc=com -w symfony||sleep 5) && /opt/bitnami/openldap/bin/ldapadd -H ldap://ldap:3389 -D cn=admin,dc=symfony,dc=com -w symfony -f src/Symfony/Component/Ldap/Tests/Fixtures/data/fixtures.ldif && /opt/bitnami/openldap/bin/ldapdelete -H ldap://ldap:3389 -D cn=admin,dc=symfony,dc=com -w symfony cn=a,ou=users,dc=symfony,dc=com" - - - name: Install dependencies - run: | - COMPOSER_HOME="$(composer config home)" - ([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json" - export COMPOSER_ROOT_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | grep -P -o '[0-9]+\.[0-9]+').x-dev - echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV - - echo "::group::composer update" - composer update --no-progress --ansi - echo "::endgroup::" - - echo "::group::install phpunit" - ./phpunit install - echo "::endgroup::" - - - name: Run tests - run: ./phpunit --group integration -v - env: - REDIS_HOST: 'localhost:16379' - REDIS_AUTHENTICATED_HOST: 'localhost:16380' - REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005' - REDIS_SENTINEL_HOSTS: 'unreachable-host:26379 localhost:26379 localhost:26379' - REDIS_SENTINEL_SERVICE: redis_sentinel - MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages - MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages - MESSENGER_SQS_DSN: "sqs://localhost:4566/messages?sslmode=disable&poll_timeout=0.01" - MESSENGER_SQS_FIFO_QUEUE_DSN: "sqs://localhost:4566/messages.fifo?sslmode=disable&poll_timeout=0.01" - KAFKA_BROKER: 127.0.0.1:9092 - POSTGRES_HOST: localhost - PGBOUNCER_HOST: localhost:6432 - - #- name: Run HTTP push tests - # if: matrix.php == '8.2' - # run: | - # [ -d .phpunit ] && mv .phpunit .phpunit.bak - # wget -q https://github.com/symfony/binary-utils/releases/download/v0.1/vulcain_0.1.3_Linux_x86_64.tar.gz -O - | tar xz && mv vulcain /usr/local/bin - # docker run --rm -e COMPOSER_ROOT_VERSION -v $(pwd):/app -v $(which composer):/usr/local/bin/composer -v $(which vulcain):/usr/local/bin/vulcain -w /app php:8.1-alpine ./phpunit src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php --filter testHttp2Push - # sudo rm -rf .phpunit - # [ -d .phpunit.bak ] && mv .phpunit.bak .phpunit - - - name: Check for changes in translation files - id: changed-translation-files - run: | - if git diff --quiet HEAD~1 HEAD -- 'src/**/Resources/translations/*.xlf'; then - echo "{changed}={true}" >> $GITHUB_OUTPUT - else - echo "{changed}={false}" >> $GITHUB_OUTPUT - fi - - - name: Check Translation Status - if: steps.changed-translation-files.outputs.changed == 'true' - run: | - php src/Symfony/Component/Translation/Resources/bin/translation-status.php -v diff --git a/.github/workflows/intl-data-tests.yml b/.github/workflows/intl-data-tests.yml deleted file mode 100644 index a02bd73ac5b8f..0000000000000 --- a/.github/workflows/intl-data-tests.yml +++ /dev/null @@ -1,108 +0,0 @@ -name: Intl/Emoji data - -on: - push: - paths: - - 'src/Symfony/Component/Emoji/*.php' - - 'src/Symfony/Component/Emoji/Resources/data/**' - - 'src/Symfony/Component/Emoji/Tests/*Test.php' - - 'src/Symfony/Component/Intl/*.php' - - 'src/Symfony/Component/Intl/Util/GitRepository.php' - - 'src/Symfony/Component/Intl/Resources/data/**' - - 'src/Symfony/Component/Intl/Tests/*Test.php' - - 'src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php' - pull_request: - paths: - - 'src/Symfony/Component/Emoji/*.php' - - 'src/Symfony/Component/Emoji/Resources/data/**' - - 'src/Symfony/Component/Emoji/Tests/*Test.php' - - 'src/Symfony/Component/Intl/*.php' - - 'src/Symfony/Component/Intl/Util/GitRepository.php' - - 'src/Symfony/Component/Intl/Resources/data/**' - - 'src/Symfony/Component/Intl/Tests/*Test.php' - - 'src/Symfony/Component/Intl/Tests/Util/GitRepositoryTest.php' - -defaults: - run: - shell: bash - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -permissions: - contents: read - -jobs: - tests: - name: Intl/Emoji data - runs-on: Ubuntu-20.04 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install system dependencies - run: | - echo "::group::apt-get update" - sudo apt-get update - echo "::endgroup::" - - echo "::group::install tools & libraries" - sudo apt-get install icu-devtools - echo "::endgroup::" - - - name: Define the ICU version - run: | - SYMFONY_ICU_VERSION=$(php -r 'require "src/Symfony/Component/Intl/Intl.php"; echo Symfony\Component\Intl\Intl::getIcuStubVersion();') - echo "SYMFONY_ICU_VERSION=$SYMFONY_ICU_VERSION" >> $GITHUB_ENV - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - coverage: "none" - extensions: "zip,intl-${{env.SYMFONY_ICU_VERSION}}" - ini-values: "memory_limit=-1" - php-version: "8.2" - - - name: Install dependencies - run: | - COMPOSER_HOME="$(composer config home)" - ([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json" - export COMPOSER_ROOT_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | grep -P -o '[0-9]+\.[0-9]+').x-dev - echo COMPOSER_ROOT_VERSION=$COMPOSER_ROOT_VERSION >> $GITHUB_ENV - - echo "::group::composer update" - composer update --no-progress --ansi - echo "::endgroup::" - - echo "::group::install phpunit" - ./phpunit install - echo "::endgroup::" - - - name: Report the ICU version - run: uconv -V && php -i | grep 'ICU version' - - - name: Run intl-data tests - run: ./phpunit --group intl-data -v - - - name: Test intl-data with compressed data - run: | - [ -f src/Symfony/Component/Intl/Resources/data/locales/en.php ] - [ ! -f src/Symfony/Component/Intl/Resources/data/locales/en.php.gz ] - src/Symfony/Component/Intl/Resources/bin/compress - [ ! -f src/Symfony/Component/Intl/Resources/data/locales/en.php ] - [ -f src/Symfony/Component/Intl/Resources/data/locales/en.php.gz ] - ./phpunit src/Symfony/Component/Intl - - - name: Run Emoji tests - run: ./phpunit src/Symfony/Component/Emoji -v - - - name: Test Emoji with compressed data - run: | - [ -f src/Symfony/Component/Emoji/Resources/data/emoji-en.php ] - [ ! -f src/Symfony/Component/Emoji/Resources/data/emoji-en.php.gz ] - src/Symfony/Component/Emoji/Resources/bin/compress - [ ! -f src/Symfony/Component/Emoji/Resources/data/emoji-en.php ] - [ -f src/Symfony/Component/Emoji/Resources/data/emoji-en.php.gz ] - ./phpunit src/Symfony/Component/Emoji diff --git a/.github/workflows/package-tests.yml b/.github/workflows/package-tests.yml deleted file mode 100644 index bc6f8eec683c7..0000000000000 --- a/.github/workflows/package-tests.yml +++ /dev/null @@ -1,143 +0,0 @@ -name: Verify Packages - -on: - pull_request: - paths: - - src/** - -permissions: - contents: read - -jobs: - verify: - name: Verify Packages - runs-on: Ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Fetch branch from where the PR started - run: git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* - - - name: Find packages - id: find-packages - run: echo "packages=$(php .github/get-modified-packages.php $(find src/Symfony -mindepth 2 -type f -name composer.json -printf '%h\n' | grep -v src/Symfony/Component/Emoji/Resources/bin |jq -R -s -c 'split("\n")[:-1]') $(git diff --name-only origin/${{ github.base_ref }} HEAD | grep src/ | jq -R -s -c 'split("\n")[:-1]'))" >> $GITHUB_OUTPUT - - - name: Verify meta files are correct - run: | - ok=0 - - _file_exist() { - if [ ! -f "${1}" ]; then - echo "File ${1} does not exist" - return 1 - fi - } - - _file_not_exist() { - if [ -f "${1}" ]; then - echo "File ${1} should not be here" - return 1 - fi - } - - _correct_license_file() { - FIRST_LINE="Copyright (c) $(date +"%Y")-present Fabien Potencier" - PACKAGE_FIRST_LINE=$(head -1 ${1}) - if [[ "$FIRST_LINE" != "$PACKAGE_FIRST_LINE" ]]; then - echo "First line of the license file is wrong. Maybe it is the wrong year?" - return 1 - fi - - TEMPLATE=$(tail -n +2 LICENSE) - PACKAGE_LICENSE=$(tail -n +2 ${1}) - if [[ "$TEMPLATE" != "$PACKAGE_LICENSE" ]]; then - echo "Wrong content in license file" - return 1 - fi - } - - json='${{ steps.find-packages.outputs.packages }}' - for package in $(echo "${json}" | jq -r '.[] | @base64'); do - _jq() { - echo ${package} | base64 --decode | jq -r ${1} - } - - DIR=$(_jq '.directory') - NAME=$(_jq '.name') - echo "::group::$NAME" - TYPE=$(_jq '.type') - localExit=0 - - if [ $TYPE != 'contract' ] && [ $TYPE != 'contracts' ]; then - _file_exist $DIR/.gitattributes || localExit=1 - fi - _file_exist $DIR/.gitignore || localExit=1 - _file_exist $DIR/CHANGELOG.md || localExit=1 - _file_exist $DIR/LICENSE || localExit=1 - if [ $TYPE != 'contract' ]; then - _file_exist $DIR/phpunit.xml.dist || localExit=1 - fi - _file_exist $DIR/README.md || localExit=1 - _file_not_exist $DIR/phpunit.xml || localExit=1 - - if [ $(_jq '.new') == true ]; then - echo "Verifying new package" - _correct_license_file $DIR/LICENSE || localExit=1 - - if [ $TYPE != 'component_bridge' ]; then - if [ ! $(cat composer.json | jq -e ".replace.\"$NAME\"|test(\"self.version\")") ]; then - echo "Composer.json's replace section needs to contain $NAME" - localExit=1 - fi - fi - fi - - ok=$(( $localExit || $ok )) - echo ::endgroup:: - if [ $localExit -ne 0 ]; then - echo "::error::$NAME failed" - fi - done - - exit $ok - - name: Verify symfony/deprecation-contracts requirements - run: | - set +e - - ok=0 - json='${{ steps.find-packages.outputs.packages }}' - for package in $(echo "${json}" | jq -r '.[] | @base64'); do - _jq() { - echo ${package} | base64 --decode | jq -r ${1} - } - - NAME=$(_jq '.name') - if [[ $NAME = 'symfony/deprecation-contracts' || $NAME = 'symfony/contracts' ]]; then - continue - fi - - echo "::group::$NAME" - DIR=$(_jq '.directory') - localExit=0 - grep -rq 'trigger_deprecation(' --include=*.php --exclude-dir=Tests/ --exclude-dir=Bridge/ $DIR - triggersDeprecation=$? - if [[ $triggersDeprecation -eq 0 && $(_jq '.requires_deprecation_contracts') == false ]]; then - errorMessage="::error::$NAME does not require symfony/deprecation-contracts but triggers at least one deprecation" - localExit=1 - elif [[ $triggersDeprecation -eq 1 && $(_jq '.requires_deprecation_contracts') == true ]]; then - errorMessage="::error::$NAME requires symfony/deprecation-contracts but does not trigger any deprecation" - localExit=1 - elif [[ $triggersDeprecation -ne 0 && $triggersDeprecation -ne 1 ]]; then - echo "::error::grep failed" - exit 2 - fi - - ok=$(( $localExit || $ok )) - echo ::endgroup:: - if [ $localExit -ne 0 ]; then - echo $errorMessage - fi - done - - exit $ok diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml deleted file mode 100644 index f367420f6cd38..0000000000000 --- a/.github/workflows/unit-tests.yml +++ /dev/null @@ -1,241 +0,0 @@ -name: Unit Tests - -on: - push: - pull_request: - -defaults: - run: - shell: bash - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -permissions: - contents: read - -jobs: - - tests: - name: Unit Tests - - env: - extensions: amqp,apcu,igbinary,intl,mbstring,memcached,redis,relay - - strategy: - matrix: - include: - - php: '8.2' - - php: '8.2' - mode: high-deps - - php: '8.2' - mode: low-deps - - php: '8.3' - - php: '8.4' - #mode: experimental - fail-fast: false - - runs-on: ubuntu-20.04 - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - coverage: "none" - ini-values: date.timezone=UTC,memory_limit=-1,default_socket_timeout=10,session.gc_probability=0,apc.enable_cli=1,zend.assertions=1 - php-version: "${{ matrix.php }}" - extensions: "${{ env.extensions }}" - tools: flex - - - name: Configure environment - run: | - git config --global user.email "" - git config --global user.name "Symfony" - git config --global init.defaultBranch main - git config --global advice.detachedHead false - - (php --ri relay 2>&1 > /dev/null) || sudo rm -f /etc/php/*/cli/conf.d/20-relay.ini - - COMPOSER_HOME="$(composer config home)" - ([ -d "$COMPOSER_HOME" ] || mkdir "$COMPOSER_HOME") && cp .github/composer-config.json "$COMPOSER_HOME/config.json" - - echo COLUMNS=120 >> $GITHUB_ENV - echo PHPUNIT="$(pwd)/phpunit --exclude-group tty,benchmark,intl-data,integration" >> $GITHUB_ENV - echo COMPOSER_UP='composer update --no-progress --ansi'$([[ "${{ matrix.mode }}" != low-deps ]] && echo ' --ignore-platform-req=php+') >> $GITHUB_ENV - - SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V) - SYMFONY_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | cut -d "'" -f2 | cut -d '.' -f 1-2) - SYMFONY_FEATURE_BRANCH=$(curl -s https://raw.githubusercontent.com/symfony/recipes/flex/main/index.json | jq -r '.versions."dev-name"') - - # Install the phpunit-bridge from a PR if required - # - # To run a PR with a patched phpunit-bridge, first submit the patch for the - # phpunit-bridge as a separate PR against the next feature-branch then - # uncomment and update the following line with that PR number - #SYMFONY_PHPUNIT_BRIDGE_PR=32886 - - if [[ $SYMFONY_PHPUNIT_BRIDGE_PR ]]; then - git fetch --depth=2 origin refs/pull/$SYMFONY_PHPUNIT_BRIDGE_PR/head - git rm -rq src/Symfony/Bridge/PhpUnit - git checkout -q FETCH_HEAD -- src/Symfony/Bridge/PhpUnit - SYMFONY_PHPUNIT_BRIDGE_REF=$(curl -s https://api.github.com/repos/symfony/symfony/pulls/$SYMFONY_PHPUNIT_BRIDGE_PR | jq -r .base.ref) - sed -i 's/"symfony\/phpunit-bridge": ".*"/"symfony\/phpunit-bridge": "'$SYMFONY_PHPUNIT_BRIDGE_REF'.x@dev"/' composer.json - rm -rf .phpunit - fi - - # Create local composer packages for each patched components and reference them in composer.json files when cross-testing components - if [[ ! "${{ matrix.mode }}" = *-deps ]]; then - php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit - else - echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV - cp composer.json composer.json.orig - echo -e '{\n"require":{'"$(grep phpunit-bridge composer.json)"'"php":"*"},"minimum-stability":"dev"}' > composer.json - php .github/build-packages.php HEAD^ $SYMFONY_VERSION $(find src/Symfony -mindepth 2 -type f -name composer.json -printf '%h\n' | grep -v src/Symfony/Component/Emoji/Resources/bin) - mv composer.json composer.json.phpunit - mv composer.json.orig composer.json - fi - if [[ $SYMFONY_PHPUNIT_BRIDGE_PR ]]; then - git rm -fq -- src/Symfony/Bridge/PhpUnit/composer.json - git diff --staged -- src/Symfony/Bridge/PhpUnit/ | git apply -R --index - fi - - # For the highest branch, in high-deps mode, the version before it is checked out and tested with the locally patched components - if [[ "${{ matrix.mode }}" = high-deps && $SYMFONY_VERSION = $(echo "$SYMFONY_VERSIONS" | tail -n 1 | sed s/.//) ]]; then - echo FLIP='^' >> $GITHUB_ENV - SYMFONY_VERSION=$(echo "$SYMFONY_VERSIONS" | grep -FB1 /$SYMFONY_VERSION | head -n 1 | sed s/.//) - git fetch --depth=2 origin $SYMFONY_VERSION - git checkout -m FETCH_HEAD - echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -printf '%h ') >> $GITHUB_ENV - fi - - # Skip the phpunit-bridge on bugfix-branches when not in *-deps mode - if [[ ! "${{ matrix.mode }}" = *-deps && $SYMFONY_VERSION != $SYMFONY_FEATURE_BRANCH ]]; then - echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -not -wholename '*/Bridge/PhpUnit/*' | xargs -I{} dirname {}) >> $GITHUB_ENV - else - echo COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist | xargs -I{} dirname {}) >> $GITHUB_ENV - fi - - # Legacy tests are skipped when deps=high and when the current branch version has not the same major version number as the next one - [[ "${{ matrix.mode }}" = high-deps && $SYMFONY_VERSION = *.4 ]] && echo LEGACY=,legacy >> $GITHUB_ENV || true - - echo SYMFONY_VERSION=$SYMFONY_VERSION >> $GITHUB_ENV - echo COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev >> $GITHUB_ENV - echo SYMFONY_REQUIRE=">=$([ '${{ matrix.mode }}' = low-deps ] && echo 5.4 || echo $SYMFONY_VERSION)" >> $GITHUB_ENV - [[ "${{ matrix.mode }}" = *-deps ]] && mv composer.json.phpunit composer.json || true - - if [[ "${{ matrix.mode }}" = low-deps ]]; then - echo SYMFONY_PHPUNIT_REQUIRE="nikic/php-parser:^4.18" >> $GITHUB_ENV - fi - - - name: Install dependencies - run: | - echo "::group::composer update" - $COMPOSER_UP - echo "::endgroup::" - - echo "::group::install phpunit" - ./phpunit install - echo "::endgroup::" - - - name: Patch return types - if: "matrix.php == '8.2' && ! matrix.mode" - run: | - patch -sp1 < .github/expected-missing-return-types.diff - git add . - composer install -q --optimize-autoloader || composer install --optimize-autoloader - SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.2' php .github/patch-types.php - git checkout src/Symfony/Contracts/Service/ResetInterface.php - SYMFONY_PATCH_TYPE_DECLARATIONS='force=2&php=8.2' php .github/patch-types.php # ensure the script is idempotent - git checkout src/Symfony/Contracts/Service/ResetInterface.php - git diff --exit-code - - - name: Check return types - if: "matrix.php == '8.2' && ! matrix.mode" - run: | - php .github/patch-types.php lint - - - name: Run tests - run: | - _run_tests() { - local ok=0 - local title="$1$FLIP" - local start=$(date -u +%s) - OUTPUT=$(bash -xc "$2" 2>&1) || ok=$? - local end=$(date -u +%s) - - if [[ $ok -ne 0 ]]; then - printf "\n%-70s%10s\n" $title $(($end-$start))s - echo "$OUTPUT" - echo "Job exited with: $ok" - echo -e "\n::error::KO $title\\n" - else - printf "::group::%-68s%10s\n" $title $(($end-$start))s - echo "$OUTPUT" - echo -e "\n\\e[32mOK\\e[0m $title\\n\\n::endgroup::" - fi - - [[ "${{ matrix.mode }}" = experimental ]] || (exit $ok) - } - export -f _run_tests - - if [[ ! "${{ matrix.mode }}" = *-deps ]]; then - echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} '$PHPUNIT {}'" - - exit 0 - fi - - if [[ "${{ matrix.mode }}" = low-deps ]]; then - echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} 'cd {} && $COMPOSER_UP --prefer-lowest --prefer-stable && $PHPUNIT'" - - exit 0 - fi - - # matrix.mode = high-deps - echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} 'cd {} && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1 - - # get a list of the patched components (relies on .github/build-packages.php being called in the previous step) - PATCHED_COMPONENTS=$(git diff --name-only src/ | grep composer.json || true) - - # for 6.4 LTS, checkout and test previous major with the patched components (only for patched components) - if [[ $PATCHED_COMPONENTS && $SYMFONY_VERSION = 6.4 ]]; then - export FLIP='^' - SYMFONY_VERSION=$(echo $SYMFONY_VERSION | awk '{print $1 - 1}') - echo -e "\\n\\e[33;1mChecking out Symfony $SYMFONY_VERSION and running tests with patched components as deps\\e[0m" - export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev - export SYMFONY_REQUIRE=">=$SYMFONY_VERSION" - git fetch --depth=2 origin $SYMFONY_VERSION - git checkout -m FETCH_HEAD - PATCHED_COMPONENTS=$(echo "$PATCHED_COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort || true) - if [[ $PATCHED_COMPONENTS ]]; then - echo "::group::install phpunit" - ./phpunit install - echo "::endgroup::" - echo "$PATCHED_COMPONENTS" | parallel -j +3 "_run_tests {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1 - fi - fi - - [[ ! $X ]] || (exit 1) - - - name: Run TTY tests - if: "! matrix.mode" - run: | - script -e -c './phpunit --group tty' /dev/null - - - name: Run tests with SIGCHLD enabled PHP - if: "matrix.php == '8.2' && ! matrix.mode" - run: | - mkdir build - cd build - wget -q https://github.com/symfony/binary-utils/releases/download/v0.1/php-8.2.0-pcntl-sigchild.tar.bz2 - tar -xjf php-8.2.0-pcntl-sigchild.tar.bz2 - cd .. - - mkdir -p /opt/php/lib - echo memory_limit=-1 > /opt/php/lib/php.ini - ./build/php/bin/php ./phpunit --colors=always src/Symfony/Component/Process diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index a1b3a666138ca..53667a08a1b71 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -1812,7 +1812,7 @@ public function testReadFile() public function testReadNonExistentFile() { $this->expectException(IOException::class); - $this->expectExceptionMessageMatches('#^Failed to read file ".+/Tests/invalid"\\: file_get_contents\\(.+/Tests/invalid\\)\\: Failed to open stream\\: No such file or directory$#'); + $this->expectExceptionMessageMatches(sprintf('#^Failed to read file ".+%1$sTests/invalid"\\: file_get_contents\\(.+%1$sTests/invalid\\)\\: Failed to open stream\\: No such file or directory$#', '\\' === \DIRECTORY_SEPARATOR ? '\\\\' : '/')); $this->filesystem->readFile(__DIR__.'/invalid'); } @@ -1820,7 +1820,7 @@ public function testReadNonExistentFile() public function testReadDirectory() { $this->expectException(IOException::class); - $this->expectExceptionMessageMatches('#^Failed to read file ".+/Tests"\\: File is a directory\\.$#'); + $this->expectExceptionMessageMatches(sprintf('#^Failed to read file ".+%sTests"\\: File is a directory\\.$#', '\\' === \DIRECTORY_SEPARATOR ? '\\\\' : '/')); $this->filesystem->readFile(__DIR__); }