[vcpkg] Add tests for remove plans.
RENAME
src/tests.installplan.cpp
src/tests.plan.cpp
@@ -37,8 +37,6 @@ namespace Microsoft::VisualStudio::CppUnitTestFramework
}
namespace UnitTest1
-{
- class InstallPlanTests : public TestClass<InstallPlanTests>
{
static std::unique_ptr<SourceControlFile> make_control_file(
const char* name,
@@ -144,6 +142,8 @@ namespace UnitTest1
}
};
+ class InstallPlanTests : public TestClass<InstallPlanTests>
+ {
TEST_METHOD(basic_install_scheme)
{
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
@@ -490,4 +490,72 @@ namespace UnitTest1
features_check(&install_plan[0], "a", {"0", "1", "core"}, Triplet::X64_WINDOWS);
}
};
+
+ static PackageSpec unsafe_pspec(std::string name, Triplet t = Triplet::X86_WINDOWS)
+ {
+ auto m_ret = PackageSpec::from_name_and_triplet(name, t);
+ Assert::IsTrue(m_ret.has_value());
+ return m_ret.value_or_exit(VCPKG_LINE_INFO);
+ }
+
+ class RemovePlanTests : public TestClass<RemovePlanTests>
+ {
+ TEST_METHOD(basic_remove_scheme)
+ {
+ std::vector<std::unique_ptr<StatusParagraph>> pghs;
+ pghs.push_back(make_status_pgh("a"));
+ StatusParagraphs status_db(std::move(pghs));
+
+ auto remove_plan = Dependencies::create_remove_plan({ unsafe_pspec("a") }, status_db);
+
+ Assert::AreEqual(size_t(1), remove_plan.size());
+ Assert::AreEqual("a", remove_plan[0].spec.name().c_str());
+ }
+
+ TEST_METHOD(recurse_remove_scheme)
+ {
+ std::vector<std::unique_ptr<StatusParagraph>> pghs;
+ pghs.push_back(make_status_pgh("a"));
+ pghs.push_back(make_status_pgh("b", "a"));
+ StatusParagraphs status_db(std::move(pghs));
+
+ auto remove_plan = Dependencies::create_remove_plan({ unsafe_pspec("a") }, status_db);
+
+ Assert::AreEqual(size_t(2), remove_plan.size());
+ Assert::AreEqual("b", remove_plan[0].spec.name().c_str());
+ Assert::AreEqual("a", remove_plan[1].spec.name().c_str());
+ }
+
+ TEST_METHOD(features_depend_remove_scheme)
+ {
+ std::vector<std::unique_ptr<StatusParagraph>> pghs;
+ pghs.push_back(make_status_pgh("a"));
+ pghs.push_back(make_status_pgh("b"));
+ pghs.push_back(make_status_feature_pgh("b", "0", "a"));
+ StatusParagraphs status_db(std::move(pghs));
+
+ auto remove_plan = Dependencies::create_remove_plan({ unsafe_pspec("a") }, status_db);
+
+ Assert::AreEqual(size_t(2), remove_plan.size());
+ Assert::AreEqual("b", remove_plan[0].spec.name().c_str());
+ Assert::AreEqual("a", remove_plan[1].spec.name().c_str());
+ }
+
+ TEST_METHOD(features_depend_remove_scheme_once_removed)
+ {
+ std::vector<std::unique_ptr<StatusParagraph>> pghs;
+ pghs.push_back(make_status_pgh("expat"));
+ pghs.push_back(make_status_pgh("vtk", "expat"));
+ pghs.push_back(make_status_pgh("opencv"));
+ pghs.push_back(make_status_feature_pgh("opencv", "vtk", "vtk"));
+ StatusParagraphs status_db(std::move(pghs));
+
+ auto remove_plan = Dependencies::create_remove_plan({ unsafe_pspec("expat") }, status_db);
+
+ Assert::AreEqual(size_t(3), remove_plan.size());
+ Assert::AreEqual("opencv", remove_plan[0].spec.name().c_str());
+ Assert::AreEqual("vtk", remove_plan[1].spec.name().c_str());
+ Assert::AreEqual("expat", remove_plan[2].spec.name().c_str());
+ }
+ };
}

MODIFY
vcpkgtest/vcpkgtest.vcxproj
vcpkgtest/vcpkgtest.vcxproj
<ClCompile Include="..\src\tests.dependencies.cpp" />
<ClCompile Include="..\src\tests.packagespec.cpp" />
<ClCompile Include="..\src\tests.paragraph.cpp" />
- <ClCompile Include="..\src\tests.installplan.cpp" />
+ <ClCompile Include="..\src\tests.plan.cpp" />
<ClCompile Include="..\src\tests.statusparagraphs.cpp" />
</ItemGroup>
<ItemGroup>

MODIFY
vcpkgtest/vcpkgtest.vcxproj.filters
vcpkgtest/vcpkgtest.vcxproj.filters
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="..\src\tests.installplan.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="..\src\tests.arguments.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\tests.statusparagraphs.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\src\tests.plan.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file

[vcpkg] Add tests for remove plans.