views:

62

answers:

1

Hi All,

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!

+1  A: 

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
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
@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
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