Skip to content

Commit

Permalink
fix(shorebird_cli): shorebird patch ios-alpha handle `BuildExceptio…
Browse files Browse the repository at this point in the history
…n` when building IPA (#1045)
  • Loading branch information
felangel authored Aug 7, 2023
1 parent 3571179 commit a62031b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ Please re-run the release command for this version or create a new release.''');
} on ProcessException catch (error) {
buildProgress.fail('Failed to build: ${error.message}');
return ExitCode.software.code;
} on BuildException catch (error) {
buildProgress.fail('Failed to build IPA');
logger.err(error.message);
return ExitCode.software.code;
}

final File aotFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,44 @@ Please re-run the release command for this version or create a new release.'''),
expect(exitCode, equals(ExitCode.software.code));
});

test('exits with code 70 when building fails (due to BuildException)',
() async {
when(() => flutterBuildProcessResult.exitCode).thenReturn(0);
when(() => flutterBuildProcessResult.stderr).thenReturn('''
Encountered error while creating the IPA:
error: exportArchive: Communication with Apple failed
error: exportArchive: No signing certificate "iOS Distribution" found
error: exportArchive: Communication with Apple failed
error: exportArchive: No signing certificate "iOS Distribution" found
error: exportArchive: Team "My Team" does not have permission to create "iOS App Store" provisioning profiles.
error: exportArchive: No profiles for 'com.example.co' were found
error: exportArchive: Communication with Apple failed
error: exportArchive: No signing certificate "iOS Distribution" found
error: exportArchive: Communication with Apple failed
error: exportArchive: No signing certificate "iOS Distribution" found
error: exportArchive: Communication with Apple failed
error: exportArchive: No signing certificate "iOS Distribution" found
''');

final tempDir = setUpTempDir();
final exitCode = await IOOverrides.runZoned(
() => runWithOverrides(command.run),
getCurrentDirectory: () => tempDir,
);

expect(exitCode, equals(ExitCode.software.code));
verify(
() => progress.fail(any(that: contains('Failed to build'))),
).called(1);
verify(
() => logger.err('''
Communication with Apple failed
No signing certificate "iOS Distribution" found
Team "My Team" does not have permission to create "iOS App Store" provisioning profiles.
No profiles for 'com.example.co' were found'''),
).called(1);
});

test('throws error when creating aot snapshot fails', () async {
const error = 'oops something went wrong';
when(() => aotBuildProcessResult.exitCode).thenReturn(1);
Expand Down

0 comments on commit a62031b

Please sign in to comment.