Fix file deletion crash in BuildIOSArchiveCommand.runCommand (#138734)
Fixes https://github.com/flutter/flutter/issues/138030
This commit is contained in:
parent
82170c1fe3
commit
e826c63aec
@ -11,6 +11,7 @@ import 'package:unified_analytics/unified_analytics.dart';
|
|||||||
|
|
||||||
import '../base/analyze_size.dart';
|
import '../base/analyze_size.dart';
|
||||||
import '../base/common.dart';
|
import '../base/common.dart';
|
||||||
|
import '../base/error_handling_io.dart';
|
||||||
import '../base/logger.dart';
|
import '../base/logger.dart';
|
||||||
import '../base/process.dart';
|
import '../base/process.dart';
|
||||||
import '../base/utils.dart';
|
import '../base/utils.dart';
|
||||||
@ -492,7 +493,9 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
generatedExportPlist?.deleteSync();
|
if (generatedExportPlist != null) {
|
||||||
|
ErrorHandlingFileSystem.deleteIfExists(generatedExportPlist);
|
||||||
|
}
|
||||||
status?.stop();
|
status?.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +180,7 @@ void main() {
|
|||||||
FakeCommand exportArchiveCommand({
|
FakeCommand exportArchiveCommand({
|
||||||
String exportOptionsPlist = '/ExportOptions.plist',
|
String exportOptionsPlist = '/ExportOptions.plist',
|
||||||
File? cachePlist,
|
File? cachePlist,
|
||||||
|
bool deleteExportOptionsPlist = false,
|
||||||
}) {
|
}) {
|
||||||
return FakeCommand(
|
return FakeCommand(
|
||||||
command: <String>[
|
command: <String>[
|
||||||
@ -201,6 +202,9 @@ void main() {
|
|||||||
if (cachePlist != null) {
|
if (cachePlist != null) {
|
||||||
cachePlist.writeAsStringSync(fileSystem.file(_exportOptionsPlist).readAsStringSync());
|
cachePlist.writeAsStringSync(fileSystem.file(_exportOptionsPlist).readAsStringSync());
|
||||||
}
|
}
|
||||||
|
if (deleteExportOptionsPlist) {
|
||||||
|
fileSystem.file(_exportOptionsPlist).deleteSync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -419,6 +423,40 @@ void main() {
|
|||||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testUsingContext('ipa build ignores deletion failure if generatedExportPlist does not exist', () async {
|
||||||
|
final File cachedExportOptionsPlist = fileSystem.file('/CachedExportOptions.plist');
|
||||||
|
final BuildCommand command = BuildCommand(
|
||||||
|
artifacts: artifacts,
|
||||||
|
androidSdk: FakeAndroidSdk(),
|
||||||
|
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
|
||||||
|
logger: logger,
|
||||||
|
fileSystem: fileSystem,
|
||||||
|
processUtils: processUtils,
|
||||||
|
osUtils: FakeOperatingSystemUtils(),
|
||||||
|
);
|
||||||
|
fakeProcessManager.addCommands(<FakeCommand>[
|
||||||
|
xattrCommand,
|
||||||
|
setUpFakeXcodeBuildHandler(),
|
||||||
|
exportArchiveCommand(
|
||||||
|
exportOptionsPlist: _exportOptionsPlist,
|
||||||
|
cachePlist: cachedExportOptionsPlist,
|
||||||
|
deleteExportOptionsPlist: true,
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
createMinimalMockProjectFiles();
|
||||||
|
|
||||||
|
await createTestCommandRunner(command).run(
|
||||||
|
const <String>['build', 'ipa', '--no-pub']
|
||||||
|
);
|
||||||
|
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
FileSystem: () => fileSystem,
|
||||||
|
Logger: () => logger,
|
||||||
|
ProcessManager: () => fakeProcessManager,
|
||||||
|
Platform: () => macosPlatform,
|
||||||
|
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||||
|
});
|
||||||
|
|
||||||
testUsingContext('ipa build invokes xcodebuild and archives for app store', () async {
|
testUsingContext('ipa build invokes xcodebuild and archives for app store', () async {
|
||||||
final File cachedExportOptionsPlist = fileSystem.file('/CachedExportOptions.plist');
|
final File cachedExportOptionsPlist = fileSystem.file('/CachedExportOptions.plist');
|
||||||
final BuildCommand command = BuildCommand(
|
final BuildCommand command = BuildCommand(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user