From 4b1b65118ef0d2e18647f653ce5342820106da75 Mon Sep 17 00:00:00 2001 From: omerlevran46 <44589502+omerlevran46@users.noreply.github.com> Date: Wed, 13 Oct 2021 16:04:27 -0400 Subject: [PATCH] [fuchsia] - remove device-finder for device discovery (#91502) device-finder binary is being from removed from the Fuchsia SDK in fxb/85985. --- .../flutter_tools/bin/fuchsia_attach.dart | 8 +- .../lib/src/fuchsia/fuchsia_dev_finder.dart | 88 ------------ .../lib/src/fuchsia/fuchsia_device.dart | 14 +- .../lib/src/fuchsia/fuchsia_pm.dart | 4 +- .../lib/src/fuchsia/fuchsia_sdk.dart | 34 +---- .../lib/src/fuchsia/fuchsia_workflow.dart | 15 -- .../fuchsia/fuchsia_dev_finder_test.dart | 134 ------------------ .../fuchsia/fuchsia_device_start_test.dart | 18 --- .../fuchsia/fuchsia_device_test.dart | 101 ++----------- .../fuchsia/fuchsia_workflow_test.dart | 45 +----- 10 files changed, 23 insertions(+), 438 deletions(-) delete mode 100644 packages/flutter_tools/lib/src/fuchsia/fuchsia_dev_finder.dart delete mode 100644 packages/flutter_tools/test/general.shard/fuchsia/fuchsia_dev_finder_test.dart diff --git a/packages/flutter_tools/bin/fuchsia_attach.dart b/packages/flutter_tools/bin/fuchsia_attach.dart index 1000c5e805..371eef81c9 100644 --- a/packages/flutter_tools/bin/fuchsia_attach.dart +++ b/packages/flutter_tools/bin/fuchsia_attach.dart @@ -29,7 +29,6 @@ final ArgParser parser = ArgParser() ..addOption('target', help: 'The GN target to attach to') ..addOption('entrypoint', defaultsTo: 'main.dart', help: 'The filename of the main method. Defaults to main.dart') ..addOption('device', help: 'The device id to attach to') - ..addOption('dev-finder', help: 'The location of the device-finder binary') ..addOption('ffx', help: 'The location of the ffx binary') ..addFlag('verbose', negatable: true); @@ -48,7 +47,6 @@ Future main(List args) async { final String buildDirectory = argResults['build-dir'] as String; final File frontendServer = globals.fs.file('$buildDirectory/host_x64/gen/third_party/flutter/frontend_server/frontend_server_tool.snapshot'); final File sshConfig = globals.fs.file('$buildDirectory/ssh-keys/ssh_config'); - final File devFinder = globals.fs.file(argResults['dev-finder']); final File ffx = globals.fs.file(argResults['ffx']); final File platformKernelDill = globals.fs.file('$buildDirectory/flutter_runner_patched_sdk/platform_strong.dill'); final File flutterPatchedSdk = globals.fs.file('$buildDirectory/flutter_runner_patched_sdk'); @@ -60,10 +58,6 @@ Future main(List args) async { originalWorkingDirectory = globals.fs.currentDirectory.path; globals.fs.currentDirectory = path; - if (!devFinder.existsSync()) { - print('Error: device-finder not found at ${devFinder.path}.'); - return 1; - } if (!ffx.existsSync()) { print('Error: ffx not found at ${ffx.path}.'); return 1; @@ -112,7 +106,7 @@ Future main(List args) async { FeatureFlags: () => const _FuchsiaFeatureFlags(), DeviceManager: () => _FuchsiaDeviceManager(), FuchsiaArtifacts: () => FuchsiaArtifacts( - sshConfig: sshConfig, devFinder: devFinder, ffx: ffx), + sshConfig: sshConfig, ffx: ffx), Artifacts: () => OverrideArtifacts( parent: CachedArtifacts( fileSystem: globals.fs, diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_dev_finder.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_dev_finder.dart deleted file mode 100644 index 8cbbde9776..0000000000 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_dev_finder.dart +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:file/file.dart'; -import 'package:process/process.dart'; - -import '../base/common.dart'; -import '../base/logger.dart'; -import '../base/process.dart'; -import 'fuchsia_sdk.dart'; - -// Usage: device-finder -// -// Subcommands: -// commands list all command names -// flags describe all known top-level flags -// help describe subcommands and their syntax -// list lists all Fuchsia devices on the network -// resolve attempts to resolve all passed Fuchsia domain names on the -// network - -/// A simple wrapper for the Fuchsia SDK's 'device-finder' tool. -class FuchsiaDevFinder { - FuchsiaDevFinder({ - required FuchsiaArtifacts? fuchsiaArtifacts, - required Logger logger, - required ProcessManager processManager, - }) - : _fuchsiaArtifacts = fuchsiaArtifacts, - _logger = logger, - _processUtils = ProcessUtils(logger: logger, processManager: processManager); - - final FuchsiaArtifacts? _fuchsiaArtifacts; - final Logger _logger; - final ProcessUtils _processUtils; - - /// Returns a list of attached devices as a list of strings with entries - /// formatted as follows: - /// - /// 192.168.42.172 scare-cable-skip-joy - Future?> list({ Duration? timeout }) async { - final File? devFinder = _fuchsiaArtifacts?.devFinder; - if (devFinder == null || !devFinder.existsSync()) { - throwToolExit('Fuchsia device-finder tool not found.'); - } - final List command = [ - devFinder.path, - 'list', - '-full', - if (timeout != null) - ...['-timeout', '${timeout.inMilliseconds}ms'] - ]; - final RunResult result = await _processUtils.run(command); - if (result.exitCode != 0) { - // No devices returns error code 1. - // https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=48563 - if (!result.stderr.contains('no devices found')) { - _logger.printError('device-finder failed: ${result.stderr}'); - } - return null; - } - return result.stdout.split('\n'); - } - - /// Returns the address of the named device. - /// - /// The string [deviceName] should be the name of the device from the - /// 'list' command, e.g. 'scare-cable-skip-joy'. - Future resolve(String deviceName) async { - final File? devFinder = _fuchsiaArtifacts?.devFinder; - if (devFinder == null || !devFinder.existsSync()) { - throwToolExit('Fuchsia device-finder tool not found.'); - } - final List command = [ - devFinder.path, - 'resolve', - '-device-limit', '1', - deviceName, - ]; - final RunResult result = await _processUtils.run(command); - if (result.exitCode != 0) { - _logger.printError('device-finder failed: ${result.stderr}'); - return null; - } - return result.stdout.trim(); - } -} diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart index 4fc131267e..78e79c2463 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart @@ -191,7 +191,6 @@ class FuchsiaDevices extends PollingDeviceDiscovery { // TODO(omerlevran): Remove once soft transition is complete fxb/67602. final List text = (await _fuchsiaSdk.listDevices( timeout: timeout, - useDeviceFinder: _fuchsiaWorkflow.shouldUseDeviceFinder, ))?.split('\n'); if (text == null || text.isEmpty) { return []; @@ -218,18 +217,9 @@ class FuchsiaDevices extends PollingDeviceDiscovery { return null; } final String name = words[1]; - String resolvedHost; - // TODO(omerlevran): Remove once soft transition is complete fxb/67602. - if (_fuchsiaWorkflow.shouldUseDeviceFinder) { - // TODO(omerlevran): Add support for resolve on the FuchsiaSdk Object. - resolvedHost = await _fuchsiaSdk.fuchsiaDevFinder.resolve( - name, - ); - } else { - // TODO(omerlevran): Add support for resolve on the FuchsiaSdk Object. - resolvedHost = await _fuchsiaSdk.fuchsiaFfx.resolve(name); - } + // TODO(omerlevran): Add support for resolve on the FuchsiaSdk Object. + final String resolvedHost = await _fuchsiaSdk.fuchsiaFfx.resolve(name); if (resolvedHost == null) { _logger.printError('Failed to resolve host for Fuchsia device `$name`'); return null; diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart index 67d98543f0..4ed9973600 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_pm.dart @@ -87,7 +87,7 @@ class FuchsiaPM { /// /// The argument [repoPath] should have previously been an argument to /// [newrepo]. The [host] should be the host reported by - /// [FuchsiaDevFinder.resolve] or [FuchsiaFfx.resolve] and [port] should be an unused port for the + /// [FuchsiaFfx.resolve], and [port] should be an unused port for the /// http server to bind. Future serve(String repoPath, String host, int port) async { final File? pm = globals.fuchsiaArtifacts?.pm; @@ -157,7 +157,7 @@ class FuchsiaPM { /// var server = FuchsiaPackageServer( /// '/path/to/repo', /// 'server_name', -/// await FuchsiaDevFinder.resolve(deviceName), +/// await FuchsiaFfx.resolve(deviceName), /// await freshPort()); /// try { /// await server.start(); diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart index 3ba5978d26..4f8286170b 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart @@ -11,7 +11,6 @@ import '../base/platform.dart'; import '../convert.dart'; import '../globals_null_migrated.dart' as globals; -import 'fuchsia_dev_finder.dart'; import 'fuchsia_ffx.dart'; import 'fuchsia_kernel_compiler.dart'; import 'fuchsia_pm.dart'; @@ -32,13 +31,6 @@ class FuchsiaSdk { /// Interface to the 'pm' tool. late final FuchsiaPM fuchsiaPM = FuchsiaPM(); - /// Interface to the 'device-finder' tool. - late final FuchsiaDevFinder fuchsiaDevFinder = FuchsiaDevFinder( - fuchsiaArtifacts: globals.fuchsiaArtifacts, - logger: globals.logger, - processManager: globals.processManager - ); - /// Interface to the 'kernel_compiler' tool. late final FuchsiaKernelCompiler fuchsiaKernelCompiler = FuchsiaKernelCompiler(); @@ -52,21 +44,12 @@ class FuchsiaSdk { /// Returns any attached devices is a newline-denominated String. /// /// Example output: abcd::abcd:abc:abcd:abcd%qemu scare-cable-skip-joy - Future listDevices({Duration? timeout, bool useDeviceFinder = false}) async { - List? devices; - if (useDeviceFinder) { - final File? devFinder = globals.fuchsiaArtifacts?.devFinder; - if (devFinder == null || !devFinder.existsSync()) { - return null; - } - devices = await fuchsiaDevFinder.list(timeout: timeout); - } else { - final File? ffx = globals.fuchsiaArtifacts?.ffx; - if (ffx == null || !ffx.existsSync()) { - return null; - } - devices = await fuchsiaFfx.list(timeout: timeout); + Future listDevices({Duration? timeout}) async { + final File? ffx = globals.fuchsiaArtifacts?.ffx; + if (ffx == null || !ffx.existsSync()) { + return null; } + final List? devices = await fuchsiaFfx.list(timeout: timeout); if (devices == null) { return null; } @@ -118,7 +101,6 @@ class FuchsiaArtifacts { /// Creates a new [FuchsiaArtifacts]. FuchsiaArtifacts({ this.sshConfig, - this.devFinder, this.ffx, this.pm, }); @@ -147,13 +129,11 @@ class FuchsiaArtifacts { final String fuchsia = globals.cache.getArtifactDirectory('fuchsia').path; final String tools = globals.fs.path.join(fuchsia, 'tools'); - final File devFinder = globals.fs.file(globals.fs.path.join(tools, 'device-finder')); final File ffx = globals.fs.file(globals.fs.path.join(tools, 'x64/ffx')); final File pm = globals.fs.file(globals.fs.path.join(tools, 'pm')); return FuchsiaArtifacts( sshConfig: sshConfig, - devFinder: devFinder.existsSync() ? devFinder : null, ffx: ffx.existsSync() ? ffx : null, pm: pm.existsSync() ? pm : null, ); @@ -166,10 +146,6 @@ class FuchsiaArtifacts { /// Fuchsia device. final File? sshConfig; - /// The location of the dev finder tool used to locate connected - /// Fuchsia devices. - final File? devFinder; - /// The location of the ffx tool used to locate connected /// Fuchsia devices. final File? ffx; diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_workflow.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_workflow.dart index c85ef8aae1..33692e3e60 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_workflow.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_workflow.dart @@ -31,28 +31,13 @@ class FuchsiaWorkflow implements Workflow { @override bool get appliesToHostPlatform => _featureFlags.isFuchsiaEnabled && (_platform.isLinux || _platform.isMacOS); - bool get shouldUseDeviceFinder { - final String? useDeviceFinder = _platform.environment.containsKey('FUCHSIA_DISABLED_ffx_discovery') - ? _platform.environment['FUCHSIA_DISABLED_ffx_discovery'] : '0'; - if (useDeviceFinder == '1') { - return true; - } - return false; - } - @override bool get canListDevices { - if (shouldUseDeviceFinder) { - return _fuchsiaArtifacts.devFinder != null; - } return _fuchsiaArtifacts.ffx != null; } @override bool get canLaunchDevices { - if (shouldUseDeviceFinder) { - return _fuchsiaArtifacts.devFinder != null && _fuchsiaArtifacts.sshConfig != null; - } return _fuchsiaArtifacts.ffx != null && _fuchsiaArtifacts.sshConfig != null; } diff --git a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_dev_finder_test.dart b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_dev_finder_test.dart deleted file mode 100644 index f2e689f893..0000000000 --- a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_dev_finder_test.dart +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:file/file.dart'; -import 'package:file/memory.dart'; -import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/logger.dart'; -import 'package:flutter_tools/src/fuchsia/fuchsia_dev_finder.dart'; -import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart'; -import 'package:test/fake.dart'; - -import '../../src/common.dart'; -import '../../src/fake_process_manager.dart'; - -void main() { - late FakeFuchsiaArtifacts fuchsiaArtifacts; - late BufferLogger logger; - late MemoryFileSystem memoryFileSystem; - late File deviceFinder; - - setUp(() { - fuchsiaArtifacts = FakeFuchsiaArtifacts(); - memoryFileSystem = MemoryFileSystem.test(); - logger = BufferLogger.test(); - deviceFinder = memoryFileSystem.file('device-finder'); - fuchsiaArtifacts.devFinder = deviceFinder; - }); - - group('device-finder list', () { - testWithoutContext('device-finder not found', () { - final FuchsiaDevFinder fuchsiaDevFinder = FuchsiaDevFinder( - fuchsiaArtifacts: fuchsiaArtifacts, - logger: logger, - processManager: FakeProcessManager.any(), - ); - - expect(() async => fuchsiaDevFinder.list(), - throwsToolExit(message: 'Fuchsia device-finder tool not found.')); - }); - - testWithoutContext('no devices', () async { - deviceFinder.createSync(); - - final ProcessManager processManager = FakeProcessManager.list([ - FakeCommand( - command: [ deviceFinder.path, 'list', '-full' ], - exitCode: 1, - stderr: 'list.go:72: no devices found', - ), - ]); - - final FuchsiaDevFinder fuchsiaDevFinder = FuchsiaDevFinder( - fuchsiaArtifacts: fuchsiaArtifacts, - logger: logger, - processManager: processManager, - ); - - expect(await fuchsiaDevFinder.list(), isNull); - expect(logger.errorText, isEmpty); - }); - - testWithoutContext('error', () async { - deviceFinder.createSync(); - - final ProcessManager processManager = FakeProcessManager.list([ - FakeCommand( - command: [ deviceFinder.path, 'list', '-full' ], - exitCode: 1, - stderr: 'unexpected error', - ), - ]); - - final FuchsiaDevFinder fuchsiaDevFinder = FuchsiaDevFinder( - fuchsiaArtifacts: fuchsiaArtifacts, - logger: logger, - processManager: processManager, - ); - - expect(await fuchsiaDevFinder.list(), isNull); - expect(logger.errorText, contains('unexpected error')); - }); - - testWithoutContext('devices found', () async { - deviceFinder.createSync(); - - final ProcessManager processManager = FakeProcessManager.list([ - FakeCommand( - command: [ deviceFinder.path, 'list', '-full' ], - stdout: 'device1\ndevice2', - ), - ]); - - final FuchsiaDevFinder fuchsiaDevFinder = FuchsiaDevFinder( - fuchsiaArtifacts: fuchsiaArtifacts, - logger: logger, - processManager: processManager, - ); - - expect(await fuchsiaDevFinder.list(), ['device1', 'device2']); - expect(logger.errorText, isEmpty); - }); - - testWithoutContext('timeout', () async { - deviceFinder.createSync(); - - final ProcessManager processManager = FakeProcessManager.list([ - FakeCommand( - command: [ - deviceFinder.path, - 'list', - '-full', - '-timeout', - '2000ms', - ], - stdout: 'device1', - ), - ]); - - final FuchsiaDevFinder fuchsiaDevFinder = FuchsiaDevFinder( - fuchsiaArtifacts: fuchsiaArtifacts, - logger: logger, - processManager: processManager, - ); - - expect(await fuchsiaDevFinder.list(timeout: const Duration(seconds: 2)), ['device1']); - }); - }); -} - -class FakeFuchsiaArtifacts extends Fake implements FuchsiaArtifacts { - @override - File? devFinder; -} diff --git a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_start_test.dart b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_start_test.dart index b3418732b1..b590721754 100644 --- a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_start_test.dart +++ b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_start_test.dart @@ -17,7 +17,6 @@ import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/fuchsia/application_package.dart'; -import 'package:flutter_tools/src/fuchsia/fuchsia_dev_finder.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_kernel_compiler.dart'; @@ -746,18 +745,6 @@ class FailingKernelCompiler implements FuchsiaKernelCompiler { } } -class FakeFuchsiaDevFinder implements FuchsiaDevFinder { - @override - Future> list({ Duration timeout }) async { - return ['192.168.11.999 scare-cable-device-finder']; - } - - @override - Future resolve(String deviceName) async { - return '192.168.11.999'; - } -} - class FakeFuchsiaFfx implements FuchsiaFfx { @override Future> list({Duration timeout}) async { @@ -774,11 +761,9 @@ class FakeFuchsiaSdk extends Fake implements FuchsiaSdk { FakeFuchsiaSdk({ FuchsiaPM pm, FuchsiaKernelCompiler compiler, - FuchsiaDevFinder devFinder, FuchsiaFfx ffx, }) : fuchsiaPM = pm ?? FakeFuchsiaPM(), fuchsiaKernelCompiler = compiler ?? FakeFuchsiaKernelCompiler(), - fuchsiaDevFinder = devFinder ?? FakeFuchsiaDevFinder(), fuchsiaFfx = ffx ?? FakeFuchsiaFfx(); @override @@ -787,9 +772,6 @@ class FakeFuchsiaSdk extends Fake implements FuchsiaSdk { @override final FuchsiaKernelCompiler fuchsiaKernelCompiler; - @override - final FuchsiaDevFinder fuchsiaDevFinder; - @override final FuchsiaFfx fuchsiaFfx; } diff --git a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart index 26c4050ff8..31997d73e2 100644 --- a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart +++ b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart @@ -19,7 +19,6 @@ import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device_port_forwarder.dart'; -import 'package:flutter_tools/src/fuchsia/fuchsia_dev_finder.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_kernel_compiler.dart'; @@ -102,7 +101,7 @@ void main() { }); testWithoutContext('can parse ffx output for single device', () async { - final FakeFuchsiaWorkflow fuchsiaWorkflow = FakeFuchsiaWorkflow(shouldUseDeviceFinder: false); + final FakeFuchsiaWorkflow fuchsiaWorkflow = FakeFuchsiaWorkflow(); final FakeFuchsiaSdk fuchsiaSdk = FakeFuchsiaSdk(devices: '2001:0db8:85a3:0000:0000:8a2e:0370:7334 paper-pulp-bush-angel'); final FuchsiaDevices fuchsiaDevices = FuchsiaDevices( platform: FakePlatform(environment: {}), @@ -117,24 +116,8 @@ void main() { expect(device.id, '192.168.42.10'); }); - testWithoutContext('can parse device-finder output for single device', () async { - final FakeFuchsiaWorkflow fuchsiaWorkflow = FakeFuchsiaWorkflow(); - final FakeFuchsiaSdk fuchsiaSdk = FakeFuchsiaSdk(devFinderDevices: '2001:0db8:85a3:0000:0000:8a2e:0370:7334 paper-pulp-bush-angel'); - final FuchsiaDevices fuchsiaDevices = FuchsiaDevices( - platform: FakePlatform(environment: {'FUCHSIA_DISABLED_ffx_discovery': '1'}), - fuchsiaSdk: fuchsiaSdk, - fuchsiaWorkflow: fuchsiaWorkflow, - logger: BufferLogger.test(), - ); - - final Device device = (await fuchsiaDevices.pollingGetDevices()).single; - - expect(device.name, 'paper-pulp-bush-angel'); - expect(device.id, '192.168.11.999'); - }); - testWithoutContext('can parse ffx output for multiple devices', () async { - final FakeFuchsiaWorkflow fuchsiaWorkflow = FakeFuchsiaWorkflow(shouldUseDeviceFinder: false); + final FakeFuchsiaWorkflow fuchsiaWorkflow = FakeFuchsiaWorkflow(); final FakeFuchsiaSdk fuchsiaSdk = FakeFuchsiaSdk(devices: '2001:0db8:85a3:0000:0000:8a2e:0370:7334 paper-pulp-bush-angel\n' '2001:0db8:85a3:0000:0000:8a2e:0370:7335 foo-bar-fiz-buzz' @@ -154,45 +137,9 @@ void main() { expect(devices.last.id, '192.168.42.10'); }); - testWithoutContext('can parse device-finder output for multiple devices', () async { - final FakeFuchsiaWorkflow fuchsiaWorkflow = FakeFuchsiaWorkflow(); - final FakeFuchsiaSdk fuchsiaSdk = FakeFuchsiaSdk(devFinderDevices: - '2001:0db8:85a3:0000:0000:8a2e:0370:7334 paper-pulp-bush-angel\n' - '2001:0db8:85a3:0000:0000:8a2e:0370:7335 foo-bar-fiz-buzz' - ); - final FuchsiaDevices fuchsiaDevices = FuchsiaDevices( - platform: FakePlatform(), - fuchsiaSdk: fuchsiaSdk, - fuchsiaWorkflow: fuchsiaWorkflow, - logger: BufferLogger.test(), - ); - - final List devices = await fuchsiaDevices.pollingGetDevices(); - - expect(devices.first.name, 'paper-pulp-bush-angel'); - expect(devices.first.id, '192.168.11.999'); - expect(devices.last.name, 'foo-bar-fiz-buzz'); - expect(devices.last.id, '192.168.11.999'); - }); - testWithoutContext('can parse junk output from ffx', () async { - final FakeFuchsiaWorkflow fuchsiaWorkflow = FakeFuchsiaWorkflow(shouldUseDeviceFinder: false, canListDevices: false); - final FakeFuchsiaSdk fuchsiaSdk = FakeFuchsiaSdk(devices: 'junk', devFinderDevices: 'junk'); - final FuchsiaDevices fuchsiaDevices = FuchsiaDevices( - platform: FakePlatform(), - fuchsiaSdk: fuchsiaSdk, - fuchsiaWorkflow: fuchsiaWorkflow, - logger: BufferLogger.test(), - ); - - final List devices = await fuchsiaDevices.pollingGetDevices(); - - expect(devices, isEmpty); - }); - - testWithoutContext('can parse junk output from device-finder', () async { - final FakeFuchsiaWorkflow fuchsiaWorkflow = FakeFuchsiaWorkflow(); - final FakeFuchsiaSdk fuchsiaSdk = FakeFuchsiaSdk(devices: 'junk', devFinderDevices: 'junk'); + final FakeFuchsiaWorkflow fuchsiaWorkflow = FakeFuchsiaWorkflow(canListDevices: false); + final FakeFuchsiaSdk fuchsiaSdk = FakeFuchsiaSdk(devices: 'junk'); final FuchsiaDevices fuchsiaDevices = FuchsiaDevices( platform: FakePlatform(), fuchsiaSdk: fuchsiaSdk, @@ -349,7 +296,6 @@ void main() { ProcessManager: () => processManager, FuchsiaArtifacts: () => FuchsiaArtifacts( sshConfig: artifactFile, - devFinder: artifactFile, ffx: artifactFile, ), FuchsiaSdk: () => FakeFuchsiaSdk(), @@ -366,14 +312,12 @@ void main() { '''; FakeProcessManager processManager; - File devFinder; File ffx; File sshConfig; setUp(() { processManager = FakeProcessManager.empty(); final FileSystem memoryFileSystem = MemoryFileSystem.test(); - devFinder = memoryFileSystem.file('device-finder')..writeAsStringSync('\n'); ffx = memoryFileSystem.file('ffx')..writeAsStringSync('\n'); sshConfig = memoryFileSystem.file('ssh_config')..writeAsStringSync('\n'); }); @@ -405,7 +349,7 @@ void main() { ProcessManager: () => processManager, SystemClock: () => SystemClock.fixed(DateTime(2018, 11, 9, 1, 25, 45)), FuchsiaArtifacts: () => - FuchsiaArtifacts(devFinder: devFinder, sshConfig: sshConfig, ffx: ffx), + FuchsiaArtifacts(sshConfig: sshConfig, ffx: ffx), }); testUsingContext('cuts off prior logs', () async { @@ -432,7 +376,7 @@ void main() { }, overrides: { ProcessManager: () => processManager, SystemClock: () => SystemClock.fixed(DateTime(2018, 11, 9, 1, 29, 45)), - FuchsiaArtifacts: () => FuchsiaArtifacts(devFinder: devFinder, sshConfig: sshConfig, ffx: ffx), + FuchsiaArtifacts: () => FuchsiaArtifacts(sshConfig: sshConfig, ffx: ffx), }); testUsingContext('can be parsed for all apps', () async { @@ -463,7 +407,7 @@ void main() { }, overrides: { ProcessManager: () => processManager, SystemClock: () => SystemClock.fixed(DateTime(2018, 11, 9, 1, 25, 45)), - FuchsiaArtifacts: () => FuchsiaArtifacts(devFinder: devFinder, sshConfig: sshConfig, ffx: ffx), + FuchsiaArtifacts: () => FuchsiaArtifacts(sshConfig: sshConfig, ffx: ffx), }); }); }); @@ -940,18 +884,6 @@ class FakeFuchsiaIsolateDiscoveryProtocol implements FuchsiaIsolateDiscoveryProt void dispose() {} } -class FakeFuchsiaDevFinder implements FuchsiaDevFinder { - @override - Future> list({ Duration timeout }) async { - return ['192.168.11.999 scare-cable-device-finder']; - } - - @override - Future resolve(String deviceName) async { - return '192.168.11.999'; - } -} - class FakeFuchsiaFfx implements FuchsiaFfx { @override Future> list({Duration timeout}) async { @@ -968,16 +900,12 @@ class FakeFuchsiaSdk extends Fake implements FuchsiaSdk { FakeFuchsiaSdk({ FuchsiaPM pm, FuchsiaKernelCompiler compiler, - FuchsiaDevFinder devFinder, FuchsiaFfx ffx, String devices, - String devFinderDevices, }) : fuchsiaPM = pm, fuchsiaKernelCompiler = compiler, - fuchsiaDevFinder = devFinder ?? FakeFuchsiaDevFinder(), fuchsiaFfx = ffx ?? FakeFuchsiaFfx(), - _devices = devices, - _devFinderDevices = devFinderDevices; + _devices = devices; @override final FuchsiaPM fuchsiaPM; @@ -985,20 +913,13 @@ class FakeFuchsiaSdk extends Fake implements FuchsiaSdk { @override final FuchsiaKernelCompiler fuchsiaKernelCompiler; - @override - final FuchsiaDevFinder fuchsiaDevFinder; - @override final FuchsiaFfx fuchsiaFfx; final String _devices; - final String _devFinderDevices; @override - Future listDevices({Duration timeout, bool useDeviceFinder = false}) async { - if (useDeviceFinder) { - return _devFinderDevices; - } + Future listDevices({Duration timeout}) async { return _devices; } } @@ -1023,7 +944,6 @@ class FakeFuchsiaWorkflow implements FuchsiaWorkflow { this.canLaunchDevices = true, this.canListDevices = true, this.canListEmulators = true, - this.shouldUseDeviceFinder = true, }); @override @@ -1037,7 +957,4 @@ class FakeFuchsiaWorkflow implements FuchsiaWorkflow { @override bool canListEmulators; - - @override - bool shouldUseDeviceFinder; } diff --git a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_workflow_test.dart b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_workflow_test.dart index 2002cf096c..28a96f8c19 100644 --- a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_workflow_test.dart +++ b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_workflow_test.dart @@ -13,14 +13,13 @@ import '../../src/fakes.dart'; void main() { final FileSystem fileSystem = MemoryFileSystem.test(); - final File devFinder = fileSystem.file('dev_finder'); final File sshConfig = fileSystem.file('ssh_config'); final File ffx = fileSystem.file('ffx'); testWithoutContext('Fuchsia workflow does not apply to host platform if feature is disabled', () { final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow( featureFlags: TestFeatureFlags(), - fuchsiaArtifacts: FuchsiaArtifacts(devFinder: devFinder, sshConfig: sshConfig), + fuchsiaArtifacts: FuchsiaArtifacts(ffx: ffx, sshConfig: sshConfig), platform: FakePlatform(), ); @@ -30,7 +29,7 @@ void main() { testWithoutContext('Fuchsia workflow does not apply to host platform on Windows', () { final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow( featureFlags: TestFeatureFlags(isFuchsiaEnabled: true), - fuchsiaArtifacts: FuchsiaArtifacts(devFinder: devFinder, sshConfig: sshConfig), + fuchsiaArtifacts: FuchsiaArtifacts(ffx: ffx, sshConfig: sshConfig), platform: FakePlatform(operatingSystem: 'windows'), ); @@ -40,7 +39,7 @@ void main() { testWithoutContext('Fuchsia workflow can not list and launch devices if there is no ffx when using default workflow', () { final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow( featureFlags: TestFeatureFlags(), - fuchsiaArtifacts: FuchsiaArtifacts(devFinder: devFinder, sshConfig: sshConfig), + fuchsiaArtifacts: FuchsiaArtifacts(sshConfig: sshConfig), platform: FakePlatform(environment: {}), ); @@ -49,18 +48,6 @@ void main() { expect(fuchsiaWorkflow.canListEmulators, false); }); - testWithoutContext('Fuchsia workflow can not list and launch devices if there is no dev finder when ffx is disabled', () { - final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow( - featureFlags: TestFeatureFlags(), - fuchsiaArtifacts: FuchsiaArtifacts(sshConfig: sshConfig, ffx: ffx), - platform: FakePlatform(environment: {'FUCHSIA_DISABLED_ffx_discovery': '1'}), - ); - - expect(fuchsiaWorkflow.canLaunchDevices, false); - expect(fuchsiaWorkflow.canListDevices, false); - expect(fuchsiaWorkflow.canListEmulators, false); - }); - testWithoutContext('Fuchsia workflow can not launch devices if there is no ssh config when using default workflow', () { final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow( featureFlags: TestFeatureFlags(), @@ -73,18 +60,6 @@ void main() { expect(fuchsiaWorkflow.canListEmulators, false); }); - testWithoutContext('Fuchsia workflow can not launch devices if there is no ssh config when ffx is disabled', () { - final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow( - featureFlags: TestFeatureFlags(), - fuchsiaArtifacts: FuchsiaArtifacts(devFinder: devFinder), - platform: FakePlatform(environment: {'FUCHSIA_DISABLED_ffx_discovery': '1'}), - ); - - expect(fuchsiaWorkflow.canLaunchDevices, false); - expect(fuchsiaWorkflow.canListDevices, true); - expect(fuchsiaWorkflow.canListEmulators, false); - }); - testWithoutContext('Fuchsia workflow can list and launch devices supported with sufficient SDK artifacts when using default workflow', () { final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow( featureFlags: TestFeatureFlags(), @@ -97,22 +72,10 @@ void main() { expect(fuchsiaWorkflow.canListEmulators, false); }); - testWithoutContext('Fuchsia workflow can list and launch devices supported with sufficient SDK artifacts when ffx is disabled', () { - final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow( - featureFlags: TestFeatureFlags(), - fuchsiaArtifacts: FuchsiaArtifacts(devFinder: devFinder, sshConfig: sshConfig), - platform: FakePlatform(environment: {'FUCHSIA_DISABLED_ffx_discovery': '1'}), - ); - - expect(fuchsiaWorkflow.canLaunchDevices, true); - expect(fuchsiaWorkflow.canListDevices, true); - expect(fuchsiaWorkflow.canListEmulators, false); - }); - testWithoutContext('Fuchsia workflow can list and launch devices supported with sufficient SDK artifacts on macOS', () { final FuchsiaWorkflow fuchsiaWorkflow = FuchsiaWorkflow( featureFlags: TestFeatureFlags(), - fuchsiaArtifacts: FuchsiaArtifacts(devFinder: devFinder, sshConfig: sshConfig, ffx: ffx), + fuchsiaArtifacts: FuchsiaArtifacts(sshConfig: sshConfig, ffx: ffx), platform: FakePlatform(operatingSystem: 'macOS', environment: {}), );