diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart index 33837f0e37..004ce80d3f 100644 --- a/packages/flutter_tools/lib/src/cache.dart +++ b/packages/flutter_tools/lib/src/cache.dart @@ -47,13 +47,13 @@ class DevelopmentArtifact { static const DevelopmentArtifact web = DevelopmentArtifact._('web', feature: flutterWebFeature); /// Artifacts required for desktop macOS. - static const DevelopmentArtifact macOS = DevelopmentArtifact._('macos', unstable: true); + static const DevelopmentArtifact macOS = DevelopmentArtifact._('macos', feature: flutterMacOSDesktopFeature); /// Artifacts required for desktop Windows. - static const DevelopmentArtifact windows = DevelopmentArtifact._('windows', unstable: true); + static const DevelopmentArtifact windows = DevelopmentArtifact._('windows', feature: flutterWindowsDesktopFeature); /// Artifacts required for desktop Linux. - static const DevelopmentArtifact linux = DevelopmentArtifact._('linux', unstable: true); + static const DevelopmentArtifact linux = DevelopmentArtifact._('linux', feature: flutterLinuxDesktopFeature); /// Artifacts required for Fuchsia. static const DevelopmentArtifact fuchsia = DevelopmentArtifact._('fuchsia', unstable: true); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/precache_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/precache_test.dart index 4eea7facde..681f6601f6 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/precache_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/precache_test.dart @@ -63,6 +63,87 @@ void main() { FeatureFlags: () => TestFeatureFlags(isWebEnabled: false), }); + testUsingContext('precache downloads macOS artifacts on dev branch when macOS is enabled.', () async { + final PrecacheCommand command = PrecacheCommand(); + applyMocksToCommand(command); + await createTestCommandRunner(command).run(const ['precache', '--macos', '--no-android', '--no-ios']); + + expect(artifacts, unorderedEquals({ + DevelopmentArtifact.universal, + DevelopmentArtifact.macOS, + })); + }, overrides: { + Cache: () => cache, + FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true), + }); + + testUsingContext('precache does not download macOS artifacts on dev branch when feature is enabled.', () async { + final PrecacheCommand command = PrecacheCommand(); + applyMocksToCommand(command); + await createTestCommandRunner(command).run(const ['precache', '--macos', '--no-android', '--no-ios']); + + expect(artifacts, unorderedEquals({ + DevelopmentArtifact.universal, + })); + }, overrides: { + Cache: () => cache, + FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false), + }); + + testUsingContext('precache downloads Windows artifacts on dev branch when feature is enabled.', () async { + final PrecacheCommand command = PrecacheCommand(); + applyMocksToCommand(command); + await createTestCommandRunner(command).run(const ['precache', '--windows', '--no-android', '--no-ios']); + + expect(artifacts, unorderedEquals({ + DevelopmentArtifact.universal, + DevelopmentArtifact.windows, + })); + }, overrides: { + Cache: () => cache, + FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true), + }); + + testUsingContext('precache does not download Windows artifacts on dev branch when feature is enabled.', () async { + final PrecacheCommand command = PrecacheCommand(); + applyMocksToCommand(command); + await createTestCommandRunner(command).run(const ['precache', '--windows', '--no-android', '--no-ios']); + + expect(artifacts, unorderedEquals({ + DevelopmentArtifact.universal, + })); + }, overrides: { + Cache: () => cache, + FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: false), + }); + + testUsingContext('precache downloads Linux artifacts on dev branch when feature is enabled.', () async { + final PrecacheCommand command = PrecacheCommand(); + applyMocksToCommand(command); + await createTestCommandRunner(command).run(const ['precache', '--linux', '--no-android', '--no-ios']); + + expect(artifacts, unorderedEquals({ + DevelopmentArtifact.universal, + DevelopmentArtifact.linux, + })); + }, overrides: { + Cache: () => cache, + FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true), + }); + + testUsingContext('precache does not download Linux artifacts on dev branch when feature is enabled.', () async { + final PrecacheCommand command = PrecacheCommand(); + applyMocksToCommand(command); + await createTestCommandRunner(command).run(const ['precache', '--linux', '--no-android', '--no-ios']); + + expect(artifacts, unorderedEquals({ + DevelopmentArtifact.universal, + })); + }, overrides: { + Cache: () => cache, + FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false), + }); + testUsingContext('precache exits if requesting mismatched artifacts.', () async { final PrecacheCommand command = PrecacheCommand(); applyMocksToCommand(command); @@ -107,7 +188,12 @@ void main() { })); }, overrides: { Cache: () => cache, - FeatureFlags: () => TestFeatureFlags(isWebEnabled: true), + FeatureFlags: () => TestFeatureFlags( + isWebEnabled: true, + isLinuxEnabled: true, + isMacOSEnabled: true, + isWindowsEnabled: true, + ), FlutterVersion: () => masterFlutterVersion, }); diff --git a/packages/flutter_tools/test/general.shard/cache_test.dart b/packages/flutter_tools/test/general.shard/cache_test.dart index 868be0a9f2..8d9c0333b6 100644 --- a/packages/flutter_tools/test/general.shard/cache_test.dart +++ b/packages/flutter_tools/test/general.shard/cache_test.dart @@ -264,9 +264,9 @@ void main() { test('Unstable artifacts', () { expect(DevelopmentArtifact.web.unstable, false); - expect(DevelopmentArtifact.linux.unstable, true); - expect(DevelopmentArtifact.macOS.unstable, true); - expect(DevelopmentArtifact.windows.unstable, true); + expect(DevelopmentArtifact.linux.unstable, false); + expect(DevelopmentArtifact.macOS.unstable, false); + expect(DevelopmentArtifact.windows.unstable, false); expect(DevelopmentArtifact.fuchsia.unstable, true); expect(DevelopmentArtifact.flutterRunner.unstable, true); });