1
0
mirror of https://tildegit.org/sbgodin/HtmGem.git synced 2023-08-25 13:53:12 +02:00
HtmGem/tests/cli/pre-commit.git

28 lines
505 B
Plaintext
Raw Normal View History

2021-03-24 10:53:12 +01:00
#!/usr/bin/env php
<?php
/**
* This file is to be placed in ./.git/hooks
* and set as executable.
*
* It will perform tests before any commit.
* To override: git commit -n
*/
echo "Running tests…";
exec('phpunit tests', $output, $returnCode);
// Removes the first line
array_shift($output);
if ($returnCode !== 0) {
echo PHP_EOL . implode(PHP_EOL, $output) . PHP_EOL;
2021-03-24 10:53:12 +01:00
echo "Tests failed…" . PHP_EOL;
exit(1);
}
// Show summary (last line)
echo array_pop($output) . PHP_EOL;
exit(0);