Skip to content
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

Merged

Conversation

christopherfujino
Copy link
Member

@christopherfujino christopherfujino commented Mar 4, 2020

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 and IOSSimulator 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 to IOSSimulatorUtils and SimControl 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.

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read [Handling breaking changes].

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.
    • I wrote a design doc: https://flutter.dev/go/template Replace this with a link to your design doc's short link
    • I got input from the developer relations team, specifically from: Replace with the names of who gave advice
    • I wrote a migration guide: Replace with a link to your migration guide

@fluttergithubbot fluttergithubbot added tool Affects the "flutter" command-line tool. See also t: labels. work in progress; do not review labels Mar 4, 2020
@christopherfujino christopherfujino changed the title Catch async errors Fix simctl process exceptions not being caught Mar 5, 2020
try {
result = processUtils.run(
result = await _processUtils.run(
Copy link
Member

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?

Copy link
Member Author

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,
);
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@christopherfujino christopherfujino added waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds waiting for tree to go green and removed waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Mar 6, 2020
@fluttergithubbot fluttergithubbot merged commit 2e18cd3 into flutter:master Mar 6, 2020
@christopherfujino christopherfujino deleted the catch-async-errors branch March 6, 2020 21:21
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Throw tool exit when xcrun fails for bad plist
4 participants