aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/tests.plan.cpp
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2018-02-28 12:15:16 -0800
committerRobert Schumacher <roschuma@microsoft.com>2018-02-28 12:15:16 -0800
commitbbbbfb9e79a201a7c479fbc9e8ca14cd8569703d (patch)
tree6d2335cc0c17ebc4d0a0a566c16f293a3bcfc45f /toolsrc/src/tests.plan.cpp
parentef4febc7ef08d1aaa3fb97efadf09e2ad2b9464d (diff)
downloadvcpkg-bbbbfb9e79a201a7c479fbc9e8ca14cd8569703d.tar.gz
vcpkg-bbbbfb9e79a201a7c479fbc9e8ca14cd8569703d.zip
[vcpkg] Add tests for create_export_plan and remove unused arguments
Diffstat (limited to 'toolsrc/src/tests.plan.cpp')
-rw-r--r--toolsrc/src/tests.plan.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/toolsrc/src/tests.plan.cpp b/toolsrc/src/tests.plan.cpp
index aae4d2ee4..08d3c1dab 100644
--- a/toolsrc/src/tests.plan.cpp
+++ b/toolsrc/src/tests.plan.cpp
@@ -997,4 +997,98 @@ namespace UnitTest1
features_check(&plan[1], "a", {"core", "a1"});
}
};
+
+ class ExportPlanTests : public TestClass<ExportPlanTests>
+ {
+ TEST_METHOD(basic_export_scheme)
+ {
+ std::vector<std::unique_ptr<StatusParagraph>> pghs;
+ pghs.push_back(make_status_pgh("a"));
+ StatusParagraphs status_db(std::move(pghs));
+
+ PackageSpecMap spec_map(Triplet::X86_WINDOWS);
+ auto spec_a = spec_map.emplace("a");
+
+ auto plan = Dependencies::create_export_plan({spec_a}, status_db);
+
+ Assert::AreEqual(size_t(1), plan.size());
+ Assert::AreEqual("a", plan[0].spec.name().c_str());
+ Assert::IsTrue(plan[0].plan_type == Dependencies::ExportPlanType::ALREADY_BUILT);
+ }
+
+ TEST_METHOD(basic_export_scheme_with_recurse)
+ {
+ 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));
+
+ PackageSpecMap spec_map(Triplet::X86_WINDOWS);
+ auto spec_a = spec_map.emplace("a");
+ auto spec_b = spec_map.emplace("b", "a");
+
+ auto plan = Dependencies::create_export_plan({spec_b}, status_db);
+
+ Assert::AreEqual(size_t(2), plan.size());
+ Assert::AreEqual("a", plan[0].spec.name().c_str());
+ Assert::IsTrue(plan[0].plan_type == Dependencies::ExportPlanType::ALREADY_BUILT);
+
+ Assert::AreEqual("b", plan[1].spec.name().c_str());
+ Assert::IsTrue(plan[1].plan_type == Dependencies::ExportPlanType::ALREADY_BUILT);
+ }
+
+ TEST_METHOD(basic_export_scheme_with_bystander)
+ {
+ std::vector<std::unique_ptr<StatusParagraph>> pghs;
+ pghs.push_back(make_status_pgh("a"));
+ pghs.push_back(make_status_pgh("b"));
+ StatusParagraphs status_db(std::move(pghs));
+
+ PackageSpecMap spec_map(Triplet::X86_WINDOWS);
+ auto spec_a = spec_map.emplace("a");
+ auto spec_b = spec_map.emplace("b", "a");
+
+ auto plan = Dependencies::create_export_plan({spec_a}, status_db);
+
+ Assert::AreEqual(size_t(1), plan.size());
+ Assert::AreEqual("a", plan[0].spec.name().c_str());
+ Assert::IsTrue(plan[0].plan_type == Dependencies::ExportPlanType::ALREADY_BUILT);
+ }
+
+ TEST_METHOD(basic_export_scheme_with_missing)
+ {
+ StatusParagraphs status_db;
+
+ PackageSpecMap spec_map(Triplet::X86_WINDOWS);
+ auto spec_a = spec_map.emplace("a");
+
+ auto plan = Dependencies::create_export_plan({spec_a}, status_db);
+
+ Assert::AreEqual(size_t(1), plan.size());
+ Assert::AreEqual("a", plan[0].spec.name().c_str());
+ Assert::IsTrue(plan[0].plan_type == Dependencies::ExportPlanType::NOT_BUILT);
+ }
+
+ TEST_METHOD(basic_upgrade_scheme_with_features)
+ {
+ std::vector<std::unique_ptr<StatusParagraph>> pghs;
+ pghs.push_back(make_status_pgh("b"));
+ pghs.push_back(make_status_pgh("a"));
+ pghs.push_back(make_status_feature_pgh("a", "a1", "b[core]"));
+ StatusParagraphs status_db(std::move(pghs));
+
+ PackageSpecMap spec_map(Triplet::X86_WINDOWS);
+ auto spec_a = spec_map.emplace("a", "", {{"a1", ""}});
+
+ auto plan = Dependencies::create_export_plan({spec_a}, status_db);
+
+ Assert::AreEqual(size_t(2), plan.size());
+
+ Assert::AreEqual("b", plan[0].spec.name().c_str());
+ Assert::IsTrue(plan[0].plan_type == Dependencies::ExportPlanType::ALREADY_BUILT);
+
+ Assert::AreEqual("a", plan[1].spec.name().c_str());
+ Assert::IsTrue(plan[1].plan_type == Dependencies::ExportPlanType::ALREADY_BUILT);
+ }
+ };
}