Unverified Commit 70bd819c authored by stuartmorgan's avatar stuartmorgan Committed by GitHub

Separate blkid in the Linux library checks (#63810)

parent 3d3b5349
......@@ -237,6 +237,8 @@ class UserMessages {
String pkgConfigTooOld(String minimumVersion) => 'pkg-config $minimumVersion or later is required.';
String get gtkLibrariesMissing => 'GTK 3.0 development libraries are required for Linux development.\n'
'They are likely available from your distribution (e.g.: apt install libgtk-3-dev)';
String get blkidLibraryMissing => 'The blkid development library is required for Linux development.\n'
'It is likely available from your distribution (e.g.: apt install libblkid-dev)';
// Messages used in FlutterCommand
String flutterElapsedTime(String name, String elapsedTime) => '"flutter $name" took $elapsedTime.';
......
......@@ -52,11 +52,10 @@ class LinuxDoctorValidator extends DoctorValidator {
kPkgConfigBinary: Version(0, 29, 0),
};
final List<String> _requiredLibraries = <String>[
final List<String> _requiredGtkLibraries = <String>[
'gtk+-3.0',
'glib-2.0',
'gio-2.0',
'blkid',
];
@override
......@@ -136,10 +135,10 @@ class LinuxDoctorValidator extends DoctorValidator {
}
}
// Message for libraries.
// Messages for libraries.
{
bool libraryMissing = false;
for (final String library in _requiredLibraries) {
for (final String library in _requiredGtkLibraries) {
if (!await _libraryIsPresent(library)) {
libraryMissing = true;
break;
......@@ -150,6 +149,10 @@ class LinuxDoctorValidator extends DoctorValidator {
messages.add(ValidationMessage.error(_userMessages.gtkLibrariesMissing));
}
}
if (!await _libraryIsPresent('blkid')) {
validationType = ValidationType.missing;
messages.add(ValidationMessage.error(_userMessages.blkidLibraryMissing));
}
return ValidationResult(validationType, messages);
}
......
......@@ -55,26 +55,31 @@ FakeCommand _pkgConfigPresentCommand(String version) {
);
}
// Commands that give positive replies for all the library pkg-config queries.
List<FakeCommand> _librariesPresentCommands() {
return const <FakeCommand>[
FakeCommand(command: <String>['pkg-config', '--exists', 'gtk+-3.0']),
FakeCommand(command: <String>['pkg-config', '--exists', 'glib-2.0']),
FakeCommand(command: <String>['pkg-config', '--exists', 'gio-2.0']),
FakeCommand(command: <String>['pkg-config', '--exists', 'blkid']),
/// A command that returns either success or failure for a pkg-config query
/// for [library], depending on [exists].
FakeCommand _libraryCheckCommand(String library, {bool exists = true}) {
return FakeCommand(
command: <String>['pkg-config', '--exists', library],
exitCode: exists ? 0 : 1,
);
}
// Commands that give positive replies for all the GTK library pkg-config queries.
List<FakeCommand> _gtkLibrariesPresentCommands() {
return <FakeCommand>[
_libraryCheckCommand('gtk+-3.0'),
_libraryCheckCommand('glib-2.0'),
_libraryCheckCommand('gio-2.0'),
];
}
// Commands that give some failures for the library pkg-config queries.
List<FakeCommand> _librariesMissingCommands() {
return const <FakeCommand>[
FakeCommand(command: <String>['pkg-config', '--exists', 'gtk+-3.0']),
FakeCommand(
command: <String>['pkg-config', '--exists', 'glib-2.0'],
exitCode: 1,
),
FakeCommand(command: <String>['pkg-config', '--exists', 'gio-2.0']),
FakeCommand(command: <String>['pkg-config', '--exists', 'blkid']),
// Commands that give some failures for the GTK library pkg-config queries.
List<FakeCommand> _gtkLibrariesMissingCommands() {
return <FakeCommand>[
_libraryCheckCommand('gtk+-3.0'),
_libraryCheckCommand('glib-2.0', exists: false),
// No more entries, since the first missing GTK library stops the
// checks.
];
}
......@@ -93,7 +98,8 @@ void main() {
_cmakePresentCommand('3.16.3'),
_ninjaPresentCommand('1.10.0'),
_pkgConfigPresentCommand('0.29'),
..._librariesPresentCommands(),
..._gtkLibrariesPresentCommands(),
_libraryCheckCommand('blkid'),
]);
final DoctorValidator linuxDoctorValidator = LinuxDoctorValidator(
processManager: processManager,
......@@ -116,7 +122,8 @@ void main() {
_cmakePresentCommand('3.16.3'),
_ninjaPresentCommand('1.10.0'),
_pkgConfigPresentCommand('0.29'),
..._librariesPresentCommands(),
..._gtkLibrariesPresentCommands(),
_libraryCheckCommand('blkid'),
]);
final DoctorValidator linuxDoctorValidator = LinuxDoctorValidator(
processManager: processManager,
......@@ -140,7 +147,8 @@ void main() {
_cmakePresentCommand('3.2.0'),
_ninjaPresentCommand('1.10.0'),
_pkgConfigPresentCommand('0.29'),
..._librariesPresentCommands(),
..._gtkLibrariesPresentCommands(),
_libraryCheckCommand('blkid'),
]);
final DoctorValidator linuxDoctorValidator = LinuxDoctorValidator(
processManager: processManager,
......@@ -164,7 +172,8 @@ void main() {
_cmakePresentCommand('3.16.3'),
_ninjaPresentCommand('0.8.1'),
_pkgConfigPresentCommand('0.29'),
..._librariesPresentCommands(),
..._gtkLibrariesPresentCommands(),
_libraryCheckCommand('blkid'),
]);
final DoctorValidator linuxDoctorValidator = LinuxDoctorValidator(
processManager: processManager,
......@@ -188,7 +197,8 @@ void main() {
_cmakePresentCommand('3.16.3'),
_ninjaPresentCommand('1.10.0'),
_pkgConfigPresentCommand('0.27.0'),
..._librariesPresentCommands(),
..._gtkLibrariesPresentCommands(),
_libraryCheckCommand('blkid'),
]);
final DoctorValidator linuxDoctorValidator = LinuxDoctorValidator(
processManager: processManager,
......@@ -212,7 +222,8 @@ void main() {
_missingBinaryCommand('cmake'),
_ninjaPresentCommand('1.10.0'),
_pkgConfigPresentCommand('0.29'),
..._librariesPresentCommands(),
..._gtkLibrariesPresentCommands(),
_libraryCheckCommand('blkid'),
]);
final UserMessages userMessages = UserMessages();
final DoctorValidator linuxDoctorValidator = LinuxDoctorValidator(
......@@ -236,7 +247,8 @@ void main() {
_cmakePresentCommand('3.16.3'),
_ninjaPresentCommand('1.10.0'),
_pkgConfigPresentCommand('0.29'),
..._librariesPresentCommands(),
..._gtkLibrariesPresentCommands(),
_libraryCheckCommand('blkid'),
]);
final UserMessages userMessages = UserMessages();
final DoctorValidator linuxDoctorValidator = LinuxDoctorValidator(
......@@ -260,7 +272,8 @@ void main() {
_cmakePresentCommand('3.16.3'),
_missingBinaryCommand('ninja'),
_pkgConfigPresentCommand('0.29'),
..._librariesPresentCommands(),
..._gtkLibrariesPresentCommands(),
_libraryCheckCommand('blkid'),
]);
final UserMessages userMessages = UserMessages();
final DoctorValidator linuxDoctorValidator = LinuxDoctorValidator(
......@@ -284,7 +297,8 @@ void main() {
_cmakePresentCommand('3.16.3'),
_ninjaPresentCommand('1.10.0'),
_missingBinaryCommand('pkg-config'),
..._librariesPresentCommands(),
..._gtkLibrariesPresentCommands(),
_libraryCheckCommand('blkid'),
]);
final UserMessages userMessages = UserMessages();
final DoctorValidator linuxDoctorValidator = LinuxDoctorValidator(
......@@ -302,13 +316,14 @@ void main() {
]);
});
testWithoutContext('Missing validation when libraries are not available', () async {
testWithoutContext('Missing validation when GTK libraries are not available', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_clangPresentCommand('4.0.1'),
_cmakePresentCommand('3.16.3'),
_ninjaPresentCommand('1.10.0'),
_pkgConfigPresentCommand('0.29'),
..._librariesMissingCommands(),
..._gtkLibrariesMissingCommands(),
_libraryCheckCommand('blkid'),
]);
final UserMessages userMessages = UserMessages();
final DoctorValidator linuxDoctorValidator = LinuxDoctorValidator(
......@@ -327,13 +342,40 @@ void main() {
]);
});
testWithoutContext('Missing validation when libraries are not available', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_clangPresentCommand('4.0.1'),
_cmakePresentCommand('3.16.3'),
_ninjaPresentCommand('1.10.0'),
_pkgConfigPresentCommand('0.29'),
..._gtkLibrariesPresentCommands(),
_libraryCheckCommand('blkid', exists: false),
]);
final UserMessages userMessages = UserMessages();
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'),
const ValidationMessage('pkg-config version 0.29'),
ValidationMessage.error(userMessages.blkidLibraryMissing),
]);
});
testWithoutContext('Missing validation when multiple dependencies are not available', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_missingBinaryCommand('clang++'),
_missingBinaryCommand('cmake'),
_ninjaPresentCommand('1.10.0'),
_pkgConfigPresentCommand('0.29'),
..._librariesPresentCommands(),
..._gtkLibrariesPresentCommands(),
_libraryCheckCommand('blkid'),
]);
final DoctorValidator linuxDoctorValidator = LinuxDoctorValidator(
processManager: processManager,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment