Skip to content

Commit a2d62df

Browse files
Use feature flags for desktop cache (flutter#53608)
1 parent aee9e94 commit a2d62df

File tree

3 files changed

+93
-7
lines changed

3 files changed

+93
-7
lines changed

packages/flutter_tools/lib/src/cache.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ class DevelopmentArtifact {
4747
static const DevelopmentArtifact web = DevelopmentArtifact._('web', feature: flutterWebFeature);
4848

4949
/// Artifacts required for desktop macOS.
50-
static const DevelopmentArtifact macOS = DevelopmentArtifact._('macos', unstable: true);
50+
static const DevelopmentArtifact macOS = DevelopmentArtifact._('macos', feature: flutterMacOSDesktopFeature);
5151

5252
/// Artifacts required for desktop Windows.
53-
static const DevelopmentArtifact windows = DevelopmentArtifact._('windows', unstable: true);
53+
static const DevelopmentArtifact windows = DevelopmentArtifact._('windows', feature: flutterWindowsDesktopFeature);
5454

5555
/// Artifacts required for desktop Linux.
56-
static const DevelopmentArtifact linux = DevelopmentArtifact._('linux', unstable: true);
56+
static const DevelopmentArtifact linux = DevelopmentArtifact._('linux', feature: flutterLinuxDesktopFeature);
5757

5858
/// Artifacts required for Fuchsia.
5959
static const DevelopmentArtifact fuchsia = DevelopmentArtifact._('fuchsia', unstable: true);

packages/flutter_tools/test/commands.shard/hermetic/precache_test.dart

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,87 @@ void main() {
6363
FeatureFlags: () => TestFeatureFlags(isWebEnabled: false),
6464
});
6565

66+
testUsingContext('precache downloads macOS artifacts on dev branch when macOS is enabled.', () async {
67+
final PrecacheCommand command = PrecacheCommand();
68+
applyMocksToCommand(command);
69+
await createTestCommandRunner(command).run(const <String>['precache', '--macos', '--no-android', '--no-ios']);
70+
71+
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
72+
DevelopmentArtifact.universal,
73+
DevelopmentArtifact.macOS,
74+
}));
75+
}, overrides: <Type, Generator>{
76+
Cache: () => cache,
77+
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
78+
});
79+
80+
testUsingContext('precache does not download macOS artifacts on dev branch when feature is enabled.', () async {
81+
final PrecacheCommand command = PrecacheCommand();
82+
applyMocksToCommand(command);
83+
await createTestCommandRunner(command).run(const <String>['precache', '--macos', '--no-android', '--no-ios']);
84+
85+
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
86+
DevelopmentArtifact.universal,
87+
}));
88+
}, overrides: <Type, Generator>{
89+
Cache: () => cache,
90+
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false),
91+
});
92+
93+
testUsingContext('precache downloads Windows artifacts on dev branch when feature is enabled.', () async {
94+
final PrecacheCommand command = PrecacheCommand();
95+
applyMocksToCommand(command);
96+
await createTestCommandRunner(command).run(const <String>['precache', '--windows', '--no-android', '--no-ios']);
97+
98+
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
99+
DevelopmentArtifact.universal,
100+
DevelopmentArtifact.windows,
101+
}));
102+
}, overrides: <Type, Generator>{
103+
Cache: () => cache,
104+
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
105+
});
106+
107+
testUsingContext('precache does not download Windows artifacts on dev branch when feature is enabled.', () async {
108+
final PrecacheCommand command = PrecacheCommand();
109+
applyMocksToCommand(command);
110+
await createTestCommandRunner(command).run(const <String>['precache', '--windows', '--no-android', '--no-ios']);
111+
112+
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
113+
DevelopmentArtifact.universal,
114+
}));
115+
}, overrides: <Type, Generator>{
116+
Cache: () => cache,
117+
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: false),
118+
});
119+
120+
testUsingContext('precache downloads Linux artifacts on dev branch when feature is enabled.', () async {
121+
final PrecacheCommand command = PrecacheCommand();
122+
applyMocksToCommand(command);
123+
await createTestCommandRunner(command).run(const <String>['precache', '--linux', '--no-android', '--no-ios']);
124+
125+
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
126+
DevelopmentArtifact.universal,
127+
DevelopmentArtifact.linux,
128+
}));
129+
}, overrides: <Type, Generator>{
130+
Cache: () => cache,
131+
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
132+
});
133+
134+
testUsingContext('precache does not download Linux artifacts on dev branch when feature is enabled.', () async {
135+
final PrecacheCommand command = PrecacheCommand();
136+
applyMocksToCommand(command);
137+
await createTestCommandRunner(command).run(const <String>['precache', '--linux', '--no-android', '--no-ios']);
138+
139+
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
140+
DevelopmentArtifact.universal,
141+
}));
142+
}, overrides: <Type, Generator>{
143+
Cache: () => cache,
144+
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false),
145+
});
146+
66147
testUsingContext('precache exits if requesting mismatched artifacts.', () async {
67148
final PrecacheCommand command = PrecacheCommand();
68149
applyMocksToCommand(command);
@@ -107,7 +188,12 @@ void main() {
107188
}));
108189
}, overrides: <Type, Generator>{
109190
Cache: () => cache,
110-
FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
191+
FeatureFlags: () => TestFeatureFlags(
192+
isWebEnabled: true,
193+
isLinuxEnabled: true,
194+
isMacOSEnabled: true,
195+
isWindowsEnabled: true,
196+
),
111197
FlutterVersion: () => masterFlutterVersion,
112198
});
113199

packages/flutter_tools/test/general.shard/cache_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,9 @@ void main() {
264264

265265
test('Unstable artifacts', () {
266266
expect(DevelopmentArtifact.web.unstable, false);
267-
expect(DevelopmentArtifact.linux.unstable, true);
268-
expect(DevelopmentArtifact.macOS.unstable, true);
269-
expect(DevelopmentArtifact.windows.unstable, true);
267+
expect(DevelopmentArtifact.linux.unstable, false);
268+
expect(DevelopmentArtifact.macOS.unstable, false);
269+
expect(DevelopmentArtifact.windows.unstable, false);
270270
expect(DevelopmentArtifact.fuchsia.unstable, true);
271271
expect(DevelopmentArtifact.flutterRunner.unstable, true);
272272
});

0 commit comments

Comments
 (0)