From 887d5dd9c2f0539e8b57f22dc89cb96faee28a82 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Sat, 1 Mar 2025 02:07:55 +1300 Subject: [PATCH] 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 --- packages/flutter_tools/lib/src/linux/linux_doctor.dart | 6 +++++- .../test/general.shard/linux/linux_doctor_test.dart | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/linux/linux_doctor.dart b/packages/flutter_tools/lib/src/linux/linux_doctor.dart index 05c7641105f..fc2325faaba 100644 --- a/packages/flutter_tools/lib/src/linux/linux_doctor.dart +++ b/packages/flutter_tools/lib/src/linux/linux_doctor.dart @@ -43,8 +43,12 @@ class _DriverInformation { result = await _processManager.run(['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; } diff --git a/packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart b/packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart index ef948a39fe1..1965c909a8a 100644 --- a/packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart +++ b/packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart @@ -160,7 +160,11 @@ Configurations: // A command that will failure when running 'eglinfo'. FakeCommand _eglinfoMissingCommand() { - return const FakeCommand(command: ['eglinfo'], exitCode: 1); + return const FakeCommand( + command: ['eglinfo'], + exitCode: 1, + exception: ProcessException('eglinfo', []), + ); } // Commands that give some failures for the GTK library pkg-config queries.