#!/bin/sh
function fail {
echo "$*" >&2
exit 1
}
CONFIGURATION="Release"
PASSWORD="yourpassword"
SCHEME="Testable"
WORKSPACE="/Users/jenkins/.jenkins/common_checkout"
SDK="iphonesimulator"
PROJDIR=$WORKSPACE/iOS/projects/Happy/trunk/Happy
function section_print {
echo "\n=== $* ==="
}
section_print "======================================================> Building $CONFIGURATION";
if [ -z $CONFIGURATION ]; then
fail "No configuration specified";
exit 1;
fi
#strange way to force backslash
if [ $PROJDIR ]; then
PROJDIR=${PROJDIR%/}
PROJDIR="$PROJDIR/"
BUILD_PATH=$PROJDIRbuild/"$CONFIGURATION"-iphonesimulator
section_print "======================================================> Project Dir is specified and is $PROJDIR"
cd "$PROJDIR" || fail "no directory $PROJDIR"
pwd
fi
section_print "======================================================> Unlocking keychain"
security list-keychains -s /Users/jenkins/Library/Keychains/login.keychain
security unlock-keychain -p "$PASSWORD" /Users/jenkins/Library/Keychains/login.keychain
section_print "======================================================> Cleaning build"
xcodebuild -configuration "$CONFIGURATION" clean || fail "Clean failed"
section_print "======================================================> Building $CONFIGURATION"
xcodebuild -list
xcodebuild -target IntegrationTests -sdk $SDK -configuration $CONFIGURATION build
section_print "======================================================> Running Automated Test Script"
echo "About to run waxsim - a long delay here might suggest something is obstructing the view of the simulator on build slave"
BTWAXSIM="/Users/Jenkins/.jenkins/common_checkout/iOS/projects/btwaxsim/trunk/btwaxsim/build/release"
killall -s "iPhone Simulator" &> /dev/null
pwd
if [ $? -eq 0 ]; then
# Stop any running iOS simulators on the OS
killall -KILL -m "iPhone Simulator"
fi
$BTWAXSIM/waxsim -f ipad /Users/jenkins/.jenkins/common_checkout/iOS/Projects/Happy/trunk/Happy/build/$CONFIGURATION-iphonesimulator/IntegrationTests.app > /tmp/KIF-$$.out 2>&1
# WaxSim hides the return value from the app, so to determine success we search for a "no failures" line
# Type "open waxsim" from terminal to see options other than ipad option below
# waxsim -f ipad /path/to/
app.app <---- use for ipad only
echo "Testing finished"
# count the number of times "TESTING FINISHED: 0 failures" is found - 0 means that there was a failure
success=`exec grep -c "TESTING FINISHED: 0 failures" /tmp/KIF-$$.out`
# if there was a failure, show what waxsim was hiding and crucially return with a non-zero exit code
if [ "$success" = '0' ]
then
echo "======== PRINT temp file to STDOUT ========"
echo " "
cat /tmp/KIF-$$.out
echo " "
echo "======== End PRINT temp file to STDOUT ===="
echo "==========================================="
echo "GUI Tests failed"
echo "==========================================="
exit 1
else
echo "======== PRINT temp file to STDOUT ========"
echo " "
cat /tmp/KIF-$$.out
echo " "
echo "======== End PRINT temp file to STDOUT ===="
echo "==========================================="
echo "UIAutomation Tests passed"
echo "==========================================="
fi
section_print "======================================================> Test Simulator Complete"