From d6735132e471c24958d1ea6d151d247240e7490f Mon Sep 17 00:00:00 2001 From: Victoria Ashworth <15619084+vashworth@users.noreply.github.com> Date: Thu, 22 Feb 2024 14:17:22 -0600 Subject: [PATCH] Delete and create iOS simulator before running Scenario app test (flutter/engine#50835) Make iOS Scenario app tests create the simulator it needs before the tests. Also, delete any existing matching simulators to prevent duplicates. Fixes https://github.com/flutter/flutter/issues/143870. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../testing/scenario_app/run_ios_tests.sh | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/testing/scenario_app/run_ios_tests.sh b/engine/src/flutter/testing/scenario_app/run_ios_tests.sh index 9b34497bb5..ed040b16d1 100755 --- a/engine/src/flutter/testing/scenario_app/run_ios_tests.sh +++ b/engine/src/flutter/testing/scenario_app/run_ios_tests.sh @@ -58,13 +58,34 @@ zip_and_upload_xcresult_to_luci () { exit 1 } +readonly DEVICE_NAME="iPhone SE (3rd generation)" +readonly DEVICE=com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation +readonly OS_RUNTIME=com.apple.CoreSimulator.SimRuntime.iOS-17-0 +readonly OS="17.0" + +# Delete any existing devices named "iPhone SE (3rd generation)". Having more +# than one may cause issues when builds target the device. +echo "Deleting any existing devices names $DEVICE_NAME..." +RESULT=0 +while [[ $RESULT == 0 ]]; do + xcrun simctl delete "$DEVICE_NAME" || RESULT=1 + if [ $RESULT == 0 ]; then + echo "Deleted $DEVICE_NAME" + fi +done +echo "" + +echo "Creating $DEVICE_NAME $DEVICE $OS_RUNTIME ..." +xcrun simctl create "$DEVICE_NAME" "$DEVICE" "$OS_RUNTIME" +echo "" + echo "Running simulator tests with Skia" echo "" if set -o pipefail && xcodebuild -sdk iphonesimulator \ -scheme Scenarios \ -resultBundlePath "$RESULT_BUNDLE_PATH/ios_scenario.xcresult" \ - -destination 'platform=iOS Simulator,OS=17.0,name=iPhone SE (3rd generation)' \ + -destination "platform=iOS Simulator,OS=$OS,name=$DEVICE_NAME" \ clean test \ FLUTTER_ENGINE="$FLUTTER_ENGINE"; then echo "test success." @@ -82,7 +103,7 @@ echo "" if set -o pipefail && xcodebuild -sdk iphonesimulator \ -scheme Scenarios \ -resultBundlePath "$RESULT_BUNDLE_PATH/ios_scenario.xcresult" \ - -destination 'platform=iOS Simulator,OS=17.0,name=iPhone SE (3rd generation)' \ + -destination "platform=iOS Simulator,OS=$OS,name=$DEVICE_NAME" \ clean test \ FLUTTER_ENGINE="$FLUTTER_ENGINE" \ -skip-testing ScenariosUITests/MultiplePlatformViewsBackgroundForegroundTest/testPlatformView \