-
Notifications
You must be signed in to change notification settings - Fork 6k
Create iOS simulator before running IosUnitTests #33906
Conversation
| 'xcrun ' | ||
| 'simctl ' | ||
| 'create ' | ||
| '%s com.apple.CoreSimulator.SimDeviceType.iPhone-11' % new_simulator_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this line of code changes 634 has to change too. Can the test command optionally take in the simulator name for the destination? Otherwise at a minimum we can pull these out into variables that are next to each other so it's clear they are updated in tandem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think we can get away with changing the 634 logic from platform='iOS Simulator,name=iPhone 11' to name=IosUnitTestsSimulator. I forgot that was why I needed to delete the old simulators so there were never multiple with the same name, or the xcodebuild command would fail since there were multiple possible destinations. Let me do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(obligatory comment to make this a request)
| test_command[0] = test_command[0] + " -only-testing:%s" % test_filter | ||
| RunCmd(test_command, cwd=ios_unit_test_dir, shell=True) | ||
| finally: | ||
| DeleteSimulator(new_simulator_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't technically needed to fix the issue and it will increase run times for tests no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this is technically not needed since any leftover simulators are deleted before the next run of this script (which happens during flake detection), but I'd rather not leak the simulator to other scripts running simulator tests (scenario?)
Fortunately it's very fast, as mentioned above:
xcrun simctl delete test1 0.08s user 0.08s system 86% cpu 0.180 total
| 'FLUTTER_ENGINE=' + ios_variant | ||
| # Delete simulators with this name in case any were leaked | ||
| # from another test run. | ||
| DeleteSimulator(new_simulator_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option is to detect if the simulator exists and decide to create a new one if one does not exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seemed like a lot more work and parsing 🙂
I wanted to guard against the simulator leaking when this script is run multiple times for flake detection. Fortunately creating and deleting simulators is extremely fast, so we don't need to over optimize.
xcrun simctl create test1 com.apple.CoreSimulator.SimDeviceType.iPhone-11 0.07s user 0.07s system 65% cpu 0.217 total
xcrun simctl delete test1 0.08s user 0.08s system 86% cpu 0.180 total
cyanglaz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
Can we land this? |
I was waiting on the change to using the name instead of the platform to launch the simulator. Now that the lights are green, does that mean it worked? If that's the case I'm good with it. |
| 'xcrun ' | ||
| 'simctl ' | ||
| 'create ' | ||
| '%s com.apple.CoreSimulator.SimDeviceType.iPhone-11' % new_simulator_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(obligatory comment to make this a request)
Yup, it worked. |
gaaclarke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks!
Fixes flutter/flutter#105567
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.