Opened 7 months ago
Last modified 3 months ago
#57189 new defect (bug)
The PHP tests initialize very slowly in wp-env
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 6.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | |
Focuses: | Cc: |
Description
When run in wp-env (Docker), the PHP tests take very long time (over 30 seconds) to initialize. This is especially annoying/time wasting when running them multiple times.
Not sure if Docker or Composer is the cause, but I see this:
> WordPress@6.2.0 test:php /dev/wp/trunk > node ./tools/local-env/scripts/docker.js run -T php composer update -W && node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit Creating trunk_php_run ... done .................................... (waits here for about 30-35 seconds) Loading composer repositories with package information Info from https://repo.packagist.org: #StandWithUkraine Updating dependencies Nothing to modify in lock file Installing dependencies from lock file (including require-dev) Nothing to install, update or remove Generating autoload files 25 packages you are using are looking for funding. Use the `composer fund` command to find out more! Creating trunk_php_run ... done Installing... Running as single site... To run multisite, use -c tests/phpunit/multisite.xml ..... (rest of the PHPUnit output)
The problem seems to be that Composer is run every time to re-check the dependencies, i.e. the script there does the equivalent of npm i
every time before it starts PHPUnit. I understand the desire to keep things updated, but this is not productive.
Change History (4)
#2
@
7 months ago
Another thing is that if a PHPUnit test fails, the (npm/Docker) script fails too. Seems not a big problem but needs fixing nevertheless. Error is:
ERROR: 1 child_process.js:836 throw err; ^ Error: Command failed: docker-compose run php ./vendor/bin/phpunit
Seems an easy fix here would be to split the "Composer install" part from the actual "run PHPUnit" part in
npm run test:php
. Something like:A better way would be to have an equivalent of a lock file and run Composer only once per week.