From 6c2023162fbfd3f24ae157b29329646488f84cd6 Mon Sep 17 00:00:00 2001 From: Victoria Ashworth <15619084+vashworth@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:47:51 -0500 Subject: [PATCH] Change resultBundlePath representation from File to Directory (#130156) `resultBundlePath` is meant to be a directory. In the `xcodebuild --help`, it describes it as a directory: ``` -resultBundlePath PATH specifies the directory where a result bundle describing what occurred will be placed ``` This PR changes our usage of it from a file to a directory so that it gets deleted correctly between reruns. Fixes https://github.com/flutter/flutter/issues/129954. --- packages/flutter_tools/lib/src/ios/mac.dart | 12 +++--- .../hermetic/build_ios_test.dart | 40 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index cbd1f89c38a..86a4a0546ad 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -357,10 +357,10 @@ Future buildXcodeProject({ buildCommands.add('SCRIPT_OUTPUT_STREAM_FILE=${scriptOutputPipeFile.absolute.path}'); } - final File resultBundleFile = tempDir.childFile(_kResultBundlePath); + final Directory resultBundleDirectory = tempDir.childDirectory(_kResultBundlePath); buildCommands.addAll([ '-resultBundlePath', - resultBundleFile.absolute.path, + resultBundleDirectory.absolute.path, '-resultBundleVersion', _kResultBundleVersion, ]); @@ -382,7 +382,7 @@ Future buildXcodeProject({ final Stopwatch sw = Stopwatch()..start(); initialBuildStatus = globals.logger.startProgress('Running Xcode build...'); - buildResult = await _runBuildWithRetries(buildCommands, app, resultBundleFile); + buildResult = await _runBuildWithRetries(buildCommands, app, resultBundleDirectory); // Notifies listener that no more output is coming. scriptOutputPipeFile?.writeAsStringSync('all done'); @@ -512,14 +512,14 @@ Future removeFinderExtendedAttributes(FileSystemEntity projectDirectory, P } } -Future _runBuildWithRetries(List buildCommands, BuildableIOSApp app, File resultBundleFile) async { +Future _runBuildWithRetries(List buildCommands, BuildableIOSApp app, Directory resultBundleDirectory) async { int buildRetryDelaySeconds = 1; int remainingTries = 8; RunResult? buildResult; while (remainingTries > 0) { - if (resultBundleFile.existsSync()) { - resultBundleFile.deleteSync(recursive: true); + if (resultBundleDirectory.existsSync()) { + resultBundleDirectory.deleteSync(recursive: true); } remainingTries--; buildRetryDelaySeconds *= 2; diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart index aaf95811246..c1f2dc3b47e 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart @@ -117,7 +117,7 @@ void main() { 'xcresulttool', 'get', '--path', - _xcBundleFilePath, + _xcBundleDirectoryPath, '--format', 'json', ], @@ -173,7 +173,7 @@ void main() { '-destination', 'generic/platform=iOS', ], - '-resultBundlePath', _xcBundleFilePath, + '-resultBundlePath', _xcBundleDirectoryPath, '-resultBundleVersion', '3', 'FLUTTER_SUPPRESS_ANALYTICS=true', 'COMPILER_INDEX_STORE_ENABLE=NO', @@ -461,7 +461,7 @@ void main() { ProcessManager: () => FakeProcessManager.list([ xattrCommand, setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); }), setUpXCResultCommand(), setUpRsyncCommand(), @@ -495,7 +495,7 @@ void main() { ProcessManager: () => FakeProcessManager.list([ xattrCommand, setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); }, stdout: 'Lots of spew from Xcode', ), setUpXCResultCommand(stdout: kSampleResultJsonWithIssues), @@ -530,7 +530,7 @@ void main() { ProcessManager: () => FakeProcessManager.list([ xattrCommand, setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); }), setUpXCResultCommand(stdout: kSampleResultJsonWithIssuesToBeDiscarded), setUpRsyncCommand(), @@ -594,7 +594,7 @@ void main() { ProcessManager: () => FakeProcessManager.list([ xattrCommand, setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); }), setUpXCResultCommand(stdout: kSampleResultJsonWithProvisionIssue), setUpRsyncCommand(), @@ -628,7 +628,7 @@ void main() { setUpFakeXcodeBuildHandler( exitCode: 1, onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); } ), setUpXCResultCommand(stdout: kSampleResultJsonWithNoProvisioningProfileIssue), @@ -661,17 +661,17 @@ void main() { exitCode: 1, stdout: '$kConcurrentRunFailureMessage1 $kConcurrentRunFailureMessage2', onRun: () { - fileSystem.systemTempDirectory.childFile(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).childFile('result.xcresult').createSync(recursive: true); } ), // The second xcodebuild is triggered due to above concurrent run failure message. setUpFakeXcodeBuildHandler( onRun: () { // If the file is not cleaned, throw an error, test failure. - if (fileSystem.systemTempDirectory.childFile(_xcBundleFilePath).existsSync()) { + if (fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).existsSync()) { throwToolExit('xcresult bundle file existed.', exitCode: 2); } - fileSystem.systemTempDirectory.childFile(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).childFile('result.xcresult').createSync(recursive: true); } ), setUpXCResultCommand(stdout: kSampleResultJsonNoIssues), @@ -709,7 +709,7 @@ void main() { Runner requires a provisioning profile. Select a provisioning profile in the Signing & Capabilities editor ''', onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); } ), setUpXCResultCommand(stdout: kSampleResultJsonInvalidIssuesMap), @@ -743,7 +743,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig setUpFakeXcodeBuildHandler( exitCode: 1, onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); } ), setUpXCResultCommand(stdout: kSampleResultJsonInvalidIssuesMap), @@ -780,7 +780,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig Runner requires a provisioning profile. Select a provisioning profile in the Signing & Capabilities editor ''', onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); } ), setUpXCResultCommand(stdout: kSampleResultJsonNoIssues), @@ -815,7 +815,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig setUpFakeXcodeBuildHandler( exitCode: 1, onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); } ), setUpXCResultCommand(stdout: kSampleResultJsonInvalidIssuesMap), @@ -850,7 +850,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig setUpFakeXcodeBuildHandler( exitCode: 1, onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); } ), setUpXCResultCommand(stdout: kSampleResultJsonWithNoProvisioningProfileIssue), @@ -885,7 +885,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig setUpFakeXcodeBuildHandler( exitCode: 1, onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); } ), setUpXCResultCommand(stdout: kSampleResultJsonWithProvisionIssue), @@ -922,7 +922,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig simulator: true, exitCode: 1, onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); }, ), setUpXCResultCommand(), @@ -958,7 +958,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig simulator: true, exitCode: 1, onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); }, ), setUpXCResultCommand(stdout: kSampleResultJsonWithIssues), @@ -996,7 +996,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig simulator: true, exitCode: 1, onRun: () { - fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync(); + fileSystem.systemTempDirectory.childDirectory(_xcBundleDirectoryPath).createSync(); }, ), setUpXCResultCommand(stdout: kSampleResultJsonWithIssuesToBeDiscarded), @@ -1040,7 +1040,7 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig }); } -const String _xcBundleFilePath = '/.tmp_rand0/flutter_ios_build_temp_dirrand0/temporary_xcresult_bundle'; +const String _xcBundleDirectoryPath = '/.tmp_rand0/flutter_ios_build_temp_dirrand0/temporary_xcresult_bundle'; class FakeAndroidSdk extends Fake implements AndroidSdk { @override