Unverified Commit 5b943257 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

fix list devices throwing on junk input (#27615)

parent 7da989f2
......@@ -115,7 +115,7 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
return <Device>[];
}
final String text = await fuchsiaSdk.listDevices();
if (text == null) {
if (text == null || text.isEmpty) {
return <Device>[];
}
final List<FuchsiaDevice> devices = parseListDevices(text);
......@@ -133,6 +133,9 @@ List<FuchsiaDevice> parseListDevices(String text) {
final String line = rawLine.trim();
// ['ip', 'device name']
final List<String> words = line.split(' ');
if (words.length < 2) {
continue;
}
final String name = words[1];
final String id = words[0];
devices.add(FuchsiaDevice(id, name: name));
......
......@@ -40,6 +40,13 @@ void main() {
expect(names.first.id, '192.168.42.56');
});
test('parse junk dev_finder output', () {
const String example = 'junk';
final List<FuchsiaDevice> names = parseListDevices(example);
expect(names.length, 0);
});
test('default capabilities', () async {
final FuchsiaDevice device = FuchsiaDevice('123');
......
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