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