Created
August 30, 2014 08:20
-
-
Save RyujiAMANO/b50f37c5388655e3cfe1 to your computer and use it in GitHub Desktop.
.git/hook/cakephp/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
#!/bin/bash -e | |
PROJECT=`pwd` | |
APP="" | |
PLUGIN="" | |
if [ ! -z `echo $PROJECT | egrep 'app/Plugin'` ] | |
then | |
APP=`echo $PROJECT | sed 's/\/\w\+\/\w\+\/\w\+$//'` | |
PLUGIN=`echo $PROJECT | sed 's/.*\/\(\w\+\)$/\1/'` | |
fi | |
FILES="" | |
for FILE in `git diff --cached --name-only --diff-filter=ACMR HEAD | egrep \\\\.\(php\)\$` | |
do | |
FILES="$FILES $PROJECT/$FILE" | |
done | |
if [ "$FILES" != "" ] | |
then | |
echo "Running phpunit..." | |
for TEST in `git diff --cached --name-only --diff-filter=ACMR HEAD | egrep -v "(Test\.php|ctp|js)$"` | |
do | |
echo $TEST | |
if [ -z `echo $TEST | egrep \\Test\\.\(php\)\$` ] | |
then | |
TEST=`echo $TEST | sed 's/\([a-zA-Z0-9\/]\+\)\.php/\1/g'` | |
else | |
TEST=`echo $TEST | sed 's/app\/Test\/Case\/\([a-zA-Z0-9\/]\+\)Test\.php/\1/g'` | |
fi | |
echo $TEST | |
if [ $PLUGIN != "" ] | |
then | |
cd $APP | |
./lib/Cake/Console/cake test $PLUGIN $TEST --stderr --configuration phpunit.xml.dist || exit $? | |
else | |
./lib/Cake/Console/cake test app $TEST --stderr --configuration phpunit.xml.dist || exit $? | |
fi | |
done | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment