#!/bin/sh

# cd into test-cases directory
cd `echo "$0" | sed 's/run-all-unit-tests/test-cases/'`

# save crash reporter state
CRSTATE=`defaults read com.apple.CrashReporter DialogType`
defaults write com.apple.CrashReporter DialogType basic

# run test targeting different OS versions
for OSVERSION in 10.7 10.6 10.5 10.4
do 
	echo ""
	echo " * * * Running all unit tests i386 built for $OSVERSION * * *"

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

	# build default architecture
	../bin/make-recursive.pl ARCH="i386" OS_VERSION=$OSVERSION OS_NAME=MacOSX | ../bin/result-filter.pl

	# if 64-bit capable Intel, then also run all test cases for 64-bits
	if [ `sysctl -n hw.optional.x86_64` = "1" ] 
	then
		echo ""
		echo " * * * Running all unit tests x86_64 built for $OSVERSION * * *"
		
		# make clean
		../bin/make-recursive.pl clean > /dev/null

		# build x86_64 architecture
		../bin/make-recursive.pl ARCH="x86_64" OS_VERSION=$OSVERSION OS_NAME=MacOSX | ../bin/result-filter.pl
	fi

done

# restore crash reporter state
defaults write com.apple.CrashReporter DialogType ${CRSTATE}


