Migrate linux_doctor to null safety (#79804)

This commit is contained in:
Jenn Magder
2021-04-05 13:58:59 -07:00
committed by GitHub
parent 32440ce165
commit b481d4b237
2 changed files with 126 additions and 29 deletions

View File

@@ -236,6 +236,30 @@ void main() {
]);
});
testWithoutContext('Missing validation when CMake version is unparsable', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_clangPresentCommand('4.0.1'),
_cmakePresentCommand('bogus'),
_ninjaPresentCommand('1.10.0'),
_pkgConfigPresentCommand('0.29'),
..._gtkLibrariesPresentCommands(),
]);
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'),
ValidationMessage.error(userMessages.cmakeMissing),
const ValidationMessage('ninja version 1.10.0'),
const ValidationMessage('pkg-config version 0.29'),
]);
});
testWithoutContext('Missing validation when clang++ is not available', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_missingBinaryCommand('clang++'),
@@ -260,6 +284,30 @@ void main() {
]);
});
testWithoutContext('Missing validation when clang++ version is unparsable', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_clangPresentCommand('bogus'),
_cmakePresentCommand('3.16.3'),
_ninjaPresentCommand('1.10.0'),
_pkgConfigPresentCommand('0.29'),
..._gtkLibrariesPresentCommands(),
]);
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>[
ValidationMessage.error(userMessages.clangMissing),
const ValidationMessage('cmake version 3.16.3'),
const ValidationMessage('ninja version 1.10.0'),
const ValidationMessage('pkg-config version 0.29'),
]);
});
testWithoutContext('Missing validation when ninja is not available', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_clangPresentCommand('4.0.1'),
@@ -284,6 +332,30 @@ void main() {
]);
});
testWithoutContext('Missing validation when ninja version is unparsable', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_clangPresentCommand('4.0.1'),
_cmakePresentCommand('3.16.3'),
_ninjaPresentCommand('bogus'),
_pkgConfigPresentCommand('0.29'),
..._gtkLibrariesPresentCommands(),
]);
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'),
ValidationMessage.error(userMessages.ninjaMissing),
const ValidationMessage('pkg-config version 0.29'),
]);
});
testWithoutContext('Missing validation when pkg-config is not available', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_clangPresentCommand('4.0.1'),
@@ -308,6 +380,30 @@ void main() {
]);
});
testWithoutContext('Missing validation when pkg-config version is unparsable', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_clangPresentCommand('4.0.1'),
_cmakePresentCommand('3.16.3'),
_ninjaPresentCommand('1.10.0'),
_pkgConfigPresentCommand('bogus'),
..._gtkLibrariesPresentCommands(),
]);
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'),
ValidationMessage.error(userMessages.pkgConfigMissing),
]);
});
testWithoutContext('Missing validation when GTK libraries are not available', () async {
final ProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
_clangPresentCommand('4.0.1'),