Skip to content

Instantly share code, notes, and snippets.

@electricmonk
Created November 20, 2014 14:17
Show Gist options
  • Save electricmonk/2e25fac43556eecdae30 to your computer and use it in GitHub Desktop.
Save electricmonk/2e25fac43556eecdae30 to your computer and use it in GitHub Desktop.
A script that starts a Java server and runs iOS unit tests against it
#!/bin/bash
# Assuming Cocoapods was installed (sudo gem install cocoapods)
JARBALL="target/server/$SERVER_ARTIFACT-$SERVER_VERSION"
# assume maven dependency:unpack has placed our jarball in target/server as configued in pom.xml
unzip -o "$JARBALL-deployable.jar" -d "target/server"
MAX_ATTEMPTS=30
SLEEP=1
java -jar "$JARBALL/$SERVER_ARTIFACT.jar" --server-port 9919 &
echo "*** Waiting for server to start"
waiting_for_start=1
attempts=0
server_status=0
while (($waiting_for_start != 0)) && (($attempts <= $MAX_ATTEMPTS));
do
attempts=$(($attempts + 1))
server_status=$(curl --output /dev/null "http://127.0.0.1:9919/health/test" --write-out %{http_code} --silent)
echo "got status $server_status from server"
if (($server_status == "200")); then
echo *** Server started
waiting_for_start=0
elif (($attempts == $MAX_ATTEMPTS)); then
echo "*** Server failed to start after $(($MAX_ATTEMPTS * $SLEEP)) seconds"
exit -1
else
printf '.'
sleep $SLEEP
fi
done
# Install CocoaPod dependencies - assuming current user has git permissions on Labgoo's spec repo
echo "*** Installing Pods"
rm Podfile.lock
rm -rf Pods
pod install --verbose
echo "*** Running xcodebuild"
xcodebuild test -workspace WixSDKIntegTests.xcworkspace -scheme WixSDKIntegTests -destination 'platform=iOS Simulator,name=iPhone 6'
XC=$?
killall "iOS Simulator"
pkill -f $SERVER_ARTIFACT
exit $XC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment