aboutsummaryrefslogtreecommitdiff
path: root/UnitTesting
diff options
context:
space:
mode:
authorGravatar thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2014-10-29 15:33:04 +0000
committerGravatar thomasvl <thomasvl@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2014-10-29 15:33:04 +0000
commitd23d29b6967f0310478eaa1f33180d02b6780a89 (patch)
tree9fdba5366bed00e054a45f2ade833e1f84b1adf5 /UnitTesting
parentff8dfe2636b6469daf1a13c3305d17d375f80809 (diff)
After switching to Xcode 6, the Simulator sometimes fails to open causing the
tests to fail. The projects that have more test targets are more vulnerable to the issue. When the simulator fails to open, we should reset it and try again.
Diffstat (limited to 'UnitTesting')
-rwxr-xr-xUnitTesting/RuniOSUnitTestsUnderSimulator.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/UnitTesting/RuniOSUnitTestsUnderSimulator.sh b/UnitTesting/RuniOSUnitTestsUnderSimulator.sh
index 20efc45..6f71f04 100755
--- a/UnitTesting/RuniOSUnitTestsUnderSimulator.sh
+++ b/UnitTesting/RuniOSUnitTestsUnderSimulator.sh
@@ -130,6 +130,13 @@ GTMKillSimulator() {
GTMKillNamedAndWait "${SimulatorProcessName}"
}
+GTMResetSimulator() {
+ GTMKillSimulator
+ device_id=`xcrun simctl list | grep "${GTM_DEVICE_TYPE} (" | sed -n 2p | \
+ cut -d "(" -f2 | cut -d ")" -f1`
+ xcrun simctl erase $device_id || true
+}
+
# Honor TEST_AFTER_BUILD if requested.
if [[ "$GTM_USE_TEST_AFTER_BUILD" == 1 && "$TEST_AFTER_BUILD" == "NO" ]]; then
GTMXcodeNote ${LINENO} "Skipping running of unittests since TEST_AFTER_BUILD=NO."
@@ -265,6 +272,17 @@ set -e
GTMKillSimulator
GTMKillNamedAndWait "${GTM_TEST_APP_NAME}"
+# If the simulator fails to open with error FBSOpenApplicationErrorDomain:4,
+# reset the sim and try again (Known simulator issue for Xcode 6).
+if [ ${TEST_HOST_RESULT} -eq 4 ] && [ ${XCODE_VERSION_MINOR} -ge "0600" ]; then
+ GTMFakeUnitTestingMsg ${LINENO} "Simulator failed to open" "$TEST_HOST_RESULT, trying again."
+ GTMResetSimulator
+ set +e
+ "${GTM_TEST_COMMAND[@]}"
+ TEST_HOST_RESULT=$?
+ set -e
+fi
+
if [[ ${TEST_HOST_RESULT} -ne 0 ]]; then
GTMXcodeError ${LINENO} "Tests failed."
exit 1