aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xUnitTesting/RuniOSUnitTestsUnderSimulator.sh29
1 files changed, 24 insertions, 5 deletions
diff --git a/UnitTesting/RuniOSUnitTestsUnderSimulator.sh b/UnitTesting/RuniOSUnitTestsUnderSimulator.sh
index 471b64f..19c41d3 100755
--- a/UnitTesting/RuniOSUnitTestsUnderSimulator.sh
+++ b/UnitTesting/RuniOSUnitTestsUnderSimulator.sh
@@ -100,11 +100,15 @@ GTMFakeUnitTestingMsg() {
echo "${DEVELOPER_DIR}/Tools/RunPlatformUnitTests.include:${1}: ${2}: ${3}"
}
-GTMKillSimulator() {
+GTMKillNamedAndWait() {
# If there is something killed, sleep for few seconds to let the simulator
# spin down so it isn't still seen as running when the next thing tries to
# launch it.
- /usr/bin/killall "iPhone Simulator" 2> /dev/null && sleep 2 || true
+ /usr/bin/killall "${1}" 2> /dev/null && sleep 2 || true
+}
+
+GTMKillSimulator() {
+ GTMKillNamedAndWait "iPhone Simulator"
}
# Honor TEST_AFTER_BUILD if requested.
@@ -165,7 +169,7 @@ GTM_LEAKS_SYMBOLS_TO_IGNORE="CFHTTPCookieStore"
#
# Build up the command line to run.
#
-
+GTM_TEST_APP_NAME=
GTM_TEST_COMMAND=(
"${SimExecutable}"
"-d" "${GTM_DEVICE_TYPE}"
@@ -177,10 +181,13 @@ fi
if [[ -n "${TEST_HOST}" ]]; then
# When using a test host, it is usually set to the executable within the app
# bundle, back up one to point at the bundle.
- TEST_HOST_FILENAME=$(basename "${TEST_HOST}")
- TEST_HOST_EXTENSION="${TEST_HOST_FILENAME##*.}"
+ GTM_TEST_APP_NAME=$(basename "${TEST_HOST}")
+ TEST_HOST_EXTENSION="${GTM_TEST_APP_NAME##*.}"
if [[ "${TEST_HOST_EXTENSION}" != "app" ]] ; then
TEST_HOST=$(dirname "${TEST_HOST}")
+ else
+ # Drop the extension.
+ GTM_TEST_APP_NAME="${GTM_TEST_APP_NAME%.*}"
fi
# Yes the DYLD_INSERT_LIBRARIES value below looks odd, that is found from
# looking at what Xcode sets when it invokes unittests directly.
@@ -191,6 +198,13 @@ if [[ -n "${TEST_HOST}" ]]; then
"${TEST_HOST}"
)
else
+ GTM_TEST_APP_NAME=$(basename "${TEST_BUNDLE_PATH}")
+ TEST_BUNDLE_EXTENSION="${GTM_TEST_APP_NAME##*.}"
+ if [[ "${TEST_BUNDLE_EXTENSION}" == "app" ]] ; then
+ # Drop the extension.
+ GTM_TEST_APP_NAME="${GTM_TEST_APP_NAME%.*}"
+ fi
+
GTM_TEST_COMMAND+=( "${TEST_BUNDLE_PATH}" )
fi
GTM_TEST_COMMAND+=(
@@ -203,6 +217,10 @@ if [[ -n "${TEST_HOST}" ]]; then
GTM_TEST_COMMAND+=( "${TEST_BUNDLE_PATH}" )
fi
+# Kill the test host just to make sure it wasn't left running and will cause
+# problems.
+GTMKillNamedAndWait "${GTM_TEST_APP_NAME}"
+
# These two lines seem to fake out Xcode just enough that its log parser acts
# as though Xcode were running the unit test via the UI. This prevents false
# failures based on lines including "error" and such (which tends to happen in
@@ -216,6 +234,7 @@ TEST_HOST_RESULT=$?
set -e
GTMKillSimulator
+GTMKillNamedAndWait "${GTM_TEST_APP_NAME}"
if [[ ${TEST_HOST_RESULT} -ne 0 ]]; then
GTMXcodeError ${LINENO} "Tests failed."