From 71d44cebdb85926bc00241fc08f0dcaaedb868d2 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Mon, 26 Feb 2018 06:08:51 -0800 Subject: [vcpkg] Add test for default-features with a preinstalled dependency --- toolsrc/src/tests.plan.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'toolsrc/src/tests.plan.cpp') diff --git a/toolsrc/src/tests.plan.cpp b/toolsrc/src/tests.plan.cpp index d33ab290d..2bdb4a465 100644 --- a/toolsrc/src/tests.plan.cpp +++ b/toolsrc/src/tests.plan.cpp @@ -536,8 +536,34 @@ namespace UnitTest1 // Expect "a" to get installed and defaults of "b" through the dependency, // as no explicit features of "b" are installed by the user. Assert::IsTrue(install_plan.size() == 2); - features_check(&install_plan[1], "a", {"core"}, Triplet::X64_WINDOWS); features_check(&install_plan[0], "b", {"b1", "core"}, Triplet::X64_WINDOWS); + features_check(&install_plan[1], "a", {"core"}, Triplet::X64_WINDOWS); + } + + TEST_METHOD(do_not_install_default_features_of_existing_dependency) + { + // Add a port "a" which depends on the core of "b" + PackageSpecMap spec_map(Triplet::X64_WINDOWS); + spec_map.emplace("a", "b[core]"); + // "b" has two features, of which "b1" is default. + spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b1"}); + + std::vector> status_paragraphs; + // "b[core]" is already installed + status_paragraphs.push_back(make_status_pgh("b")); + status_paragraphs.back()->package.spec = + PackageSpec::from_name_and_triplet("b", Triplet::X64_WINDOWS).value_or_exit(VCPKG_LINE_INFO); + + // Install "a" (without explicit feature specification) + auto install_specs = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS); + auto install_plan = Dependencies::create_feature_install_plan( + spec_map.map, + FullPackageSpec::to_feature_specs({install_specs.value_or_exit(VCPKG_LINE_INFO)}), + StatusParagraphs(std::move(status_paragraphs))); + + // Expect "a" to get installed, but not require rebuilding "b" + Assert::IsTrue(install_plan.size() == 1); + features_check(&install_plan[0], "a", {"core"}, Triplet::X64_WINDOWS); } TEST_METHOD(install_default_features_of_dependency_test_2) -- cgit v1.2.3