-
-
Save josecelano/b4e956359659415074a7 to your computer and use it in GitHub Desktop.
A pre-commit for running PHPUnit
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 | |
printf("%sGit pre-commit hook %1\$s", PHP_EOL); | |
$projectName = basename(getcwd()); | |
exec('phpunit --configuration phpunit.xml', $output, $returnCode); // Assuming cwd here | |
if ($returnCode !== 0) { | |
$minimalTestSummary = array_pop($output); | |
printf("Test suite for %s failed: ", $projectName); | |
printf("( %s ) %s%2\$s", $minimalTestSummary, PHP_EOL); | |
return false; // exit(1); | |
} | |
printf("All tests for %s passed.%s%2\$s", $projectName, PHP_EOL); | |
return true; // exit(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment