3

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!

Gcoop
  • 3,372
  • 4
  • 26
  • 35

5 Answers5

6

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); ?

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • Error reporting is on, but I added that func call anyway and nothing additional is output either via executing PHPUnit directly or via phpUnderControl, using the ant. – Gcoop Jul 23 '10 at 15:48
  • 1
    @Gcoop strange. Display_errors is on as well? Does ant pass through stdout/stderr output by the programs it runs? Maybe redirect logging into a file just to see whether errors are swallowed somewhere? (Can be done in php.ini) – Pekka Jul 23 '10 at 15:51
  • Spot on thank you, display_errors was switched off in php.ini :( so silly. Output now shows me what the problem is! It's to do with the unit test not being able to find the file its testing, thanks so much. – Gcoop Jul 23 '10 at 15:57
1

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.

Echilon
  • 10,064
  • 33
  • 131
  • 217
mmm
  • 11
  • 1
0

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

biegleux
  • 13,179
  • 11
  • 45
  • 52
Feng
  • 2,872
  • 3
  • 23
  • 20
0

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>
JTHouseCat
  • 445
  • 4
  • 4
0

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.

Rafael Fonseca
  • 161
  • 1
  • 13