New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix simctl process exceptions not being caught #51916
Fix simctl process exceptions not being caught #51916
Conversation
try { | ||
result = processUtils.run( | ||
result = await _processUtils.run( |
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.
The issue indicates that the user might be able to avoid the ProcessExceptions by fixing a plist file. Should the throwToolExit
include that in the message?
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.
Done.
@@ -187,7 +212,7 @@ class SimControl { | |||
|
|||
Future<void> takeScreenshot(String deviceId, String outputPath) async { | |||
try { | |||
await processUtils.run( | |||
await _processUtils.run( | |||
<String>[_xcrunPath, 'simctl', 'io', deviceId, 'screenshot', outputPath], | |||
throwOnError: true, | |||
); |
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.
I'm not sure failing to take a screenshot should throw a tool exit. Maybe it should just print an error and continue?
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.
Done.
Description
Fixes
simctl
process exceptions not being caught because an async call in a try/catch wasn't being awaited.Also added direct injection to
IOSSimulatorUtils
,SimControl
andIOSSimulator
classes.Related Issues
Fixes #39759.
Tests
Added tests to verify
SimControl
methods properly caught process exceptions and emitted tool exits. Also refactored many tests to directly inject dependencies toIOSSimulatorUtils
andSimControl
classes.Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read [Handling breaking changes].