[flutter_tools] ensure linux doctor validator finishes when pkg-config is not installed (#103755)

This commit is contained in:
Christopher Fujino
2022-05-13 18:24:13 -07:00
committed by GitHub
parent 4f96419612
commit 4c417884c2
2 changed files with 26 additions and 0 deletions

View File

@@ -127,6 +127,8 @@ class LinuxDoctorValidator extends DoctorValidator {
final _VersionInfo? version = installedVersions[kPkgConfigBinary];
if (version == null || version.number == null) {
messages.add(ValidationMessage.error(_userMessages.pkgConfigMissing));
// Exit early because we cannot validate libraries without pkg-config.
return ValidationResult(validationType, messages);
} else {
assert(_requiredBinaryVersions.containsKey(kPkgConfigBinary));
// The full version description is just the number, so add context.

View File

@@ -219,6 +219,30 @@ void main() {
]);
});
testWithoutContext('Missing validation when pkg-config is missing', () async {
final UserMessages userMessages = UserMessages();
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_clangPresentCommand('4.0.1'),
_cmakePresentCommand('3.16.3'),
_ninjaPresentCommand('1.10.0'),
_missingBinaryException('pkg-config'),
// We never check libraries because pkg-config is not present
]);
final DoctorValidator linuxDoctorValidator = LinuxDoctorValidator(
processManager: processManager,
userMessages: userMessages,
);
final ValidationResult result = await linuxDoctorValidator.validate();
expect(result.type, ValidationType.missing);
expect(result.messages, <ValidationMessage>[
const ValidationMessage('clang version 4.0.1-6+build1'),
const ValidationMessage('cmake version 3.16.3'),
const ValidationMessage('ninja version 1.10.0'),
ValidationMessage.error(userMessages.pkgConfigMissing),
]);
});
testWithoutContext('Missing validation when CMake is not available', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_clangPresentCommand('4.0.1'),