PHPUnit / Process finished with exit code 0 / Interpreter Options / Before launch
Since 2018.2 (#PS-182.3684.42) we have had an issue with phpunit in PhpStorm.
Before running phpunit we need to execute a script that generates a phpunit.xml file that is going to be used for the run.
In order to do so we have been using the 'Interpreter options' field to execute a script that generates the phpunit.xml.
It's maybe not the most elegant solution, but it's been working fine for us until upgrading to 2018.2. Our run configuration look like this:
Use alternative configuration file: /home/user/project/phpunit.xml
Test Runner options: --testsuite auto
Interpreter options: build-phpunit-xml.php --source phpunit.custom.xml --target phpunit.xml &&
Custom working directory: /home/users/project
This leads to the executing of this command:
vagrant:///home/user/project/usr/bin/php build-phpunit-xml.php --source phpunit.custom.xml --target phpunit.xml && /var/www/project/vendor/phpunit/phpunit/phpunit --testsuite auto --configuration /var/www/project/phpunit.xml
Which as mention has been working fine up until 2018.2. The same output is shown in 2010.2 except that when the build-phpunit-xml.php has been executed the run fails with "Test framework quit unexpectedly" and with the exit code 0.
vagrant:///home/user/project/usr/bin/php build-phpunit-xml.php --source phpunit.custom.xml --target phpunit.xml && /var/www/project/vendor/phpunit/phpunit/phpunit --testsuite auto --configuration /var/www/project/phpunit.xml
Process finished with exit code 0
Comparing the .idea.log in 2018.1 and 2018.2 did reveal that since 2018.2 every parameter is now enclosed with single quotes:
2018.1:
cd /var/www/project; env "JETBRAINS_REMOTE_RUN"="1" "IDE_PHPUNIT_CUSTOM_LOADER"="/var/www/project/vendor/autoload.php" /usr/bin/php build-phpunit-xml.php --source phpunit.custom.xml --target phpunit.xml && /var/www/project/vendor/phpunit/phpunit/phpunit --testsuite auto --configuration /var/www/project/phpunit.xml --teamcity
2018.2:
cd /var/www/project; env "JETBRAINS_REMOTE_RUN"="1" "IDE_PHPUNIT_CUSTOM_LOADER"="/var/www/project/vendor/autoload.php" '/usr/bin/php' 'build-phpunit-xml.php' '--source' 'phpunit.custom.xml' '--target' 'phpunit.xml' '&&' '/var/www/project/vendor/phpunit/phpunit/phpunit' '--testsuite' 'auto' '--configuration' '/var/www/project/phpunit.xml' '--teamcity'
If I run the command generated by 2018.1 manually inside the vagrant environment it is executed correctly.
If I use the command generated by 2018.2 it stops after the build-phpunit-xml.php script has been executed. Unquoting the && makes the command continue with phpunit after build-phpunit-xml.php has been executed.
I've tried to modify the 'Interpreter options' in several ways from enclosing the whole command with double quotes and trying to escape the single quotes, but nothing works.
It's worth mention that I also tried using a 'Before launch' configuration where I added a 'Run Remote External tool' that executed the build-phpunit-xml.php script on the remote server, but this solution did not work neither on 2018.1 or 2018.2. It will execute the script, but will not start phpunit afterwards.
The output of this solution is the same on both 2018.1 and 2018.2:
ssh://vagrant@127.0.0.1:222/usr/bin/php build-phpunit-xml.php --source phpunit.custom.xml --target phpunit.xml
Process finished with exit code 0
I think that the behavior of the 'Before launch' is somewhat broken, because in my head it should execute phpunit once the 'Before launch' instructions has been completed.
Any ideas or help is very much appreciated. For now I'll just continue using 2018.1.
请先登录再写评论。
The
Interpreter optionsfield is definitely not intended to be used this way.Before launchis a way to go here.We need to understand why it doesn't start the tests for you. Please record a screencast similar to mine: http://recordit.co/t9Xc18VdvU
Please have a look at the following screencast.
At you can see, once the Before launch job has been executed, nothing else happens.
Sorry for the lack of response. Could you please check if behavior is the same in PhpStorm 2018.3.2?
Yes, it's still present in PhpStorm 2018.3.5.
In my case I tried to execute something before running node.js app, but putting any remote external tool (via vagrant connection) in 'before' section results in this message:
`External tool 'something' completed with exit code 0`
And nothing else is going on, the app doesn't start.
Also, this problem was already reported few years ago:
https://youtrack.jetbrains.com/issue/IDEA-144799
Thanks for sharing the report.
Unfortunately there are no updates from a corresponding developer.