Last active
November 2, 2020 22:14
-
-
Save paulund/20aa6fa2815ceb6cee0b24794eb0d1c6 to your computer and use it in GitHub Desktop.
Run phpunit tests before push and error if the tests fail
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
#!/bin/bash | |
git diff --cached --name-only | while read FILE; do | |
if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then | |
echo "Running tests..." | |
cd "${0%/*}/.." | |
phpunit 1> /dev/null | |
if [ $? -ne 0 ]; then | |
echo -e "\e[1;31m\tUnit tests failed ! Aborting commit.\e[0m" >&2 | |
exit 1; | |
fi | |
fi | |
done || exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment