@@ -308,6 +308,33 @@ void main() {
308308 verify (operatingSystemUtils.chmod (argThat (hasPath (dir.path)), 'a+r,a+x' ));
309309 });
310310
311+ testWithoutContext ('EngineCachedArtifact removes unzipped FlutterMacOS.framework before replacing' , () async {
312+ final OperatingSystemUtils operatingSystemUtils = MockOperatingSystemUtils ();
313+ final MockCache cache = MockCache ();
314+ final FileSystem fileSystem = MemoryFileSystem .test ();
315+ final Directory artifactDir = fileSystem.systemTempDirectory.createTempSync ('flutter_cache_test_artifact.' );
316+ final Directory downloadDir = fileSystem.systemTempDirectory.createTempSync ('flutter_cache_test_download.' );
317+
318+ when (cache.getArtifactDirectory (any)).thenReturn (artifactDir);
319+ when (cache.getDownloadDir ()).thenReturn (downloadDir);
320+ final Directory binDir = artifactDir.childDirectory ('bin_dir' )..createSync ();
321+ binDir.childFile ('FlutterMacOS.framework.zip' ).createSync ();
322+ final Directory unzippedFramework = binDir.childDirectory ('FlutterMacOS.framework' );
323+ final File staleFile = unzippedFramework.childFile ('stale_file' )..createSync (recursive: true );
324+ artifactDir.childFile ('unused_url_path' ).createSync ();
325+
326+ final FakeCachedArtifact artifact = FakeCachedArtifact (
327+ cache: cache,
328+ binaryDirs: < List <String >> [
329+ < String > ['bin_dir' , 'unused_url_path' ],
330+ ],
331+ requiredArtifacts: DevelopmentArtifact .universal,
332+ );
333+ await artifact.updateInner (MockArtifactUpdater (), fileSystem, operatingSystemUtils);
334+ expect (unzippedFramework, exists);
335+ expect (staleFile, isNot (exists));
336+ });
337+
311338 testWithoutContext ('IosUsbArtifacts verifies executables for libimobiledevice in isUpToDateInner' , () async {
312339 final FileSystem fileSystem = MemoryFileSystem .test ();
313340 final Cache cache = Cache .test (fileSystem: fileSystem, processManager: FakeProcessManager .any ());
0 commit comments