Skip to content

Instantly share code, notes, and snippets.

@weierophinney
Created November 17, 2011 16:02
Show Gist options
  • Save weierophinney/1373526 to your computer and use it in GitHub Desktop.
Save weierophinney/1373526 to your computer and use it in GitHub Desktop.
#!/bin/bash
# -------------------------------------------------------------
# Run phpUnit tests for a subset of Zend Framework
# -------------------------------------------------------------
# Author: Enrico Zimuel (enrico@zend.com)
# -------------------------------------------------------------
ZFPATH="/home/matthew/git/zf-standard/tests"
PHP="/home/matthew/svn/phpfarm/inst/bin/php-5.2.17"
PHPUNIT="/home/matthew/Downloads/dev/phpunit-3.4/phpunit/phpunit.php"
PHPVER=`$PHP -v | head -n1 | sed 's/[^0-9.]*\([0-9.]*\).*/\1/'`
PHPUNITVER=`$PHP $PHPUNIT -v | head -n1 | sed 's/[^0-9.]*\([0-9.]*\).*/\1/'`
if [ "$1" = '' ]; then
echo "Usage: ./runtest.sh file [-o path]"
echo
echo "file = list of Zend classes to test (e.g. Config)"
echo "path = optional path for the phpUnit output"
exit 0
fi
if [ ! -e "$1" ]; then
echo "Error: file does not exists"
exit 1
fi
OUTDIR=`pwd`
if [ "$2" = "-o" -o "$2" = "-O" ]; then
if [ ! -d "$3" ]; then
echo "Error: output directory is not valid"
exit 1
fi
OUTDIR="$3"
fi
for line in $(cat "$1");
do
echo -n "Testing: $line..."
LOGFILE=${line//[^a-zA-z_.-]/_}
LOGFILE=${LOGFILE/%.php/}
(cd "$ZFPATH"; $PHP $PHPUNIT "Zend/$line" > "$OUTDIR/${LOGFILE}_php${PHPVER//./-}_unit${PHPUNITVER//./-}.test")
echo "done"
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment