From 38231c884ee856401c771165dea7be2de4285b7f Mon Sep 17 00:00:00 2001 From: John Wen Date: Fri, 1 Aug 2014 10:59:08 -0700 Subject: [PATCH] If app crashes, start it up to upload crash logs Added -upload_crash_logs parameter to start up the same simulator or device that ran the tests if the app crashed so that logs can be uploaded. --- Supporting Files/CI/subliminal-test | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Supporting Files/CI/subliminal-test b/Supporting Files/CI/subliminal-test index 01b6916..1aca854 100755 --- a/Supporting Files/CI/subliminal-test +++ b/Supporting Files/CI/subliminal-test @@ -30,7 +30,7 @@ print_usage_and_fail () { subliminal-test (-project | -workspace | -prebuilt_app ) ( -sim_device | -hw_id ) [-build_tool ] [-scheme ] [-sdk ] [-replacement_bundle_id ] [--quiet_build] - [-sim_version ] [-timeout ] [-output ] + [-sim_version ] [-timeout ] [-output ] [-upload_crash_logs ] [-e ] \`subliminal-test\` builds a scheme contained in an Xcode project or Xcode workspace, @@ -134,6 +134,9 @@ Optional testing arguments: Has no default value. + -upload_crash_logs If the app aborts during a test run, restart the app and idle for + to give the app an opportunity to upload crash logs. + --verbose_logging Enables UIAutomation's debug logs, which record every user interaction simulated by the Automation instrument. @@ -187,7 +190,7 @@ case $1 in shift 1;; # Set argument, wait for value - -project|-workspace|-prebuilt_app|-sim_device|-hw_id|-build_tool|-scheme|-configuration|-sdk|-replacement_bundle_id|-sim_version|-timeout|-output|-e) + -project|-workspace|-prebuilt_app|-sim_device|-hw_id|-build_tool|-scheme|-configuration|-sdk|-replacement_bundle_id|-sim_version|-timeout|-output|-upload_crash_logs|-e) if [[ -n "$CURRENT_ARG" ]]; then echo "Missing value for argument: $CURRENT_ARG" print_usage_and_fail @@ -673,5 +676,18 @@ if [[ -d "${OUTPUT}" ]]; then mv "$RESULTS_DIR/Run 1" "$OUTPUT/Run Data" fi +# If the app crashed, start it back up so that crash logs can be uploaded +if [ $TEST_STATUS -eq 1 ] && [[ -n "$UPLOAD_CRASH_LOGS" ]]; then + echo "\nStarting up app again to allow crash logs to upload..." + + IDLE_SCRIPT=`mktemp /tmp/subliminal-test.idle_script.XXXXXX` + echo "UIATarget.localTarget().delay($UPLOAD_CRASH_LOGS);" > "$IDLE_SCRIPT" + + DEVICE=`[[ -n "$HW_ID" ]] && echo "$HW_ID" || echo "$SIM_DEVICE - Simulator - iOS $SIM_VERSION"` + instruments -w "$DEVICE" -t Automation "$APP" -e UIASCRIPT "$IDLE_SCRIPT" + + rm -rf "$IDLE_SCRIPT" +fi + echo "\n\nRun complete." cleanup_and_exit $TEST_STATUS