Fix flutter doctor usage of eglinfo in failure cases. (#164334)

Ignore return value from eglinfo - it doesn't indicate failure.
Discovered when using an X11 system where Wayland is not available. It
returns 1 in this case, but the output is still valid. Confirmed by
looking at the eglinfo source - we should parse the output regardless of
what it returns.

Catch exception correctly when eglinfo is not installed.

Fixes for https://github.com/flutter/flutter/pull/163980
This commit is contained in:
Robert Ancell 2025-03-01 02:07:55 +13:00 committed by GitHub
parent 45b21ec3bb
commit 887d5dd9c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View File

@ -43,8 +43,12 @@ class _DriverInformation {
result = await _processManager.run(<String>['eglinfo'], stdoutEncoding: utf8);
} on ArgumentError {
// ignore error.
} on ProcessException {
return false;
}
if (result == null || result.exitCode != 0) {
// result.exitCode is ignored, as this is non-zero if some platforms are not avaiable.
// The output information is still parsable in all cases.
if (result == null) {
return false;
}

View File

@ -160,7 +160,11 @@ Configurations:
// A command that will failure when running 'eglinfo'.
FakeCommand _eglinfoMissingCommand() {
return const FakeCommand(command: <String>['eglinfo'], exitCode: 1);
return const FakeCommand(
command: <String>['eglinfo'],
exitCode: 1,
exception: ProcessException('eglinfo', <String>[]),
);
}
// Commands that give some failures for the GTK library pkg-config queries.