Unverified Commit ad7e2f7b authored by Dan Field's avatar Dan Field Committed by GitHub

Disable Fuchsia SDK usage unless opted in (#123084)

Disable Fuchsia SDK usage unless opted in
parent 20de2a28
...@@ -8,6 +8,7 @@ import '../base/file_system.dart'; ...@@ -8,6 +8,7 @@ import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/platform.dart'; import '../base/platform.dart';
import '../convert.dart'; import '../convert.dart';
import '../features.dart' show featureFlags;
import '../globals.dart' as globals; import '../globals.dart' as globals;
import 'fuchsia_ffx.dart'; import 'fuchsia_ffx.dart';
...@@ -16,7 +17,7 @@ import 'fuchsia_pm.dart'; ...@@ -16,7 +17,7 @@ import 'fuchsia_pm.dart';
/// Returns [true] if the current platform supports Fuchsia targets. /// Returns [true] if the current platform supports Fuchsia targets.
bool isFuchsiaSupportedPlatform(Platform platform) { bool isFuchsiaSupportedPlatform(Platform platform) {
return platform.isLinux || platform.isMacOS; return featureFlags.isFuchsiaEnabled && (platform.isLinux || platform.isMacOS);
} }
/// The Fuchsia SDK shell commands. /// The Fuchsia SDK shell commands.
......
...@@ -17,6 +17,7 @@ import 'package:flutter_tools/src/build_info.dart'; ...@@ -17,6 +17,7 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/device_port_forwarder.dart'; import 'package:flutter_tools/src/device_port_forwarder.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_device.dart'; import 'package:flutter_tools/src/fuchsia/fuchsia_device.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_ffx.dart'; import 'package:flutter_tools/src/fuchsia/fuchsia_ffx.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_kernel_compiler.dart'; import 'package:flutter_tools/src/fuchsia/fuchsia_kernel_compiler.dart';
...@@ -32,6 +33,7 @@ import 'package:vm_service/vm_service.dart' as vm_service; ...@@ -32,6 +33,7 @@ import 'package:vm_service/vm_service.dart' as vm_service;
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
import '../../src/fake_vm_services.dart'; import '../../src/fake_vm_services.dart';
import '../../src/fakes.dart';
final vm_service.Isolate fakeIsolate = vm_service.Isolate( final vm_service.Isolate fakeIsolate = vm_service.Isolate(
id: '1', id: '1',
...@@ -483,6 +485,7 @@ void main() { ...@@ -483,6 +485,7 @@ void main() {
expect(device.supportsScreenshot, true); expect(device.supportsScreenshot, true);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => FakePlatform(), Platform: () => FakePlatform(),
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
}); });
testUsingContext('is not supported on Windows', () { testUsingContext('is not supported on Windows', () {
...@@ -493,6 +496,7 @@ void main() { ...@@ -493,6 +496,7 @@ void main() {
Platform: () => FakePlatform( Platform: () => FakePlatform(
operatingSystem: 'windows', operatingSystem: 'windows',
), ),
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
}); });
test("takeScreenshot throws if file isn't .ppm", () async { test("takeScreenshot throws if file isn't .ppm", () async {
...@@ -532,6 +536,7 @@ void main() { ...@@ -532,6 +536,7 @@ void main() {
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh', 'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
}, },
), ),
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
}); });
testUsingContext('takeScreenshot throws if scp failed', () async { testUsingContext('takeScreenshot throws if scp failed', () async {
...@@ -582,6 +587,7 @@ void main() { ...@@ -582,6 +587,7 @@ void main() {
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh', 'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
}, },
), ),
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
}); });
testUsingContext( testUsingContext(
...@@ -632,6 +638,7 @@ void main() { ...@@ -632,6 +638,7 @@ void main() {
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh', 'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
}, },
), ),
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
}, testOn: 'posix'); }, testOn: 'posix');
testUsingContext('takeScreenshot returns', () async { testUsingContext('takeScreenshot returns', () async {
...@@ -674,6 +681,7 @@ void main() { ...@@ -674,6 +681,7 @@ void main() {
'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh', 'FUCHSIA_SSH_CONFIG': '/fuchsia/out/default/.ssh',
}, },
), ),
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
}); });
}); });
......
...@@ -6,12 +6,15 @@ import 'package:file/file.dart'; ...@@ -6,12 +6,15 @@ import 'package:file/file.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_ffx.dart'; import 'package:flutter_tools/src/fuchsia/fuchsia_ffx.dart';
import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart'; import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/fake_process_manager.dart'; import '../../src/context.dart';
import '../../src/fakes.dart';
void main() { void main() {
late FakeFuchsiaArtifacts fakeFuchsiaArtifacts; late FakeFuchsiaArtifacts fakeFuchsiaArtifacts;
...@@ -27,6 +30,22 @@ void main() { ...@@ -27,6 +30,22 @@ void main() {
fakeFuchsiaArtifacts.ffx = ffx; fakeFuchsiaArtifacts.ffx = ffx;
}); });
testUsingContext('isFuchsiaSupportedPlatform returns true when opted in on Linux and macOS', () {
expect(isFuchsiaSupportedPlatform(FakePlatform(operatingSystem: 'macos')), true);
expect(isFuchsiaSupportedPlatform(FakePlatform()), true);
expect(isFuchsiaSupportedPlatform(FakePlatform(operatingSystem: 'windows')), false);
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isFuchsiaEnabled: true),
});
testUsingContext('isFuchsiaSupportedPlatform returns false when opted out on Linux and macOS', () {
expect(isFuchsiaSupportedPlatform(FakePlatform(operatingSystem: 'macos')), false);
expect(isFuchsiaSupportedPlatform(FakePlatform()), false);
expect(isFuchsiaSupportedPlatform(FakePlatform(operatingSystem: 'windows')), false);
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(),
});
group('ffx list', () { group('ffx list', () {
testWithoutContext('ffx not found', () { testWithoutContext('ffx not found', () {
final FuchsiaFfx fuchsiaFfx = FuchsiaFfx( final FuchsiaFfx fuchsiaFfx = FuchsiaFfx(
......
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