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
75c853c8
Unverified
Commit
75c853c8
authored
Feb 17, 2021
by
omerlevran46
Committed by
GitHub
Feb 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fuchsia] - update getting local host address logic (#75981)
parent
894fdea8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
53 deletions
+70
-53
fuchsia_dev_finder.dart
...ges/flutter_tools/lib/src/fuchsia/fuchsia_dev_finder.dart
+1
-5
fuchsia_device.dart
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
+1
-9
fuchsia_device_test.dart
...tools/test/general.shard/fuchsia/fuchsia_device_test.dart
+68
-39
No files found.
packages/flutter_tools/lib/src/fuchsia/fuchsia_dev_finder.dart
View file @
75c853c8
...
...
@@ -68,12 +68,9 @@ class FuchsiaDevFinder {
/// Returns the address of the named device.
///
/// If local is true, then gives the address by which the device reaches the
/// host.
///
/// The string [deviceName] should be the name of the device from the
/// 'list' command, e.g. 'scare-cable-skip-joy'.
Future
<
String
>
resolve
(
String
deviceName
,
{
bool
local
=
false
}
)
async
{
Future
<
String
>
resolve
(
String
deviceName
)
async
{
if
(
_fuchsiaArtifacts
.
devFinder
==
null
||
!
_fuchsiaArtifacts
.
devFinder
.
existsSync
())
{
throwToolExit
(
'Fuchsia device-finder tool not found.'
);
...
...
@@ -81,7 +78,6 @@ class FuchsiaDevFinder {
final
List
<
String
>
command
=
<
String
>[
_fuchsiaArtifacts
.
devFinder
.
path
,
'resolve'
,
if
(
local
)
'-local'
,
'-device-limit'
,
'1'
,
deviceName
,
];
...
...
packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart
View file @
75c853c8
...
...
@@ -211,7 +211,6 @@ class FuchsiaDevices extends PollingDeviceDiscovery {
final
String
name
=
words
[
1
];
final
String
resolvedHost
=
await
_fuchsiaSdk
.
fuchsiaDevFinder
.
resolve
(
name
,
local:
false
,
);
if
(
resolvedHost
==
null
)
{
_logger
.
printError
(
'Failed to resolve host for Fuchsia device `
$name
`'
);
...
...
@@ -297,14 +296,7 @@ class FuchsiaDevice extends Device {
}
// Stop the app if it's currently running.
await
stopApp
(
package
);
final
String
host
=
await
fuchsiaSdk
.
fuchsiaDevFinder
.
resolve
(
name
,
local:
true
,
);
if
(
host
==
null
)
{
globals
.
printError
(
'Failed to resolve host for Fuchsia device'
);
return
LaunchResult
.
failed
();
}
final
String
host
=
await
hostAddress
;
// Find out who the device thinks we are.
final
int
port
=
await
globals
.
os
.
findFreePort
();
if
(
port
==
0
)
{
...
...
packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart
View file @
75c853c8
...
...
@@ -876,16 +876,17 @@ void main() {
FakeOperatingSystemUtils
osUtils
;
FakeFuchsiaDeviceTools
fuchsiaDeviceTools
;
MockFuchsiaSdk
fuchsiaSdk
;
MockFuchsiaArtifacts
fuchsiaArtifacts
;
Artifacts
artifacts
;
FakeProcessManager
fakeSuccessfulProcessManager
;
FakeProcessManager
fakeFailedProcessManager
;
File
sshConfig
;
setUp
(()
{
memoryFileSystem
=
MemoryFileSystem
.
test
();
osUtils
=
FakeOperatingSystemUtils
();
fuchsiaDeviceTools
=
FakeFuchsiaDeviceTools
();
fuchsiaSdk
=
MockFuchsiaSdk
();
fuchsiaArtifacts
=
MockFuchsiaArtifacts
();
sshConfig
=
MemoryFileSystem
.
test
().
file
(
'ssh_config'
)..
writeAsStringSync
(
'
\n
'
);
artifacts
=
Artifacts
.
test
();
for
(
final
BuildMode
mode
in
<
BuildMode
>[
BuildMode
.
debug
,
BuildMode
.
release
])
{
memoryFileSystem
.
file
(
...
...
@@ -908,6 +909,20 @@ void main() {
platform:
TargetPlatform
.
fuchsia_arm64
,
mode:
mode
),
).
createSync
();
}
fakeSuccessfulProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
FakeCommand
(
command:
<
String
>[
'ssh'
,
'-F'
,
sshConfig
.
absolute
.
path
,
'123'
,
r'echo $SSH_CONNECTION'
],
stdout:
'fe80::8c6c:2fff:fe3d:c5e1%ethp0003 50666 fe80::5054:ff:fe63:5e7a%ethp0003 22'
,
),
]);
fakeFailedProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
FakeCommand
(
command:
<
String
>[
'ssh'
,
'-F'
,
sshConfig
.
absolute
.
path
,
'123'
,
r'echo $SSH_CONNECTION'
],
stdout:
''
,
stderr:
''
,
exitCode:
1
,
),
]);
});
Future
<
LaunchResult
>
setupAndStartApp
({
...
...
@@ -949,9 +964,9 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
artifacts
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
()
,
ProcessManager:
()
=>
fakeSuccessfulProcessManager
,
FuchsiaDeviceTools:
()
=>
fuchsiaDeviceTools
,
FuchsiaArtifacts:
()
=>
fuchsiaArtifacts
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
)
,
FuchsiaSdk:
()
=>
fuchsiaSdk
,
OperatingSystemUtils:
()
=>
osUtils
,
});
...
...
@@ -976,9 +991,9 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
artifacts
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
()
,
ProcessManager:
()
=>
fakeSuccessfulProcessManager
,
FuchsiaDeviceTools:
()
=>
fuchsiaDeviceTools
,
FuchsiaArtifacts:
()
=>
fuchsiaArtifacts
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
)
,
FuchsiaSdk:
()
=>
fuchsiaSdk
,
OperatingSystemUtils:
()
=>
osUtils
,
});
...
...
@@ -991,9 +1006,9 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
artifacts
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
()
,
ProcessManager:
()
=>
fakeSuccessfulProcessManager
,
FuchsiaDeviceTools:
()
=>
fuchsiaDeviceTools
,
FuchsiaArtifacts:
()
=>
fuchsiaArtifacts
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
)
,
FuchsiaSdk:
()
=>
fuchsiaSdk
,
OperatingSystemUtils:
()
=>
osUtils
,
});
...
...
@@ -1006,9 +1021,23 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
artifacts
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'Artifact.genSnapshot.TargetPlatform.fuchsia_arm64.release'
,
'--deterministic'
,
'--snapshot_kind=app-aot-elf'
,
'--elf=build/fuchsia/elf.aotsnapshot'
,
'build/fuchsia/app_name.dil'
],
),
FakeCommand
(
command:
<
String
>[
'ssh'
,
'-F'
,
sshConfig
.
absolute
.
path
,
'123'
,
r'echo $SSH_CONNECTION'
],
stdout:
'fe80::8c6c:2fff:fe3d:c5e1%ethp0003 50666 fe80::5054:ff:fe63:5e7a%ethp0003 22'
,
),
]),
FuchsiaDeviceTools:
()
=>
fuchsiaDeviceTools
,
FuchsiaArtifacts:
()
=>
fuchsiaArtifacts
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
)
,
FuchsiaSdk:
()
=>
fuchsiaSdk
,
OperatingSystemUtils:
()
=>
osUtils
,
});
...
...
@@ -1021,25 +1050,37 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
artifacts
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
()
,
ProcessManager:
()
=>
fakeSuccessfulProcessManager
,
FuchsiaDeviceTools:
()
=>
fuchsiaDeviceTools
,
FuchsiaArtifacts:
()
=>
fuchsiaArtifacts
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
)
,
FuchsiaSdk:
()
=>
fuchsiaSdk
,
OperatingSystemUtils:
()
=>
osUtils
,
});
testUsingContext
(
'fail w
ith correct LaunchResult when device-finder fails
'
,
()
async
{
final
LaunchResult
launchResult
=
await
setupAndStartApp
(
prebuilt:
true
,
mode:
BuildMode
.
release
)
;
expect
(
launchResult
.
started
,
isFalse
);
expect
(
launchResult
.
hasObservatory
,
isFalse
);
testUsingContext
(
'fail w
hen cant get ssh config
'
,
()
async
{
expect
(()
async
=>
await
setupAndStartApp
(
prebuilt:
true
,
mode:
BuildMode
.
release
)
,
throwsToolExit
(
message:
'Cannot interact with device. No ssh config.
\n
'
'Try setting FUCHSIA_SSH_CONFIG or FUCHSIA_BUILD_DIR.'
)
);
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
artifacts
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
FuchsiaDeviceTools:
()
=>
fuchsiaDeviceTools
,
FuchsiaArtifacts:
()
=>
fuchsiaArtifacts
,
FuchsiaSdk:
()
=>
MockFuchsiaSdk
(
devFinder:
FailingDevFinder
()),
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
null
),
OperatingSystemUtils:
()
=>
osUtils
,
});
testUsingContext
(
'fail when cant get host address'
,
()
async
{
expect
(()
async
=>
await
setupAndStartApp
(
prebuilt:
true
,
mode:
BuildMode
.
release
),
throwsToolExit
(
message:
'Failed to get local address, aborting.'
));
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
artifacts
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
fakeFailedProcessManager
,
FuchsiaDeviceTools:
()
=>
fuchsiaDeviceTools
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
),
OperatingSystemUtils:
()
=>
osUtils
,
});
...
...
@@ -1051,9 +1092,9 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
artifacts
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
()
,
ProcessManager:
()
=>
fakeSuccessfulProcessManager
,
FuchsiaDeviceTools:
()
=>
fuchsiaDeviceTools
,
FuchsiaArtifacts:
()
=>
fuchsiaArtifacts
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
)
,
FuchsiaSdk:
()
=>
MockFuchsiaSdk
(
pm:
FailingPM
()),
OperatingSystemUtils:
()
=>
osUtils
,
});
...
...
@@ -1066,9 +1107,9 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
artifacts
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
()
,
ProcessManager:
()
=>
fakeSuccessfulProcessManager
,
FuchsiaDeviceTools:
()
=>
FakeFuchsiaDeviceTools
(
amber:
FailingAmberCtl
()),
FuchsiaArtifacts:
()
=>
fuchsiaArtifacts
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
)
,
FuchsiaSdk:
()
=>
fuchsiaSdk
,
OperatingSystemUtils:
()
=>
osUtils
,
});
...
...
@@ -1081,9 +1122,9 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
artifacts
,
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
()
,
ProcessManager:
()
=>
fakeSuccessfulProcessManager
,
FuchsiaDeviceTools:
()
=>
FakeFuchsiaDeviceTools
(
tiles:
FailingTilesCtl
()),
FuchsiaArtifacts:
()
=>
fuchsiaArtifacts
,
FuchsiaArtifacts:
()
=>
FuchsiaArtifacts
(
sshConfig:
sshConfig
)
,
FuchsiaSdk:
()
=>
fuchsiaSdk
,
OperatingSystemUtils:
()
=>
osUtils
,
});
...
...
@@ -1548,23 +1589,11 @@ class FakeFuchsiaDevFinder implements FuchsiaDevFinder {
}
@override
Future
<
String
>
resolve
(
String
deviceName
,
{
bool
local
=
false
}
)
async
{
Future
<
String
>
resolve
(
String
deviceName
)
async
{
return
'192.168.42.10'
;
}
}
class
FailingDevFinder
implements
FuchsiaDevFinder
{
@override
Future
<
List
<
String
>>
list
({
Duration
timeout
})
async
{
return
null
;
}
@override
Future
<
String
>
resolve
(
String
deviceName
,
{
bool
local
=
false
})
async
{
return
null
;
}
}
class
MockFuchsiaSdk
extends
Mock
implements
FuchsiaSdk
{
MockFuchsiaSdk
({
FuchsiaPM
pm
,
...
...
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