Issue #4628 - Ensuring checkEnabledModules is required dependency aware

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2020-03-03 13:51:33 -06:00
parent f150062fde
commit dbaf0bf69d
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
2 changed files with 15 additions and 10 deletions

View File

@ -487,17 +487,19 @@ public class Modules implements Iterable<Module>
_modules.stream().filter(Module::isEnabled).forEach(m ->
{
// Check dependencies
m.getDepends().forEach(d ->
{
Set<Module> providers = getAvailableProviders(d);
if (providers.stream().filter(Module::isEnabled).count() == 0)
m.getDepends().stream()
.filter(Module::isRequiredDependency)
.forEach(d ->
{
if (unsatisfied.length() > 0)
unsatisfied.append(',');
unsatisfied.append(m.getName());
StartLog.error("Module %s requires a module providing %s from one of %s%n", m.getName(), d, providers);
}
});
Set<Module> providers = getAvailableProviders(d);
if (providers.stream().noneMatch(Module::isEnabled))
{
if (unsatisfied.length() > 0)
unsatisfied.append(',');
unsatisfied.append(m.getName());
StartLog.error("Module %s requires a module providing %s from one of %s%n", m.getName(), d, providers);
}
});
});
if (unsatisfied.length() > 0)

View File

@ -234,6 +234,7 @@ public class ModulesTest
// Collect active module list
List<Module> active = modules.getEnabled();
modules.checkEnabledModules();
// Assert names are correct, and in the right order
List<String> expectedNames = new ArrayList<>();
@ -282,6 +283,7 @@ public class ModulesTest
// Collect active module list
List<Module> active = modules.getEnabled();
modules.checkEnabledModules();
// Assert names are correct, and in the right order
List<String> expectedNames = new ArrayList<>();
@ -331,6 +333,7 @@ public class ModulesTest
// Collect active module list
List<Module> active = modules.getEnabled();
modules.checkEnabledModules();
// Assert names are correct, and in the right order
List<String> expectedNames = new ArrayList<>();