Unverified Commit a2d62df3 authored by stuartmorgan's avatar stuartmorgan Committed by GitHub

Use feature flags for desktop cache (#53608)

parent aee9e94c
......@@ -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);
......
......@@ -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 <String>['precache', '--macos', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.macOS,
}));
}, overrides: <Type, Generator>{
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 <String>['precache', '--macos', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
}));
}, overrides: <Type, Generator>{
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 <String>['precache', '--windows', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.windows,
}));
}, overrides: <Type, Generator>{
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 <String>['precache', '--windows', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
}));
}, overrides: <Type, Generator>{
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 <String>['precache', '--linux', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
DevelopmentArtifact.linux,
}));
}, overrides: <Type, Generator>{
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 <String>['precache', '--linux', '--no-android', '--no-ios']);
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
DevelopmentArtifact.universal,
}));
}, overrides: <Type, Generator>{
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: <Type, Generator>{
Cache: () => cache,
FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
FeatureFlags: () => TestFeatureFlags(
isWebEnabled: true,
isLinuxEnabled: true,
isMacOSEnabled: true,
isWindowsEnabled: true,
),
FlutterVersion: () => masterFlutterVersion,
});
......
......@@ -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);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment