WordPress / phpunit-test-runner

GNU General Public License v2.0
66 stars 63 forks source link

junit.xml is not generated #218

Open benniledl opened 5 months ago

benniledl commented 5 months ago

The junit.xml file is not generated and thus I cannot report the results back to wp.org

root@host50:/var/home/user/wp-tests/phpunit-test-runner# php report.php
Environment variables pass checks.
Getting SVN Revision
fatal: Not a git repository: '/var/home/user/wp-tests/tmp/.git'
Getting SVN message
fatal: Not a git repository: '/var/home/user/wp-tests/tmp/.git'
Copying junit.xml results
rsync -rv '/var/home/user/wp-tests/tmp'/tests/phpunit/build/logs/* '/var/home/user/wp-tests/tmp'
sending incremental file list
rsync: change_dir "/var/home/user/wp-tests/tmp/tests/phpunit/build/logs" failed: No such file or directory (2)

rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.1]
sent 20 bytes  received 12 bytes  64.00 bytes/sec
total size is 0  speedup is 0.00
Error: Failed to perform operation.
benniledl commented 5 months ago

different log verbosity

root@host50:/var/home/user/wp-tests/phpunit-test-runner# php report.php
Environment variables pass checks.
Getting SVN Revision
Getting SVN message
Copying junit.xml results
rsync -rv '/var/home/user/wp-tests/wp-env'/tests/phpunit/build/logs/* '/var/home/user/wp-tests/wp-env'
sending incremental file list
env.json

sent 1,964 bytes  received 35 bytes  3,998.00 bytes/sec
total size is 1,872  speedup is 0.94
Processing and uploading junit.xml

Warning: file_get_contents(/var/home/user/wp-tests/wp-env/junit.xml): Failed to open stream: No such file or directory in /var/home/user/wp-tests/phpunit-test-runner/report.php on line 124
Error: Error uploading results: Invalid parameter(s): results (HTTP status 400)
Tuomas-dev commented 4 months ago

Same issue affecting us as well. Tested in few different environments with the actual test passing without errors.

bgturner commented 3 months ago

I just tried this on my local computer and experience the same results. When I look at the location that the readme indicates should hold the junit.xml file, the only thing I see is the env.json:

★ trunk* build/logs % pwd
/tmp/wp-test-runner/tests/phpunit/build/logs
★ trunk* build/logs % ls -alh
total 16
drwxr-xr-x@ 3 ben.turner  wheel    96B Jun 26 07:59 .
drwxr-xr-x@ 3 ben.turner  wheel    96B Jun 26 07:59 ..
-rw-r--r--@ 1 ben.turner  wheel   5.7K Jun 26 08:24 env.json

Looking closer at the test.php file, I think it might have something to do with generating a shell command in PHP and how the args are escaped:

https://github.com/wordpress/phpunit-test-runner/blob/master/test.php#L74

As a test, I changed the WPT_FLAVOR variable in the .env file from 1 to 0 and re-ran the tests. This correctly generated the `junit.xml file.

https://github.com/wordpress/phpunit-test-runner/blob/master/.env.default#L71

★ trunk* /tmp/wp-test-runner % ls tests/phpunit/build/logs
env.json  junit.xml

I can't tinker on this more at the moment, but my gut says the way that the WPT_PHPUNIT_CMD variable is built up needs some work.

benniledl commented 1 week ago

this should fix it: https://github.com/WordPress/wordpress-develop/commit/592dd4f7566fe24050a3c1fa5c5618ca4e873d0d

@bgturner @javiercasares @Tuomas-dev