Be less eager to ignore groups in a cyclic path

This commit is contained in:
Oliver Hamlet
2018-05-11 22:30:12 +01:00
parent 1cb7b2a344
commit 7767c10f2f
2 changed files with 49 additions and 4 deletions
+5 -1
View File
@@ -465,8 +465,12 @@ std::unordered_set<std::string> getGroupsInPaths(
// lastGroup, but not the other way around.
auto lastGroup = *groups.find(Group(lastGroupName));
return pathfinder(
auto groupsInPaths = pathfinder(
lastGroup, firstGroupName, groups, std::unordered_set<std::string>());
groupsInPaths.erase(lastGroupName);
return groupsInPaths;
}
void PluginSorter::AddGroupEdges() {
@@ -212,7 +212,8 @@ TEST_P(PluginSorterTest, sortingShouldThrowIfAPluginHasAGroupThatDoesNotExist) {
EXPECT_THROW(ps.Sort(game_), UndefinedGroupError);
}
TEST_P(PluginSorterTest, sortingShouldIgnoreAGroupEdgeIfItWouldCauseACycleInIsolation) {
TEST_P(PluginSorterTest,
sortingShouldIgnoreAGroupEdgeIfItWouldCauseACycleInIsolation) {
ASSERT_NO_THROW(loadInstalledPlugins(game_, false));
GenerateMasterlist();
@@ -245,8 +246,9 @@ TEST_P(PluginSorterTest, sortingShouldIgnoreAGroupEdgeIfItWouldCauseACycleInIsol
EXPECT_EQ(expectedSortedOrder, sorted);
}
TEST_P(PluginSorterTest,
sortingShouldIgnoreGroupsThatContradictAnotherGroupInCombinationWithMoreSpecificMetadata) {
TEST_P(
PluginSorterTest,
sortingShouldIgnoreGroupsThatContradictAnotherGroupInCombinationWithMoreSpecificMetadata) {
ASSERT_NO_THROW(loadInstalledPlugins(game_, false));
GenerateMasterlist();
@@ -292,6 +294,45 @@ TEST_P(PluginSorterTest,
EXPECT_EQ(expectedSortedOrder, sorted);
}
TEST_P(
PluginSorterTest,
sortingShouldNotIgnorePluginsInTheSameGroupAsTheTargetPluginOfAGroupEdgeThatCausesACycleInIsolation) {
ASSERT_NO_THROW(loadInstalledPlugins(game_, false));
GenerateMasterlist();
game_.GetDatabase()->LoadLists(masterlistPath_.string());
PluginMetadata plugin(blankEsm);
plugin.SetGroup("group4");
game_.GetDatabase()->SetPluginUserMetadata(plugin);
plugin = PluginMetadata(blankDifferentMasterDependentEsm);
plugin.SetGroup("group4");
game_.GetDatabase()->SetPluginUserMetadata(plugin);
PluginSorter ps;
std::vector<std::string> expectedSortedOrder({
masterFile,
blankDifferentEsm,
blankEsm,
blankMasterDependentEsm,
blankDifferentMasterDependentEsm,
blankEsp,
blankDifferentEsp,
blankMasterDependentEsp,
blankDifferentMasterDependentEsp,
blankPluginDependentEsp,
blankDifferentPluginDependentEsp,
});
if (GetParam() == GameType::fo4 || GetParam() == GameType::tes5se) {
expectedSortedOrder.insert(expectedSortedOrder.begin() + 2, blankEsl);
}
std::vector<std::string> sorted = ps.Sort(game_);
EXPECT_EQ(expectedSortedOrder, sorted);
}
TEST_P(PluginSorterTest,
sortingShouldUseLoadAfterMetadataWhenDecidingRelativePluginPositions) {
ASSERT_NO_THROW(loadInstalledPlugins(game_, false));