#!/bin/sh

unset RC_TRACE_DYLIBS
unset RC_TRACE_ARCHIVES
unset LD_TRACE_DYLIBS
unset LD_TRACE_ARCHIVES

export DYLD_FALLBACK_LIBRARY_PATH=${DYLD_FALLBACK_LIBRARY_PATH}:/Developer/usr/lib
export MACOSX_DEPLOYMENT_TARGET=10.7
# cd into test-cases directory
cd `echo "$0" | sed 's/run-all-unit-tests/test-cases/'`

[ "$PROCTORRUN" ] && exec ../proctor-run

all_archs="x86_64  i386"
valid_archs="x86_64 i386"
# only test arm code if iOS platform tools installed
if [ -d /Developer/Platforms/iPhoneOS.platform/Developer/SDKs ]
then
    all_archs="${all_archs}  armv7"
    valid_archs="${valid_archs} armv7"
fi


# clean first
../bin/make-recursive.pl clean > /dev/null

mkdir /tmp/$$
for arch in $all_archs
do
	echo ""
	echo " * * * Running all unit tests for architecture $arch * * *"

	# build architecture
	[ "$NEWTEST" ] && NT=-newtest

	../bin/make-recursive$NT.pl ARCH=$arch VALID_ARCHS="$valid_archs" | ../bin/result-filter.pl

	# clean up so svn is happy
	../bin/make-recursive.pl ARCH=$arch clean > /dev/null

	echo ""
done
