include exception details in tool exit displayed when adb call fails (#147498)

Fixes #125971
This commit is contained in:
Andrew Kolos 2024-04-30 10:38:21 -07:00 committed by GitHub
parent af270935bb
commit ce822ec8bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -74,7 +74,8 @@ class AndroidDevices extends PollingDeviceDiscovery {
} on ProcessException catch (exception) {
throwToolExit(
'Unable to run "adb", check your Android SDK installation and '
'$kAndroidHome environment variable: ${exception.executable}',
'$kAndroidHome environment variable: ${exception.executable}\n'
'Error details: ${exception.message}',
);
}
final List<AndroidDevice> devices = <AndroidDevice>[];

View File

@ -87,6 +87,7 @@ void main() {
const FakeCommand(
command: <String>['adb', 'devices', '-l'],
exitCode: 1,
stderr: '<stderr from adb>'
),
]);
final AndroidDevices androidDevices = AndroidDevices(
@ -99,8 +100,15 @@ void main() {
userMessages: UserMessages(),
);
expect(androidDevices.pollingGetDevices(),
throwsToolExit(message: RegExp('Unable to run "adb"')));
expect(
androidDevices.pollingGetDevices(),
throwsToolExit(
message:
'Unable to run "adb", check your Android SDK installation and ANDROID_HOME environment variable: adb\n'
'Error details: Process exited abnormally with exit code 1:\n'
'<stderr from adb>',
),
);
});
testWithoutContext('AndroidDevices is disabled if feature is disabled', () {