Unverified Commit b84ac50d authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tool] Misc. fixes for Fuchsia (#33466)

parent c1d448f3
...@@ -23,7 +23,8 @@ class FuchsiaDevFinder { ...@@ -23,7 +23,8 @@ class FuchsiaDevFinder {
/// formatted as follows: /// formatted as follows:
/// 192.168.42.172 scare-cable-skip-joy /// 192.168.42.172 scare-cable-skip-joy
Future<List<String>> list() async { Future<List<String>> list() async {
if (fuchsiaArtifacts.devFinder == null) { if (fuchsiaArtifacts.devFinder == null ||
!fuchsiaArtifacts.devFinder.existsSync()) {
throwToolExit('Fuchsia dev_finder tool not found.'); throwToolExit('Fuchsia dev_finder tool not found.');
} }
final List<String> command = <String>[ final List<String> command = <String>[
...@@ -45,7 +46,8 @@ class FuchsiaDevFinder { ...@@ -45,7 +46,8 @@ class FuchsiaDevFinder {
/// The string [deviceName] should be the name of the device from the /// The string [deviceName] should be the name of the device from the
/// 'list' command, e.g. 'scare-cable-skip-joy'. /// 'list' command, e.g. 'scare-cable-skip-joy'.
Future<String> resolve(String deviceName) async { Future<String> resolve(String deviceName) async {
if (fuchsiaArtifacts.devFinder == null) { if (fuchsiaArtifacts.devFinder == null ||
!fuchsiaArtifacts.devFinder.existsSync()) {
throwToolExit('Fuchsia dev_finder tool not found.'); throwToolExit('Fuchsia dev_finder tool not found.');
} }
final List<String> command = <String>[ final List<String> command = <String>[
......
...@@ -378,7 +378,7 @@ class FuchsiaDevice extends Device { ...@@ -378,7 +378,7 @@ class FuchsiaDevice extends Device {
const String findCommand = 'find /hub -name vmservice-port'; const String findCommand = 'find /hub -name vmservice-port';
final RunResult findResult = await shell(findCommand); final RunResult findResult = await shell(findCommand);
if (findResult.exitCode != 0) { if (findResult.exitCode != 0) {
throwToolExit("'$findCommand' on device $id failed"); throwToolExit("'$findCommand' on device $id failed. stderr: '${findResult.stderr}'");
return null; return null;
} }
final String findOutput = findResult.stdout; final String findOutput = findResult.stdout;
......
...@@ -46,7 +46,8 @@ class FuchsiaSdk { ...@@ -46,7 +46,8 @@ class FuchsiaSdk {
/// $ dev_finder list -full /// $ dev_finder list -full
/// > 192.168.42.56 paper-pulp-bush-angel /// > 192.168.42.56 paper-pulp-bush-angel
Future<String> listDevices() async { Future<String> listDevices() async {
if (fuchsiaArtifacts.devFinder == null) { if (fuchsiaArtifacts.devFinder == null ||
!fuchsiaArtifacts.devFinder.existsSync()) {
return null; return null;
} }
final List<String> devices = await fuchsiaDevFinder.list(); final List<String> devices = await fuchsiaDevFinder.list();
...@@ -64,7 +65,8 @@ class FuchsiaSdk { ...@@ -64,7 +65,8 @@ class FuchsiaSdk {
StreamController<String>(onCancel: () { StreamController<String>(onCancel: () {
process.kill(); process.kill();
}); });
if (fuchsiaArtifacts.sshConfig == null) { if (fuchsiaArtifacts.sshConfig == null ||
!fuchsiaArtifacts.sshConfig.existsSync()) {
printError('Cannot read device logs: No ssh config.'); printError('Cannot read device logs: No ssh config.');
printError('Have you set FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR?'); printError('Have you set FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR?');
return null; return null;
...@@ -91,7 +93,7 @@ class FuchsiaSdk { ...@@ -91,7 +93,7 @@ class FuchsiaSdk {
} catch (exception) { } catch (exception) {
printTrace('$exception'); printTrace('$exception');
} }
return null; return const Stream<String>.empty();
} }
} }
......
...@@ -240,6 +240,8 @@ void main() { ...@@ -240,6 +240,8 @@ void main() {
when(mockProcess.stderr).thenAnswer((Invocation _) => stderr.stream); when(mockProcess.stderr).thenAnswer((Invocation _) => stderr.stream);
devFinder = MockFile(); devFinder = MockFile();
sshConfig = MockFile(); sshConfig = MockFile();
when(devFinder.existsSync()).thenReturn(true);
when(sshConfig.existsSync()).thenReturn(true);
when(devFinder.absolute).thenReturn(devFinder); when(devFinder.absolute).thenReturn(devFinder);
when(sshConfig.absolute).thenReturn(sshConfig); when(sshConfig.absolute).thenReturn(sshConfig);
}); });
......
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