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
adead099
Unverified
Commit
adead099
authored
May 20, 2020
by
Jenn Magder
Committed by
GitHub
May 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always show diagnostics (#57532)
parent
67b0dbb4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
22 deletions
+50
-22
devices.dart
packages/flutter_tools/lib/src/commands/devices.dart
+27
-22
devices_test.dart
...tter_tools/test/commands.shard/hermetic/devices_test.dart
+23
-0
No files found.
packages/flutter_tools/lib/src/commands/devices.dart
View file @
adead099
...
...
@@ -60,34 +60,39 @@ class DevicesCommand extends FlutterCommand {
if
(
boolArg
(
'machine'
))
{
await
printDevicesAsJson
(
devices
);
}
else
if
(
devices
.
isEmpty
)
{
final
StringBuffer
status
=
StringBuffer
(
'No devices detected.'
);
status
.
writeln
();
status
.
writeln
();
status
.
writeln
(
'Run "flutter emulators" to list and start any available device emulators.'
);
status
.
writeln
();
status
.
write
(
'If you expected your device to be detected, please run "flutter doctor" to diagnose potential issues. '
);
if
(
timeout
==
null
)
{
status
.
write
(
'You may also try increasing the time to wait for connected devices with the --timeout flag. '
);
}
status
.
write
(
'Visit https://flutter.dev/setup/ for troubleshooting tips.'
);
globals
.
printStatus
(
status
.
toString
());
final
List
<
String
>
diagnostics
=
await
deviceManager
.
getDeviceDiagnostics
();
if
(
diagnostics
.
isNotEmpty
)
{
globals
.
printStatus
(
''
);
for
(
final
String
diagnostic
in
diagnostics
)
{
globals
.
printStatus
(
'•
$diagnostic
'
,
hangingIndent:
2
);
}
else
{
if
(
devices
.
isEmpty
)
{
final
StringBuffer
status
=
StringBuffer
(
'No devices detected.'
);
status
.
writeln
();
status
.
writeln
();
status
.
writeln
(
'Run "flutter emulators" to list and start any available device emulators.'
);
status
.
writeln
();
status
.
write
(
'If you expected your device to be detected, please run "flutter doctor" to diagnose potential issues. '
);
if
(
timeout
==
null
)
{
status
.
write
(
'You may also try increasing the time to wait for connected devices with the --timeout flag. '
);
}
status
.
write
(
'Visit https://flutter.dev/setup/ for troubleshooting tips.'
);
globals
.
printStatus
(
status
.
toString
());
}
else
{
globals
.
printStatus
(
'
${devices.length}
connected
${pluralize('device', devices.length)}
:
\n
'
);
await
Device
.
printDevices
(
devices
);
}
}
else
{
globals
.
printStatus
(
'
${devices.length}
connected
${pluralize('device', devices.length)}
:
\n
'
);
await
Device
.
printDevices
(
devices
);
await
_printDiagnostics
();
}
return
FlutterCommandResult
.
success
();
}
Future
<
void
>
_printDiagnostics
()
async
{
final
List
<
String
>
diagnostics
=
await
deviceManager
.
getDeviceDiagnostics
();
if
(
diagnostics
.
isNotEmpty
)
{
globals
.
printStatus
(
''
);
for
(
final
String
diagnostic
in
diagnostics
)
{
globals
.
printStatus
(
'•
$diagnostic
'
,
hangingIndent:
2
);
}
}
}
Future
<
void
>
printDevicesAsJson
(
List
<
Device
>
devices
)
async
{
globals
.
printStatus
(
const
JsonEncoder
.
withIndent
(
' '
).
convert
(
...
...
packages/flutter_tools/test/commands.shard/hermetic/devices_test.dart
View file @
adead099
...
...
@@ -84,6 +84,25 @@ void main() {
DeviceManager:
()
=>
_FakeDeviceManager
(),
ProcessManager:
()
=>
MockProcessManager
(),
});
testUsingContext
(
'available devices and diagnostics'
,
()
async
{
final
DevicesCommand
command
=
DevicesCommand
();
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'devices'
]);
expect
(
testLogger
.
statusText
,
'''
2 connected devices:
ephemeral • ephemeral • android-arm • Test SDK (1.2.3) (emulator)
webby • webby • web-javascript • Web SDK (1.2.4) (emulator)
• Cannot connect to device ABC
'''
);
},
overrides:
<
Type
,
Generator
>{
DeviceManager:
()
=>
_FakeDeviceManager
(),
ProcessManager:
()
=>
MockProcessManager
(),
});
});
}
...
...
@@ -126,4 +145,8 @@ class _FakeDeviceManager extends DeviceManager {
Future
<
List
<
Device
>>
refreshAllConnectedDevices
({
Duration
timeout
})
=>
getAllConnectedDevices
();
@override
Future
<
List
<
String
>>
getDeviceDiagnostics
()
=>
Future
<
List
<
String
>>.
value
(
<
String
>[
'Cannot connect to device ABC'
]
);
}
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