From 02bc11c9be3f9ea6ae323a33c813a4c8561613e6 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Mon, 3 Jun 2024 15:46:02 -0700 Subject: [PATCH] Place `flutter_gpu` in the package cache. (#149299) Resolves https://github.com/flutter/flutter/issues/131711. Fetch https://storage.googleapis.com/flutter_infra_release/flutter/${engine_version}/flutter_gpu.zip and extract it into the package cache. Cannot function until https://github.com/flutter/engine/pull/53107 has been merged/rolled into the framework. --- .../flutter_tools/lib/src/flutter_cache.dart | 2 +- .../test/general.shard/cache_test.dart | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/packages/flutter_tools/lib/src/flutter_cache.dart b/packages/flutter_tools/lib/src/flutter_cache.dart index 9b2c51be5f5..104177f7aaa 100644 --- a/packages/flutter_tools/lib/src/flutter_cache.dart +++ b/packages/flutter_tools/lib/src/flutter_cache.dart @@ -231,7 +231,7 @@ class FlutterSdk extends EngineCachedArtifact { final Platform _platform; @override - List getPackageDirs() => const ['sky_engine']; + List getPackageDirs() => const ['sky_engine', 'flutter_gpu']; @override List> getBinaryDirs() { diff --git a/packages/flutter_tools/test/general.shard/cache_test.dart b/packages/flutter_tools/test/general.shard/cache_test.dart index 220e8fef69a..2b7dfdd9c17 100644 --- a/packages/flutter_tools/test/general.shard/cache_test.dart +++ b/packages/flutter_tools/test/general.shard/cache_test.dart @@ -393,6 +393,44 @@ void main() { expect(operatingSystemUtils.chmods, >[['/.tmp_rand0/flutter_cache_test_artifact.rand0/bin_dir', 'a+r,a+x']]); }); + testWithoutContext('EngineCachedArtifact downloads package zip from expected URL', () async { + final FakeOperatingSystemUtils operatingSystemUtils = FakeOperatingSystemUtils(); + 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.'); + final FakeSecondaryCache cache = FakeSecondaryCache() + ..artifactDirectory = artifactDir + ..downloadDir = downloadDir; + artifactDir.childDirectory('pkg').createSync(); + + final FakeCachedArtifact artifact = FakeCachedArtifact( + cache: cache, + binaryDirs: >[], + packageDirs: [ + 'package_dir', + ], + requiredArtifacts: DevelopmentArtifact.universal, + ); + + Uri? packageUrl; + final ArtifactUpdater artifactUpdater = FakeArtifactUpdater() + ..onDownloadZipArchive = (String message, Uri url, Directory location) { + location.childDirectory('package_dir').createSync(); + packageUrl = url; + }; + + await artifact.updateInner(artifactUpdater, fileSystem, operatingSystemUtils); + expect(packageUrl, isNotNull); + expect(packageUrl.toString(), 'https://storage.googleapis.com/flutter_infra_release/flutter/null/package_dir.zip'); + + final Directory dir = fileSystem.systemTempDirectory + .listSync(recursive: true) + .whereType() + .singleWhereOrNull((Directory directory) => directory.basename == 'pkg')!; + expect(dir.path, artifactDir.childDirectory('pkg').path); + expect(dir.childDirectory('package_dir').existsSync(), isTrue); + }); + testWithoutContext('Try to remove without a parent', () async { final FileSystem fileSystem = MemoryFileSystem.test(); final Directory parent = fileSystem.directory('dir');