diff options
author | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2013-03-01 16:00:18 +0000 |
---|---|---|
committer | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2013-03-01 16:00:18 +0000 |
commit | 44043f0b1646f6a439c3dd22e96a2d9f5577ed78 (patch) | |
tree | a88f2e880429bc0f2934b449c9d51f1f36cc208a /UnitTesting/RuniOSUnitTestsUnderSimulator.sh | |
parent | 571db0b0ef9c5c9bda19d92c59e5ce0a8eb6ca2e (diff) |
Try and make scripted builds more stable by killing the app being launched to
make sure nothing is left between runs to cause problems for the next launch.
DELTA=24 (19 added, 0 deleted, 5 changed)
Diffstat (limited to 'UnitTesting/RuniOSUnitTestsUnderSimulator.sh')
-rwxr-xr-x | UnitTesting/RuniOSUnitTestsUnderSimulator.sh | 29 |
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." |