Running PHPUnit via Phing on HHVM
For quite some time we run the unit tests for our libs and tools against PHP and HHVM, at least that is what I thought up to now. As it turns out I missed a minor detail. In our Jenkins job we invoke the Phing task like this:
hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 -v Eval.Jit=false "$WORKSPACE/vendor/bin/phing" -f "$WORKSPACE/build.xml" ci:build
What happens now is that Phing is executed via HHVM but PHPUnit will still be executed via the PHP binary because the PHPUnit shell script will look for the php binary in the PATH configuration. Since we run HHVM side-by-side with PHP on our Jenkins build nodes I was not able to point /usr/bin/php to /usr/bin/hhvm - which would be the easiest and cleanest solution. I had to come up with the following work-a-round:
export PATH="$WORKSPACE:$PATH" ln -s /usr/bin/hhvm "$WORKSPACE/php" hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 -v Eval.Jit=false "$WORKSPACE/vendor/bin/phing" -f "$WORKSPACE/build.xml" ci:build rm "$WORKSPACE/php"
Before running Phing a php symlink pointing to /usr/bin/hhvm gets created in the current Jenkins workspace directory. In addition to that the directory is added to the PATH environment variable (as the first entry. This is important!). When PHPUnit now tries to find a php binary it will find the one in the current Jenkins workspace directory which in fact is the hhvm binary and will run against it. After running Phing the symlink gets removed just to be on the safe side.