Created
February 17, 2017 09:00
-
-
Save oqq/c7c2a7ae509206e762dc58afaa360bff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php declare(strict_types=1); | |
$projectName = basename(getcwd()); | |
echo <<<EOT | |
+ Starting unit tests for \033[1m\033[37;44m ${projectName} \033[0m. | |
EOT; | |
exec('vendor/bin/phpunit', $output, $returnCode); | |
if (0 === $returnCode) { | |
echo <<<EOT | |
+ All tests \033[1m\033[47;42m passed \033[0m. | |
+ Proceeding with commit. Have a nice day. | |
EOT; | |
exit(0); | |
} | |
while (null !== ($summary = array_pop($output))) { | |
if (false !== strpos($summary, 'Tests:')) { | |
break; | |
} | |
} | |
echo <<<EOT | |
+ Test suite \033[1m\033[47;41m failed \033[0m: | |
$summary\033[0m | |
+ \033[1m\033[47;41m ABORTING COMMIT \033[0m | |
EOT; | |
exit($returnCode); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment