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
a9aea962
Unverified
Commit
a9aea962
authored
Jul 30, 2019
by
Zachary Anderson
Committed by
GitHub
Jul 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Catch ProcessException from 'adb devices' (#37196)
parent
99d66f27
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
6 deletions
+26
-6
android_device.dart
packages/flutter_tools/lib/src/android/android_device.dart
+4
-1
android_device_test.dart
...tools/test/general.shard/android/android_device_test.dart
+22
-5
No files found.
packages/flutter_tools/lib/src/android/android_device.dart
View file @
a9aea962
...
...
@@ -678,8 +678,11 @@ List<AndroidDevice> getAdbDevices() {
try
{
text
=
runSync
(<
String
>[
adbPath
,
'devices'
,
'-l'
]);
}
on
ArgumentError
catch
(
exception
)
{
throwToolExit
(
'Unable to
run
"adb", check your Android SDK installation and '
throwToolExit
(
'Unable to
find
"adb", check your Android SDK installation and '
'ANDROID_HOME environment variable:
${exception.message}
'
);
}
on
ProcessException
catch
(
exception
)
{
throwToolExit
(
'Unable to run "adb", check your Android SDK installation and '
'ANDROID_HOME environment variable:
${exception.executable}
'
);
}
final
List
<
AndroidDevice
>
devices
=
<
AndroidDevice
>[];
parseADBDeviceOutput
(
text
,
devices:
devices
);
...
...
packages/flutter_tools/test/general.shard/android/android_device_test.dart
View file @
a9aea962
...
...
@@ -34,7 +34,12 @@ void main() {
});
group
(
'getAdbDevices'
,
()
{
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
MockProcessManager
mockProcessManager
;
setUp
(()
{
mockProcessManager
=
MockProcessManager
();
});
testUsingContext
(
'throws on missing adb path'
,
()
{
final
Directory
sdkDir
=
MockAndroidSdk
.
createSdkDirectory
();
Config
.
instance
.
setValue
(
'android-sdk'
,
sdkDir
.
path
);
...
...
@@ -42,10 +47,22 @@ void main() {
final
File
adbExe
=
fs
.
file
(
getAdbPath
(
androidSdk
));
when
(
mockProcessManager
.
runSync
(
<
String
>[
adbExe
.
path
,
'devices'
,
'-l'
],
))
.
thenAnswer
(
(
_
)
=>
throw
ArgumentError
(
adbExe
.
path
),
);
)).
thenThrow
(
ArgumentError
(
adbExe
.
path
));
expect
(()
=>
getAdbDevices
(),
throwsToolExit
(
message:
RegExp
(
'Unable to find "adb".*
${adbExe.path}
'
)));
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
MockAndroidSdk
(),
FileSystem:
()
=>
MemoryFileSystem
(),
ProcessManager:
()
=>
mockProcessManager
,
});
testUsingContext
(
'throws on failing adb'
,
()
{
final
Directory
sdkDir
=
MockAndroidSdk
.
createSdkDirectory
();
Config
.
instance
.
setValue
(
'android-sdk'
,
sdkDir
.
path
);
final
File
adbExe
=
fs
.
file
(
getAdbPath
(
androidSdk
));
when
(
mockProcessManager
.
runSync
(
<
String
>[
adbExe
.
path
,
'devices'
,
'-l'
],
)).
thenThrow
(
ProcessException
(
adbExe
.
path
,
<
String
>[
'devices'
,
'-l'
]));
expect
(()
=>
getAdbDevices
(),
throwsToolExit
(
message:
RegExp
(
'Unable to run "adb".*
${adbExe.path}
'
)));
},
overrides:
<
Type
,
Generator
>{
AndroidSdk:
()
=>
MockAndroidSdk
(),
...
...
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