Permalink
Browse files

Ensure we can run runtests.sh out of the box on a Mac

  • Loading branch information...
1 parent 10eee4f commit 0312cb9129d9812c523487233b5893ee7b9988f9 @punkstar punkstar committed Jan 3, 2012
Showing with 33 additions and 1 deletion.
  1. +33 −1 runtests.sh
View
34 runtests.sh 100644 → 100755
@@ -26,4 +26,36 @@
# @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
#
-phpunit --configuration $(dirname $(readlink -f $0))/phpunit.xml
+OS=`uname -s`
+
+if [ "$OS" = "Darwin" ]
+then
+ # We don't have `readlink -f` on OS X, so we roll our own, courtesy of:
+ # http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac
+ cd `dirname $0`
+ TARGET_FILE=`basename $0`
+
+ # Iterate down a (possible) chain of symlinks
+ while [ -L "$TARGET_FILE" ]
+ do
+ TARGET_FILE=`readlink $TARGET_FILE`
+ cd `dirname $TARGET_FILE`
+ TARGET_FILE=`basename $TARGET_FILE`
+ done
+
+ # Compute the canonicalized name by finding the physical path
+ # for the directory we're in and appending the target file.
+ ABSPATH=`pwd -P`
+else
+ ABSPATH=`dirname $(readlink -f $0)`
+fi
+
+CONFIG=$ABSPATH/phpunit.xml
+
+if [ -e $CONFIG ]
+then
+ phpunit --configuration $CONFIG
+else
+ echo "Error: The file $CONFIG doesn't exist."
+ exit 1
+fi

0 comments on commit 0312cb9

Please sign in to comment.