Question

I have the following build.xml file setup in phpUnderControl.

    <target name="phpunit">
    <exec executable="phpunit" dir="${basedir}/httpdocs" failonerror="on">
        <arg line="--log-junit ${basedir}/build/logs/phpunit.xml
                --coverage-clover ${basedir}/build/logs/phpunit.coverage.xml
                --coverage-html ${basedir}/build/coverage
                --colors
                ${basedir}/httpdocs/qc/unit/CalculatorTest.php" />
    </exec>
</target>

For some unkown reason the build always fails with the below message.

phpunit:
 [exec] PHPUnit 3.4.15 by Sebastian Bergmann.
 [exec] 

BUILD FAILED
/opt/cruisecontrol-bin-2.8.3/projects/citest.local/build.xml:30: exec returned: 255

I have run the very simple unit test manually within the unit directory and PHPUnit returns.

PHPUnit 3.4.15 by Sebastian Bergmann.

.

Time: 0 seconds, Memory: 5.25Mb

OK (1 test, 1 assertion)

Does anyone know why it keeps failing the build, when all the tests are fine?

My build script does have a clean method which removes and log files, so its not that. I have also manually removed the log files, just in case it's that script. And changed the owner of the log directories so they are writable.

If it makes any difference the phpunit.xml is empty after PHPUnit is run.

Thanks.

UPDATE: Incidentally if I remove failonerror="on" it works, obviously, but PHPUnit still returns 255 and I do want it to fail on any errors, the issue is there isn't any errors yet it still fails!

Était-ce utile?

La solution

255 is the error code that PHP throws on fatal and (I think) parse errors.

Could there be a fatal or parse error in the script execution, maybe after the tests have run?

Any PHP errors? What happens if you add error_reporting(E_ALL); ?

Autres conseils

Probably the 'exec returned: 255' is caused by the memory consumption of the CodeCoverage report, which will be displayed after enabling error_reporting(E_ALL) like Pekka mentioned. Try init_set('display_errors','on'); also. Usualy you will face a 'memory size ...exhaused' fatal.

In my case, it turned out to be that I didn't have a webserver installed. Installing nginx and setting it up as a webserver (even if I'm not using it) fixed the problem.

it might be caused by some empty testsuite in phpunit.xml, that is, no assertXXX in test code

I got Selenium, PHPUnit, PHPUnderControl, and CruiseControl all working together (here http://www.siteconsortium.com/h/p1.php?id=php002)

Just a very basic example but I was able to get it to work like this. Start from something simple and copy the other stuff back in.

<?xml version="1.0" encoding="UTF-8"?>
<project name="test" default="build" basedir=".">

<target name="build">
  <exec executable="C:\\PHP\\phpunit.bat" dir="C:\\workspace\\proj\\phpunit" failonerror="on">
     <arg line="--log-junit C:\\workspace\\proj\\build\\logs\\phpunit.xml
           --configuration C:\\workspace\\proj\\phpunit.xml
           --include-path C:\\trunk\\includes C:\\workspace\\proj\\includes" />
     </exec>
  </target>
</project>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top