Skip to content

Instantly share code, notes, and snippets.

@rayward
Last active December 31, 2015 17:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rayward/8017758 to your computer and use it in GitHub Desktop.
Save rayward/8017758 to your computer and use it in GitHub Desktop.
phpunit segfault detection wrapper
#!/bin/bash
# PHP's garbage collector on occasion segfaults upon shutdown.
# This script detects a successful build by looking for 'OK' and then terminates successfully.
set -o pipefail
testcommand="vendor/bin/phpunit -dmemory_limit=-1 --stderr --configuration $1"
$testcommand 2>&1 | sudo tee phpunit-output
phpunit_success=$?
if [ $phpunit_success -gt 0 ]; then
echo -e "\nThe command \"$testcommand\" exited with $phpunit_success"
fi
output=$(cat phpunit-output)
if [[ $output =~ $'\n'$'\n'OK ]] ; then
exit 0
else
exit $phpunit_success
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment