Last active
September 24, 2015 18:56
-
-
Save androzd/98c9736607d7d2c69b20 to your computer and use it in GitHub Desktop.
git pre-commit hook for symfony2. Runs phpunit test, before commit.
This file contains hidden or 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/php | |
| <?php | |
| echo PHP_EOL."\033[43mStarting unit tests\033[0m".PHP_EOL; | |
| exec('phpunit -c app', $output, $returnCode); | |
| if ($returnCode !== 0) | |
| { | |
| while (($minimalTestSummary = array_pop($output)) !== null) | |
| { | |
| if (strpos($minimalTestSummary, 'Tests:') !== false) | |
| { | |
| break; | |
| } | |
| } | |
| echo "\033[41m+ Test suite for project failed:\033[0m".PHP_EOL; | |
| echo $minimalTestSummary; | |
| echo "\033[0m".PHP_EOL; | |
| echo PHP_EOL; | |
| exit(1); | |
| } | |
| echo "\033[42mAll tests for project passed.\033[0m".PHP_EOL.PHP_EOL; | |
| exit(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment