Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
32041c0c
Unverified
Commit
32041c0c
authored
Jan 09, 2019
by
Jonah Williams
Committed by
GitHub
Jan 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reland: Switch to dev_finder (#26250)
parent
6f1d10b7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
104 deletions
+51
-104
fuchsia_attach.dart
packages/flutter_tools/bin/fuchsia_attach.dart
+2
-1
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+8
-18
fuchsia_sdk.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart
+12
-50
fuchsia_workflow.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_workflow.dart
+3
-3
fuchsa_device_test.dart
packages/flutter_tools/test/fuchsia/fuchsa_device_test.dart
+9
-22
fuchsia_workflow_test.dart
...ges/flutter_tools/test/fuchsia/fuchsia_workflow_test.dart
+17
-10
No files found.
packages/flutter_tools/bin/fuchsia_attach.dart
View file @
32041c0c
...
...
@@ -41,6 +41,7 @@ Future<void> main(List<String> args) async {
final
String
buildDirectory
=
argResults
[
'build-dir'
];
final
File
frontendServer
=
fs
.
file
(
'
$buildDirectory
/host_x64/gen/third_party/flutter/frontend_server/frontend_server_tool.snapshot'
);
final
File
sshConfig
=
fs
.
file
(
'
$buildDirectory
/ssh-keys/ssh_config'
);
final
File
devFinder
=
fs
.
file
(
'
$buildDirectory
/host_x64/dev_finder'
);
final
File
platformKernelDill
=
fs
.
file
(
'
$buildDirectory
/flutter_runner_patched_sdk/platform_strong.dill'
);
final
File
flutterPatchedSdk
=
fs
.
file
(
'
$buildDirectory
/flutter_runner_patched_sdk'
);
final
String
packages
=
'
$buildDirectory
/dartlang/gen/
$path
/
${name}
_dart_library.packages'
;
...
...
@@ -91,7 +92,7 @@ Future<void> main(List<String> args) async {
muteCommandLogging:
false
,
verboseHelp:
false
,
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
,
devFinder:
devFinder
),
Artifacts:
()
=>
OverrideArtifacts
(
parent:
CachedArtifacts
(),
frontendServer:
frontendServer
,
...
...
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
32041c0c
...
...
@@ -108,12 +108,8 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
if
(!
fuchsiaWorkflow
.
canListDevices
)
{
return
<
Device
>[];
}
final
String
text
=
await
fuchsiaSdk
.
netls
();
final
List
<
FuchsiaDevice
>
devices
=
<
FuchsiaDevice
>[];
for
(
String
name
in
parseFuchsiaDeviceOutput
(
text
))
{
final
String
id
=
await
fuchsiaSdk
.
netaddr
();
devices
.
add
(
FuchsiaDevice
(
id
,
name:
name
));
}
final
String
text
=
await
fuchsiaSdk
.
listDevices
();
final
List
<
FuchsiaDevice
>
devices
=
parseListDevices
(
text
);
return
devices
;
}
...
...
@@ -121,24 +117,18 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
Future
<
List
<
String
>>
getDiagnostics
()
async
=>
const
<
String
>[];
}
/// Parses output from the netls tool into fuchsia devices names.
///
/// Example output:
/// $ ./netls
/// > device liliac-shore-only-last (fe80::82e4:da4d:fe81:227d/3)
@visibleForTesting
List
<
String
>
parseFuchsiaDeviceOutput
(
String
text
)
{
final
List
<
String
>
names
=
<
String
>[];
List
<
FuchsiaDevice
>
parseListDevices
(
String
text
)
{
final
List
<
FuchsiaDevice
>
devices
=
<
FuchsiaDevice
>[];
for
(
String
rawLine
in
text
.
trim
().
split
(
'
\n
'
))
{
final
String
line
=
rawLine
.
trim
();
if
(!
line
.
startsWith
(
'device'
))
continue
;
// ['device', 'device name', '(id)']
// ['ip', 'device name']
final
List
<
String
>
words
=
line
.
split
(
' '
);
final
String
name
=
words
[
1
];
names
.
add
(
name
);
final
String
id
=
words
[
0
];
devices
.
add
(
FuchsiaDevice
(
id
,
name:
name
));
}
return
nam
es
;
return
devic
es
;
}
class
FuchsiaDevice
extends
Device
{
...
...
packages/flutter_tools/lib/src/fuchsia/fuchsia_sdk.dart
View file @
32041c0c
...
...
@@ -9,7 +9,6 @@ import '../base/common.dart';
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/platform.dart'
;
import
'../base/process.dart'
;
import
'../base/process_manager.dart'
;
...
...
@@ -24,21 +23,15 @@ FuchsiaArtifacts get fuchsiaArtifacts => context[FuchsiaArtifacts];
/// This workflow assumes development within the fuchsia source tree,
/// including a working fx command-line tool in the user's PATH.
class
FuchsiaSdk
{
static
const
List
<
String
>
_netaddrCommand
=
<
String
>[
'fx'
,
'netaddr'
,
'--fuchsia'
,
'--nowait'
];
static
const
List
<
String
>
_netlsCommand
=
<
String
>[
'fx'
,
'netls'
,
'--nowait'
];
static
const
List
<
String
>
_syslogCommand
=
<
String
>[
'fx'
,
'syslog'
,
'--clock'
,
'Local'
];
/// Invokes the `netaddr` command.
///
/// This returns the network address of an attached fuchsia device. Does
/// not currently support multiple attached devices.
///
/// Example output:
///
$ fx netaddr --fuchsia --nowait
///
> fe80::9aaa:fcff:fe60:d3af%eth1
Future
<
String
>
netaddr
()
async
{
///
$ dev_finder list -full
///
> 192.168.42.56 paper-pulp-bush-angel
Future
<
String
>
listDevices
()
async
{
try
{
final
RunResult
process
=
await
runAsync
(
_netaddrCommand
);
final
String
path
=
fuchsiaArtifacts
.
devFinder
.
absolute
.
path
;
final
RunResult
process
=
await
runAsync
(<
String
>[
path
,
'list'
,
'-full'
]);
return
process
.
stdout
.
trim
();
}
on
ArgumentError
catch
(
exception
)
{
throwToolExit
(
'
$exception
'
);
...
...
@@ -69,49 +62,18 @@ class FuchsiaSdk {
}
return
null
;
}
/// Invokes the `netls` command.
///
/// This lists attached fuchsia devices with their name and address. Does
/// not currently support multiple attached devices.
///
/// Example output:
/// $ fx netls --nowait
/// > device liliac-shore-only-last (fe80::82e4:da4d:fe81:227d/3)
Future
<
String
>
netls
()
async
{
try
{
final
RunResult
process
=
await
runAsync
(
_netlsCommand
);
return
process
.
stdout
;
}
on
ArgumentError
catch
(
exception
)
{
throwToolExit
(
'
$exception
'
);
}
return
null
;
}
}
/// Fuchsia-specific artifacts used to interact with a device.
class
FuchsiaArtifacts
{
/// Creates a new [FuchsiaArtifacts].
///
/// May optionally provide a file `sshConfig` file.
FuchsiaArtifacts
({
File
sshConfig
})
:
_sshConfig
=
sshConfig
;
FuchsiaArtifacts
({
this
.
sshConfig
,
this
.
devFinder
});
/// The location of the SSH configuration file used to interact with a
/// fuchsia device.
///
/// Requires the env variable `BUILD_DIR` to be set if not provided by
/// the constructor.
File
get
sshConfig
{
if
(
_sshConfig
==
null
)
{
final
String
buildDirectory
=
platform
.
environment
[
'BUILD_DIR'
];
if
(
buildDirectory
==
null
)
{
throwToolExit
(
'BUILD_DIR must be supplied to locate SSH keys. For example:
\n
'
' export BUILD_DIR=path/to/fuchsia/out/x64
\n
'
);
}
_sshConfig
=
fs
.
file
(
'
$buildDirectory
/ssh-keys/ssh_config'
);
}
return
_sshConfig
;
}
File
_sshConfig
;
/// Fuchsia device.
final
File
sshConfig
;
/// The location of the dev finder tool used to locate connected
/// Fuchsia devices.
final
File
devFinder
;
}
packages/flutter_tools/lib/src/fuchsia/fuchsia_workflow.dart
View file @
32041c0c
...
...
@@ -3,9 +3,9 @@
// found in the LICENSE file.
import
'../base/context.dart'
;
import
'../base/os.dart'
;
import
'../base/platform.dart'
;
import
'../doctor.dart'
;
import
'fuchsia_sdk.dart'
;
/// The [FuchsiaWorkflow] instance.
FuchsiaWorkflow
get
fuchsiaWorkflow
=>
context
[
FuchsiaWorkflow
];
...
...
@@ -21,12 +21,12 @@ class FuchsiaWorkflow implements Workflow {
@override
bool
get
canListDevices
{
return
os
.
which
(
'fx'
)
!=
null
;
return
fuchsiaArtifacts
.
devFinder
!=
null
;
}
@override
bool
get
canLaunchDevices
{
return
os
.
which
(
'fx'
)
!=
null
;
return
fuchsiaArtifacts
.
devFinder
!=
null
&&
fuchsiaArtifacts
.
sshConfig
!=
null
;
}
@override
...
...
packages/flutter_tools/test/fuchsia/fuchsa_device_test.dart
View file @
32041c0c
...
...
@@ -29,12 +29,13 @@ void main() {
expect
(
device
.
name
,
name
);
});
test
(
'parse
netls log
output'
,
()
{
const
String
example
=
'
device lilia-shore-only-last (fe80::0000:a00a:f00f:2002/3)
'
;
final
List
<
String
>
names
=
parseFuchsiaDeviceOutput
(
example
);
test
(
'parse
dev_finder
output'
,
()
{
const
String
example
=
'
192.168.42.56 paper-pulp-bush-angel
'
;
final
List
<
FuchsiaDevice
>
names
=
parseListDevices
(
example
);
expect
(
names
.
length
,
1
);
expect
(
names
.
first
,
'lilia-shore-only-last'
);
expect
(
names
.
first
.
name
,
'paper-pulp-bush-angel'
);
expect
(
names
.
first
.
id
,
'192.168.42.56'
);
});
test
(
'default capabilities'
,
()
async
{
...
...
@@ -50,7 +51,6 @@ void main() {
group
(
'displays friendly error when'
,
()
{
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
final
MockProcessResult
mockProcessResult
=
MockProcessResult
();
final
MockFuchsiaArtifacts
mockFuchsiaArtifacts
=
MockFuchsiaArtifacts
();
final
MockFile
mockFile
=
MockFile
();
when
(
mockProcessManager
.
run
(
any
,
...
...
@@ -60,23 +60,9 @@ void main() {
when
(
mockProcessResult
.
exitCode
).
thenReturn
(
1
);
when
<
String
>(
mockProcessResult
.
stdout
).
thenReturn
(
''
);
when
<
String
>(
mockProcessResult
.
stderr
).
thenReturn
(
''
);
when
(
mockFuchsiaArtifacts
.
sshConfig
).
thenReturn
(
mockFile
);
when
(
mockFile
.
absolute
).
thenReturn
(
mockFile
);
when
(
mockFile
.
path
).
thenReturn
(
''
);
testUsingContext
(
'No BUILD_DIR set'
,
()
async
{
final
FuchsiaDevice
device
=
FuchsiaDevice
(
'id'
);
ToolExit
toolExit
;
try
{
await
device
.
servicePorts
();
}
on
ToolExit
catch
(
err
)
{
toolExit
=
err
;
}
expect
(
toolExit
.
message
,
contains
(
'BUILD_DIR must be supplied to locate SSH keys'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
});
final
MockProcessManager
emptyStdoutProcessManager
=
MockProcessManager
();
final
MockProcessResult
emptyStdoutProcessResult
=
MockProcessResult
();
when
(
emptyStdoutProcessManager
.
run
(
...
...
@@ -99,7 +85,10 @@ void main() {
expect
(
toolExit
.
message
,
contains
(
'No Dart Observatories found. Are you running a debug build?'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
emptyStdoutProcessManager
,
FuchsiaArtifacts:
()
=>
mockFuchsiaArtifacts
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
mockFile
,
devFinder:
mockFile
,
),
});
group
(
'device logs'
,
()
{
...
...
@@ -211,8 +200,6 @@ void main() {
});
}
class
MockFuchsiaArtifacts
extends
Mock
implements
FuchsiaArtifacts
{}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockProcessResult
extends
Mock
implements
ProcessResult
{}
...
...
packages/flutter_tools/test/fuchsia/fuchsia_workflow_test.dart
View file @
32041c0c
...
...
@@ -4,6 +4,7 @@
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart'
;
import
'package:flutter_tools/src/fuchsia/fuchsia_workflow.dart'
;
import
'package:mockito/mockito.dart'
;
...
...
@@ -14,28 +15,34 @@ class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {}
class
MockFile
extends
Mock
implements
File
{}
void
main
(
)
{
bool
fxPresent
=
false
;
final
MockOperatingSystemUtils
utils
=
MockOperatingSystemUtils
();
final
MockFile
file
=
MockFile
();
when
(
utils
.
which
(
'fx'
)).
thenAnswer
((
Invocation
_
)
=>
fxPresent
?
file
:
null
);
group
(
'android workflow'
,
()
{
testUsingContext
(
'can not list and launch devices if there is no `fx` command'
,
()
{
fxPresent
=
false
;
final
MockFile
devFinder
=
MockFile
();
final
MockFile
sshConfig
=
MockFile
();
when
(
devFinder
.
absolute
).
thenReturn
(
devFinder
);
when
(
sshConfig
.
absolute
).
thenReturn
(
sshConfig
);
testUsingContext
(
'can not list and launch devices if there is not ssh config and dev finder'
,
()
{
expect
(
fuchsiaWorkflow
.
canLaunchDevices
,
false
);
expect
(
fuchsiaWorkflow
.
canListDevices
,
false
);
expect
(
fuchsiaWorkflow
.
canListEmulators
,
false
);
},
overrides:
<
Type
,
Generator
>{
OperatingSystemUtils:
()
=>
utils
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
devFinder:
null
,
sshConfig:
null
),
});
testUsingContext
(
'can not list and launch devices if there is not ssh config and dev finder'
,
()
{
expect
(
fuchsiaWorkflow
.
canLaunchDevices
,
false
);
expect
(
fuchsiaWorkflow
.
canListDevices
,
true
);
expect
(
fuchsiaWorkflow
.
canListEmulators
,
false
);
},
overrides:
<
Type
,
Generator
>{
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
devFinder:
devFinder
,
sshConfig:
null
),
});
testUsingContext
(
'can list and launch devices supported if there is a `fx` command'
,
()
{
fxPresent
=
true
;
expect
(
fuchsiaWorkflow
.
canLaunchDevices
,
true
);
expect
(
fuchsiaWorkflow
.
canListDevices
,
true
);
expect
(
fuchsiaWorkflow
.
canListEmulators
,
false
);
},
overrides:
<
Type
,
Generator
>{
OperatingSystemUtils:
()
=>
utils
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
devFinder:
devFinder
,
sshConfig:
sshConfig
)
,
});
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment