[vcpkg] Fix issue in upgrade dependency resolution where self-referencing features cause cycles
MODIFY
src/tests.plan.cpp
src/tests.plan.cpp
@@ -996,6 +996,34 @@ namespace UnitTest1
features_check(&plan[1], "a", {"core", "a1"});
}
+
+ TEST_METHOD(basic_upgrade_scheme_with_self_features)
+ {
+ std::vector<std::unique_ptr<StatusParagraph>> pghs;
+ pghs.push_back(make_status_pgh("a"));
+ pghs.push_back(make_status_feature_pgh("a", "a1", ""));
+ pghs.push_back(make_status_feature_pgh("a", "a2", "a[a1]"));
+ StatusParagraphs status_db(std::move(pghs));
+
+ PackageSpecMap spec_map(Triplet::X86_WINDOWS);
+ auto spec_a = spec_map.emplace("a", "", {{"a1", ""}, {"a2", "a[a1]"}});
+
+ Dependencies::MapPortFileProvider provider(spec_map.map);
+ Dependencies::PackageGraph graph(provider, status_db);
+
+ graph.upgrade(spec_a);
+
+ auto plan = graph.serialize();
+
+ Assert::AreEqual(size_t(2), plan.size());
+
+ Assert::AreEqual("a", plan[0].spec().name().c_str());
+ Assert::IsTrue(plan[0].remove_action.has_value());
+
+ Assert::AreEqual("a", plan[1].spec().name().c_str());
+ Assert::IsTrue(plan[1].install_action.has_value());
+ Assert::IsTrue(plan[1].install_action.get()->feature_list == std::set<std::string>{"core", "a1", "a2"});
+ }
};
class ExportPlanTests : public TestClass<ExportPlanTests>
@@ -1069,7 +1097,7 @@ namespace UnitTest1
Assert::IsTrue(plan[0].plan_type == Dependencies::ExportPlanType::NOT_BUILT);
}
- TEST_METHOD(basic_upgrade_scheme_with_features)
+ TEST_METHOD(basic_export_scheme_with_features)
{
std::vector<std::unique_ptr<StatusParagraph>> pghs;
pghs.push_back(make_status_pgh("b"));

MODIFY
src/vcpkg/dependencies.cpp
src/vcpkg/dependencies.cpp
@@ -530,7 +530,7 @@ namespace vcpkg::Dependencies
for (auto&& depend : remove_edges_edges)
{
auto& depend_cluster = graph.get(depend.spec());
- graph_plan.remove_graph.add_edge({&cluster}, {&depend_cluster});
+ if (&depend_cluster != &cluster) graph_plan.remove_graph.add_edge({&cluster}, {&depend_cluster});
mark_minus(depend_cluster, graph, graph_plan);
}
}

[vcpkg] Fix issue in upgrade dependency resolution where self-referencing features cause cycles