Delete unzipped FlutterMacOS.framework before replacing artifact (#77316)

This commit is contained in:
Jenn Magder 2021-03-04 19:36:21 -08:00 committed by GitHub
parent fcc0042d82
commit a7f7687a2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View file

@ -934,6 +934,7 @@ abstract class EngineCachedArtifact extends CachedArtifact {
final File frameworkZip = fileSystem.file(fileSystem.path.join(dir.path, 'FlutterMacOS.framework.zip'));
if (frameworkZip.existsSync()) {
final Directory framework = fileSystem.directory(fileSystem.path.join(dir.path, 'FlutterMacOS.framework'));
ErrorHandlingFileSystem.deleteIfExists(framework, recursive: true);
framework.createSync();
operatingSystemUtils.unzip(frameworkZip, framework);
}

View file

@ -308,6 +308,33 @@ void main() {
verify(operatingSystemUtils.chmod(argThat(hasPath(dir.path)), 'a+r,a+x'));
});
testWithoutContext('EngineCachedArtifact removes unzipped FlutterMacOS.framework before replacing', () async {
final OperatingSystemUtils operatingSystemUtils = MockOperatingSystemUtils();
final MockCache cache = MockCache();
final FileSystem fileSystem = MemoryFileSystem.test();
final Directory artifactDir = fileSystem.systemTempDirectory.createTempSync('flutter_cache_test_artifact.');
final Directory downloadDir = fileSystem.systemTempDirectory.createTempSync('flutter_cache_test_download.');
when(cache.getArtifactDirectory(any)).thenReturn(artifactDir);
when(cache.getDownloadDir()).thenReturn(downloadDir);
final Directory binDir = artifactDir.childDirectory('bin_dir')..createSync();
binDir.childFile('FlutterMacOS.framework.zip').createSync();
final Directory unzippedFramework = binDir.childDirectory('FlutterMacOS.framework');
final File staleFile = unzippedFramework.childFile('stale_file')..createSync(recursive: true);
artifactDir.childFile('unused_url_path').createSync();
final FakeCachedArtifact artifact = FakeCachedArtifact(
cache: cache,
binaryDirs: <List<String>>[
<String>['bin_dir', 'unused_url_path'],
],
requiredArtifacts: DevelopmentArtifact.universal,
);
await artifact.updateInner(MockArtifactUpdater(), fileSystem, operatingSystemUtils);
expect(unzippedFramework, exists);
expect(staleFile, isNot(exists));
});
testWithoutContext('IosUsbArtifacts verifies executables for libimobiledevice in isUpToDateInner', () async {
final FileSystem fileSystem = MemoryFileSystem.test();
final Cache cache = Cache.test(fileSystem: fileSystem, processManager: FakeProcessManager.any());