Skip to content

Commit

Permalink
[Tests] Improvements in the script
Browse files Browse the repository at this point in the history
* Add support for phpunit.xml when is available
* Add to the test suite individual test files present in /tests/Zend/ (only when 'all' option is used)
* Remove from the test suite the files and/or directories marked as excluded in phpunit conf (only when 'all' option is used)
  • Loading branch information
Maks3w committed May 31, 2012
1 parent 7157cc5 commit 91f340b
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions tests/runtests.sh
Expand Up @@ -30,7 +30,12 @@


: ${BASEDIR:=$(dirname $0)} : ${BASEDIR:=$(dirname $0)}
: ${PHPUNIT:="phpunit"} : ${PHPUNIT:="phpunit"}
: ${PHPUNIT_OPTS:="-c $BASEDIR/phpunit.xml.dist"} : ${PHPUNIT_CONF:="$BASEDIR/phpunit.xml.dist"}
if [ -e "$BASEDIR/phpunit.xml" ]
then
PHPUNIT_CONF="$BASEDIR/phpunit.xml"
fi
: ${PHPUNIT_OPTS:="-c $PHPUNIT_CONF"}
: ${PHPUNIT_GROUPS:=""} : ${PHPUNIT_GROUPS:=""}
: ${RUN_AS_GROUPS:=false} : ${RUN_AS_GROUPS:=false}
: ${RESULT:=0} : ${RESULT:=0}
Expand All @@ -54,10 +59,23 @@ while [ -n "$1" ] ; do
then then
PHPUNIT_GROUPS="" PHPUNIT_GROUPS=""
else else
# Add every component present in /library/
for i in $(ls -d ${BASEDIR}/../library/Zend/*/) for i in $(ls -d ${BASEDIR}/../library/Zend/*/)
do do
PHPUNIT_GROUPS="${PHPUNIT_GROUPS:+"$PHPUNIT_GROUPS "}${BASEDIR}/Zend/$(basename $i)" PHPUNIT_GROUPS="${PHPUNIT_GROUPS:+"$PHPUNIT_GROUPS "}${BASEDIR}/Zend/$(basename $i)"
done done

# Add individual test files present in /tests/Zend
for i in $(ls ${BASEDIR}/Zend/*Test.php)
do
PHPUNIT_GROUPS="${PHPUNIT_GROUPS:+"$PHPUNIT_GROUPS "}${BASEDIR}/Zend/$(basename $i)"
done

# Exclude files/directories excluded in phpunit.xml.dist or phpunit.xml (if available)
for i in $(grep "<exclude>.*</exclude>" $PHPUNIT_CONF | sed 's#.*<exclude>./Zend/\(.*\)</exclude>.*#\1#')
do
PHPUNIT_GROUPS=${PHPUNIT_GROUPS//${BASEDIR}\/Zend\/${i}/}
done
fi fi
break ;; break ;;


Expand Down Expand Up @@ -86,18 +104,18 @@ done
set -x set -x
if ${RUN_AS_GROUPS:=true} if ${RUN_AS_GROUPS:=true}
then then
${PHPUNIT} ${PHPUNIT_OPTS} ${PHPUNIT_COVERAGE} ${PHPUNIT_DB} \ ${PHPUNIT} ${PHPUNIT_OPTS} ${PHPUNIT_COVERAGE} ${PHPUNIT_DB} \
${PHPUNIT_GROUPS:+--group $PHPUNIT_GROUPS} ${PHPUNIT_GROUPS:+--group $PHPUNIT_GROUPS}
RESULT=$? RESULT=$?
else else
# Replace commas with spaces and underscores with slashes # Replace commas with spaces and underscores with slashes
PHPUNIT_GROUPS=${PHPUNIT_GROUPS//,/ } PHPUNIT_GROUPS=${PHPUNIT_GROUPS//,/ }
PHPUNIT_GROUPS=${PHPUNIT_GROUPS//_//} PHPUNIT_GROUPS=${PHPUNIT_GROUPS//_/\/}
for i in ${PHPUNIT_GROUPS} for i in ${PHPUNIT_GROUPS}
do do
${PHPUNIT} ${PHPUNIT_OPTS} ${PHPUNIT_COVERAGE} ${PHPUNIT_DB} $i ${PHPUNIT} ${PHPUNIT_OPTS} ${PHPUNIT_COVERAGE} ${PHPUNIT_DB} $i
RESULT=$(($RESULT || $?)) RESULT=$(($RESULT || $?))
done done
fi fi


exit $RESULT exit $RESULT

0 comments on commit 91f340b

Please sign in to comment.