aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2020-02-04 15:50:10 -0800
committerRobert Schumacher <roschuma@microsoft.com>2020-02-04 15:50:10 -0800
commit6f66ad14fe9da11d4bf50f5b25b4da86ed971c53 (patch)
tree0f5dbcd1719cd6a8e486c4058cfefd607d58aa6c /toolsrc/src/vcpkg-test
parentd502f061bb3ee0258d6453acbf258b9e5d93d564 (diff)
parentd808514c9df44bb97d6eccff952bfe8ec4e156f7 (diff)
downloadvcpkg-6f66ad14fe9da11d4bf50f5b25b4da86ed971c53.tar.gz
vcpkg-6f66ad14fe9da11d4bf50f5b25b4da86ed971c53.zip
Merge remote-tracking branch 'origin/master' into HEAD
Diffstat (limited to 'toolsrc/src/vcpkg-test')
-rw-r--r--toolsrc/src/vcpkg-test/dependencies.cpp69
-rw-r--r--toolsrc/src/vcpkg-test/mockcmakevarsprovider.cpp28
-rw-r--r--toolsrc/src/vcpkg-test/paragraph.cpp96
-rw-r--r--toolsrc/src/vcpkg-test/plan.cpp727
-rw-r--r--toolsrc/src/vcpkg-test/specifier.cpp16
-rw-r--r--toolsrc/src/vcpkg-test/supports.cpp79
-rw-r--r--toolsrc/src/vcpkg-test/update.cpp16
-rw-r--r--toolsrc/src/vcpkg-test/util.cpp42
8 files changed, 570 insertions, 503 deletions
diff --git a/toolsrc/src/vcpkg-test/dependencies.cpp b/toolsrc/src/vcpkg-test/dependencies.cpp
index 2344bb990..63e7cfee7 100644
--- a/toolsrc/src/vcpkg-test/dependencies.cpp
+++ b/toolsrc/src/vcpkg-test/dependencies.cpp
@@ -1,5 +1,7 @@
#include <catch2/catch.hpp>
-
+#include <vcpkg-test/mockcmakevarprovider.h>
+#include <vcpkg-test/util.h>
+#include <vcpkg/dependencies.h>
#include <vcpkg/sourceparagraph.h>
using namespace vcpkg;
@@ -7,22 +9,69 @@ using Parse::parse_comma_list;
TEST_CASE ("parse depends", "[dependencies]")
{
- auto v = expand_qualified_dependencies(parse_comma_list("libA (windows)"));
+ auto v = expand_qualified_dependencies(parse_comma_list("liba (windows)"));
REQUIRE(v.size() == 1);
- REQUIRE(v.at(0).depend.name == "libA");
+ REQUIRE(v.at(0).depend.name == "liba");
REQUIRE(v.at(0).qualifier == "windows");
}
TEST_CASE ("filter depends", "[dependencies]")
{
- auto deps = expand_qualified_dependencies(parse_comma_list("libA (windows), libB, libC (uwp)"));
- auto v = filter_dependencies(deps, Triplet::X64_WINDOWS);
+ const std::unordered_map<std::string, std::string> x64_win_cmake_vars{{"VCPKG_TARGET_ARCHITECTURE", "x64"},
+ {"VCPKG_CMAKE_SYSTEM_NAME", ""}};
+
+ const std::unordered_map<std::string, std::string> arm_uwp_cmake_vars{{"VCPKG_TARGET_ARCHITECTURE", "arm"},
+ {"VCPKG_CMAKE_SYSTEM_NAME", "WindowsStore"}};
+
+ auto deps = expand_qualified_dependencies(parse_comma_list("liba (windows), libb, libc (uwp)"));
+ auto v = filter_dependencies(deps, Triplet::X64_WINDOWS, x64_win_cmake_vars);
REQUIRE(v.size() == 2);
- REQUIRE(v.at(0) == "libA");
- REQUIRE(v.at(1) == "libB");
+ REQUIRE(v.at(0).package_spec.name() == "liba");
+ REQUIRE(v.at(1).package_spec.name() == "libb");
- auto v2 = filter_dependencies(deps, Triplet::ARM_UWP);
+ auto v2 = filter_dependencies(deps, Triplet::ARM_UWP, arm_uwp_cmake_vars);
+ REQUIRE(v.size() == 2);
+ REQUIRE(v2.at(0).package_spec.name() == "libb");
+ REQUIRE(v2.at(1).package_spec.name() == "libc");
+}
+
+TEST_CASE ("parse feature depends", "[dependencies]")
+{
+ auto u = parse_comma_list("libwebp[anim, gif2webp, img2webp, info, mux, nearlossless, "
+ "simd, cwebp, dwebp], libwebp[vwebp_sdl, extras] (!osx)");
+ REQUIRE(u.at(1) == "libwebp[vwebp_sdl, extras] (!osx)");
+ auto v = expand_qualified_dependencies(u);
REQUIRE(v.size() == 2);
- REQUIRE(v2.at(0) == "libB");
- REQUIRE(v2.at(1) == "libC");
+ auto&& a0 = v.at(0);
+ REQUIRE(a0.depend.name == "libwebp");
+ REQUIRE(a0.depend.features.size() == 9);
+ REQUIRE(a0.qualifier.empty());
+
+ auto&& a1 = v.at(1);
+ REQUIRE(a1.depend.name == "libwebp");
+ REQUIRE(a1.depend.features.size() == 2);
+ REQUIRE(a1.qualifier == "!osx");
+}
+
+TEST_CASE ("qualified dependency", "[dependencies]")
+{
+ using namespace Test;
+ PackageSpecMap spec_map;
+ auto spec_a = FullPackageSpec{spec_map.emplace("a", "b, b[b1] (linux)"), {}};
+ auto spec_b = FullPackageSpec{spec_map.emplace("b", "", {{"b1", ""}}), {}};
+
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto plan = vcpkg::Dependencies::create_feature_install_plan(map_port, var_provider, {spec_a}, {});
+ REQUIRE(plan.install_actions.size() == 2);
+ REQUIRE(plan.install_actions.at(0).feature_list == std::vector<std::string>{"core"});
+
+ FullPackageSpec linspec_a{PackageSpec::from_name_and_triplet("a", Triplet::from_canonical_name("x64-linux"))
+ .value_or_exit(VCPKG_LINE_INFO),
+ {}};
+ var_provider.dep_info_vars[linspec_a.package_spec].emplace("VCPKG_CMAKE_SYSTEM_NAME", "Linux");
+ auto plan2 = vcpkg::Dependencies::create_feature_install_plan(map_port, var_provider, {linspec_a}, {});
+ REQUIRE(plan2.install_actions.size() == 2);
+ REQUIRE(plan2.install_actions.at(0).feature_list == std::vector<std::string>{"b1", "core"});
}
diff --git a/toolsrc/src/vcpkg-test/mockcmakevarsprovider.cpp b/toolsrc/src/vcpkg-test/mockcmakevarsprovider.cpp
new file mode 100644
index 000000000..eda1a7a64
--- /dev/null
+++ b/toolsrc/src/vcpkg-test/mockcmakevarsprovider.cpp
@@ -0,0 +1,28 @@
+#include <vcpkg-test/mockcmakevarprovider.h>
+
+namespace vcpkg::Test
+{
+ Optional<const std::unordered_map<std::string, std::string>&> MockCMakeVarProvider::get_generic_triplet_vars(
+ const Triplet& triplet) const
+ {
+ auto it = generic_triplet_vars.find(triplet);
+ if (it == generic_triplet_vars.end()) return nullopt;
+ return it->second;
+ }
+
+ Optional<const std::unordered_map<std::string, std::string>&> MockCMakeVarProvider::get_dep_info_vars(
+ const PackageSpec& spec) const
+ {
+ auto it = dep_info_vars.find(spec);
+ if (it == dep_info_vars.end()) return nullopt;
+ return it->second;
+ }
+
+ Optional<const std::unordered_map<std::string, std::string>&> MockCMakeVarProvider::get_tag_vars(
+ const PackageSpec& spec) const
+ {
+ auto it = tag_vars.find(spec);
+ if (it == tag_vars.end()) return nullopt;
+ return it->second;
+ }
+} \ No newline at end of file
diff --git a/toolsrc/src/vcpkg-test/paragraph.cpp b/toolsrc/src/vcpkg-test/paragraph.cpp
index 85c37851d..2ee4efe2f 100644
--- a/toolsrc/src/vcpkg-test/paragraph.cpp
+++ b/toolsrc/src/vcpkg-test/paragraph.cpp
@@ -10,10 +10,11 @@ namespace Strings = vcpkg::Strings;
TEST_CASE ("SourceParagraph construct minimum", "[paragraph]")
{
auto m_pgh =
- vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
- {"Source", "zlib"},
- {"Version", "1.2.8"},
- }});
+ vcpkg::SourceControlFile::parse_control_file("",
+ std::vector<std::unordered_map<std::string, std::string>>{{
+ {"Source", "zlib"},
+ {"Version", "1.2.8"},
+ }});
REQUIRE(m_pgh.has_value());
auto& pgh = **m_pgh.get();
@@ -28,15 +29,15 @@ TEST_CASE ("SourceParagraph construct minimum", "[paragraph]")
TEST_CASE ("SourceParagraph construct maximum", "[paragraph]")
{
auto m_pgh =
- vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
- {"Source", "s"},
- {"Version", "v"},
- {"Maintainer", "m"},
- {"Description", "d"},
- {"Build-Depends", "bd"},
- {"Default-Features", "df"},
- {"Supports", "x64"},
- }});
+ vcpkg::SourceControlFile::parse_control_file("",
+ std::vector<std::unordered_map<std::string, std::string>>{{
+ {"Source", "s"},
+ {"Version", "v"},
+ {"Maintainer", "m"},
+ {"Description", "d"},
+ {"Build-Depends", "bd"},
+ {"Default-Features", "df"},
+ }});
REQUIRE(m_pgh.has_value());
auto& pgh = **m_pgh.get();
@@ -48,18 +49,17 @@ TEST_CASE ("SourceParagraph construct maximum", "[paragraph]")
REQUIRE(pgh.core_paragraph->depends[0].name() == "bd");
REQUIRE(pgh.core_paragraph->default_features.size() == 1);
REQUIRE(pgh.core_paragraph->default_features[0] == "df");
- REQUIRE(pgh.core_paragraph->supports.size() == 1);
- REQUIRE(pgh.core_paragraph->supports[0] == "x64");
}
TEST_CASE ("SourceParagraph two depends", "[paragraph]")
{
auto m_pgh =
- vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
- {"Source", "zlib"},
- {"Version", "1.2.8"},
- {"Build-Depends", "z, openssl"},
- }});
+ vcpkg::SourceControlFile::parse_control_file("",
+ std::vector<std::unordered_map<std::string, std::string>>{{
+ {"Source", "zlib"},
+ {"Version", "1.2.8"},
+ {"Build-Depends", "z, openssl"},
+ }});
REQUIRE(m_pgh.has_value());
auto& pgh = **m_pgh.get();
@@ -71,11 +71,12 @@ TEST_CASE ("SourceParagraph two depends", "[paragraph]")
TEST_CASE ("SourceParagraph three depends", "[paragraph]")
{
auto m_pgh =
- vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
- {"Source", "zlib"},
- {"Version", "1.2.8"},
- {"Build-Depends", "z, openssl, xyz"},
- }});
+ vcpkg::SourceControlFile::parse_control_file("",
+ std::vector<std::unordered_map<std::string, std::string>>{{
+ {"Source", "zlib"},
+ {"Version", "1.2.8"},
+ {"Build-Depends", "z, openssl, xyz"},
+ }});
REQUIRE(m_pgh.has_value());
auto& pgh = **m_pgh.get();
@@ -85,31 +86,15 @@ TEST_CASE ("SourceParagraph three depends", "[paragraph]")
REQUIRE(pgh.core_paragraph->depends[2].name() == "xyz");
}
-TEST_CASE ("SourceParagraph three supports", "[paragraph]")
-{
- auto m_pgh =
- vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
- {"Source", "zlib"},
- {"Version", "1.2.8"},
- {"Supports", "x64, windows, uwp"},
- }});
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->supports.size() == 3);
- REQUIRE(pgh.core_paragraph->supports[0] == "x64");
- REQUIRE(pgh.core_paragraph->supports[1] == "windows");
- REQUIRE(pgh.core_paragraph->supports[2] == "uwp");
-}
-
TEST_CASE ("SourceParagraph construct qualified depends", "[paragraph]")
{
auto m_pgh =
- vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
- {"Source", "zlib"},
- {"Version", "1.2.8"},
- {"Build-Depends", "libA (windows), libB (uwp)"},
- }});
+ vcpkg::SourceControlFile::parse_control_file("",
+ std::vector<std::unordered_map<std::string, std::string>>{{
+ {"Source", "zlib"},
+ {"Version", "1.2.8"},
+ {"Build-Depends", "libA (windows), libB (uwp)"},
+ }});
REQUIRE(m_pgh.has_value());
auto& pgh = **m_pgh.get();
@@ -127,11 +112,12 @@ TEST_CASE ("SourceParagraph construct qualified depends", "[paragraph]")
TEST_CASE ("SourceParagraph default features", "[paragraph]")
{
auto m_pgh =
- vcpkg::SourceControlFile::parse_control_file(std::vector<std::unordered_map<std::string, std::string>>{{
- {"Source", "a"},
- {"Version", "1.0"},
- {"Default-Features", "a1"},
- }});
+ vcpkg::SourceControlFile::parse_control_file("",
+ std::vector<std::unordered_map<std::string, std::string>>{{
+ {"Source", "a"},
+ {"Version", "1.0"},
+ {"Default-Features", "a1"},
+ }});
REQUIRE(m_pgh.has_value());
auto& pgh = **m_pgh.get();
@@ -380,11 +366,12 @@ TEST_CASE ("BinaryParagraph serialize min", "[paragraph]")
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
REQUIRE(pghs.size() == 1);
- REQUIRE(pghs[0].size() == 4);
+ REQUIRE(pghs[0].size() == 5);
REQUIRE(pghs[0]["Package"] == "zlib");
REQUIRE(pghs[0]["Version"] == "1.2.8");
REQUIRE(pghs[0]["Architecture"] == "x86-windows");
REQUIRE(pghs[0]["Multi-Arch"] == "same");
+ REQUIRE(pghs[0]["Type"] == "Port");
}
TEST_CASE ("BinaryParagraph serialize max", "[paragraph]")
@@ -402,13 +389,14 @@ TEST_CASE ("BinaryParagraph serialize max", "[paragraph]")
auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss).value_or_exit(VCPKG_LINE_INFO);
REQUIRE(pghs.size() == 1);
- REQUIRE(pghs[0].size() == 7);
+ REQUIRE(pghs[0].size() == 8);
REQUIRE(pghs[0]["Package"] == "zlib");
REQUIRE(pghs[0]["Version"] == "1.2.8");
REQUIRE(pghs[0]["Architecture"] == "x86-windows");
REQUIRE(pghs[0]["Multi-Arch"] == "same");
REQUIRE(pghs[0]["Description"] == "first line\n second line");
REQUIRE(pghs[0]["Depends"] == "dep");
+ REQUIRE(pghs[0]["Type"] == "Port");
}
TEST_CASE ("BinaryParagraph serialize multiple deps", "[paragraph]")
diff --git a/toolsrc/src/vcpkg-test/plan.cpp b/toolsrc/src/vcpkg-test/plan.cpp
index e354b7551..594c9783b 100644
--- a/toolsrc/src/vcpkg-test/plan.cpp
+++ b/toolsrc/src/vcpkg-test/plan.cpp
@@ -1,7 +1,10 @@
#include <catch2/catch.hpp>
+#include <vcpkg-test/mockcmakevarprovider.h>
#include <vcpkg-test/util.h>
+#include <vcpkg/base/graphs.h>
#include <vcpkg/dependencies.h>
+#include <vcpkg/portfileprovider.h>
#include <vcpkg/sourceparagraph.h>
#include <vcpkg/triplet.h>
@@ -11,54 +14,28 @@
using namespace vcpkg;
+using Test::make_control_file;
using Test::make_status_feature_pgh;
using Test::make_status_pgh;
+using Test::MockCMakeVarProvider;
+using Test::PackageSpecMap;
using Test::unsafe_pspec;
-static std::unique_ptr<SourceControlFile> make_control_file(
- const char* name,
- const char* depends,
- const std::vector<std::pair<const char*, const char*>>& features = {},
- const std::vector<const char*>& default_features = {})
-{
- using Pgh = std::unordered_map<std::string, std::string>;
- std::vector<Pgh> scf_pghs;
- scf_pghs.push_back(Pgh{{"Source", name},
- {"Version", "0"},
- {"Build-Depends", depends},
- {"Default-Features", Strings::join(", ", default_features)}});
- for (auto&& feature : features)
- {
- scf_pghs.push_back(Pgh{
- {"Feature", feature.first},
- {"Description", "feature"},
- {"Build-Depends", feature.second},
- });
- }
- auto m_pgh = vcpkg::SourceControlFile::parse_control_file(std::move(scf_pghs));
- REQUIRE(m_pgh.has_value());
- return std::move(*m_pgh.get());
-}
-
/// <summary>
/// Assert that the given action an install of given features from given package.
/// </summary>
-static void features_check(Dependencies::AnyAction& install_action,
+static void features_check(Dependencies::InstallPlanAction& plan,
std::string pkg_name,
- std::vector<std::string> vec,
+ std::vector<std::string> expected_features,
const Triplet& triplet = Triplet::X86_WINDOWS)
{
- REQUIRE(install_action.install_action.has_value());
- const auto& plan = install_action.install_action.value_or_exit(VCPKG_LINE_INFO);
const auto& feature_list = plan.feature_list;
REQUIRE(plan.spec.triplet().to_string() == triplet.to_string());
+ REQUIRE(pkg_name == plan.spec.name());
+ REQUIRE(feature_list.size() == expected_features.size());
- auto& scfl = *plan.source_control_file_location.get();
- REQUIRE(pkg_name == scfl.source_control_file->core_paragraph->name);
- REQUIRE(feature_list.size() == vec.size());
-
- for (auto&& feature_name : vec)
+ for (auto&& feature_name : expected_features)
{
// TODO: see if this can be simplified
if (feature_name == "core" || feature_name == "")
@@ -74,42 +51,14 @@ static void features_check(Dependencies::AnyAction& install_action,
/// <summary>
/// Assert that the given action is a remove of given package.
/// </summary>
-static void remove_plan_check(Dependencies::AnyAction& remove_action,
+static void remove_plan_check(Dependencies::RemovePlanAction& plan,
std::string pkg_name,
const Triplet& triplet = Triplet::X86_WINDOWS)
{
- const auto& plan = remove_action.remove_action.value_or_exit(VCPKG_LINE_INFO);
REQUIRE(plan.spec.triplet().to_string() == triplet.to_string());
REQUIRE(pkg_name == plan.spec.name());
}
-/// <summary>
-/// Map of source control files by their package name.
-/// </summary>
-struct PackageSpecMap
-{
- std::unordered_map<std::string, SourceControlFileLocation> map;
- Triplet triplet;
- PackageSpecMap(const Triplet& t = Triplet::X86_WINDOWS) noexcept { triplet = t; }
-
- PackageSpec emplace(const char* name,
- const char* depends = "",
- const std::vector<std::pair<const char*, const char*>>& features = {},
- const std::vector<const char*>& default_features = {})
- {
- auto scfl = SourceControlFileLocation{make_control_file(name, depends, features, default_features), ""};
- return emplace(std::move(scfl));
- }
-
- PackageSpec emplace(vcpkg::SourceControlFileLocation&& scfl)
- {
- auto spec = PackageSpec::from_name_and_triplet(scfl.source_control_file->core_paragraph->name, triplet);
- REQUIRE(spec.has_value());
- map.emplace(scfl.source_control_file->core_paragraph->name, std::move(scfl));
- return PackageSpec{*spec.get()};
- }
-};
-
TEST_CASE ("basic install scheme", "[plan]")
{
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
@@ -119,14 +68,16 @@ TEST_CASE ("basic install scheme", "[plan]")
auto spec_b = spec_map.emplace("b", "c");
auto spec_c = spec_map.emplace("c");
- Dependencies::MapPortFileProvider map_port(spec_map.map);
+ PortFileProvider::MapPortFileProvider map_port(spec_map.map);
+ MockCMakeVarProvider var_provider;
+
auto install_plan = Dependencies::create_feature_install_plan(
- map_port, {FeatureSpec{spec_a, ""}}, StatusParagraphs(std::move(status_paragraphs)));
+ map_port, var_provider, {FullPackageSpec{spec_a, {}}}, StatusParagraphs(std::move(status_paragraphs)));
REQUIRE(install_plan.size() == 3);
- REQUIRE(install_plan.at(0).spec().name() == "c");
- REQUIRE(install_plan.at(1).spec().name() == "b");
- REQUIRE(install_plan.at(2).spec().name() == "a");
+ REQUIRE(install_plan.install_actions.at(0).spec.name() == "c");
+ REQUIRE(install_plan.install_actions.at(1).spec.name() == "b");
+ REQUIRE(install_plan.install_actions.at(2).spec.name() == "a");
}
TEST_CASE ("multiple install scheme", "[plan]")
@@ -143,17 +94,21 @@ TEST_CASE ("multiple install scheme", "[plan]")
auto spec_g = spec_map.emplace("g");
auto spec_h = spec_map.emplace("h");
- Dependencies::MapPortFileProvider map_port(spec_map.map);
+ PortFileProvider::MapPortFileProvider map_port(spec_map.map);
+ MockCMakeVarProvider var_provider;
+
auto install_plan = Dependencies::create_feature_install_plan(
map_port,
- {FeatureSpec{spec_a, ""}, FeatureSpec{spec_b, ""}, FeatureSpec{spec_c, ""}},
+ var_provider,
+ {FullPackageSpec{spec_a}, FullPackageSpec{spec_b}, FullPackageSpec{spec_c}},
StatusParagraphs(std::move(status_paragraphs)));
auto iterator_pos = [&](const PackageSpec& spec) {
- auto it =
- std::find_if(install_plan.begin(), install_plan.end(), [&](auto& action) { return action.spec() == spec; });
- REQUIRE(it != install_plan.end());
- return it - install_plan.begin();
+ auto it = std::find_if(install_plan.install_actions.begin(),
+ install_plan.install_actions.end(),
+ [&](auto& action) { return action.spec == spec; });
+ REQUIRE(it != install_plan.install_actions.end());
+ return it - install_plan.install_actions.begin();
};
const auto a_pos = iterator_pos(spec_a);
@@ -184,12 +139,14 @@ TEST_CASE ("existing package scheme", "[plan]")
PackageSpecMap spec_map;
auto spec_a = FullPackageSpec{spec_map.emplace("a")};
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
auto install_plan = Dependencies::create_feature_install_plan(
- spec_map.map, FullPackageSpec::to_feature_specs({spec_a}), StatusParagraphs(std::move(status_paragraphs)));
+ map_port, var_provider, {spec_a}, StatusParagraphs(std::move(status_paragraphs)));
REQUIRE(install_plan.size() == 1);
- const auto p = install_plan.at(0).install_action.get();
- REQUIRE(p);
+ const auto p = &install_plan.already_installed.at(0);
REQUIRE(p->spec.name() == "a");
REQUIRE(p->plan_type == Dependencies::InstallPlanType::ALREADY_INSTALLED);
REQUIRE(p->request_type == Dependencies::RequestType::USER_REQUESTED);
@@ -203,18 +160,19 @@ TEST_CASE ("user requested package scheme", "[plan]")
const auto spec_a = FullPackageSpec{spec_map.emplace("a", "b")};
const auto spec_b = FullPackageSpec{spec_map.emplace("b")};
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
const auto install_plan = Dependencies::create_feature_install_plan(
- spec_map.map, FullPackageSpec::to_feature_specs({spec_a}), StatusParagraphs(std::move(status_paragraphs)));
+ map_port, var_provider, {spec_a}, StatusParagraphs(std::move(status_paragraphs)));
REQUIRE(install_plan.size() == 2);
- const auto p = install_plan.at(0).install_action.get();
- REQUIRE(p);
+ const auto p = &install_plan.install_actions.at(0);
REQUIRE(p->spec.name() == "b");
REQUIRE(p->plan_type == Dependencies::InstallPlanType::BUILD_AND_INSTALL);
REQUIRE(p->request_type == Dependencies::RequestType::AUTO_SELECTED);
- const auto p2 = install_plan.at(1).install_action.get();
- REQUIRE(p2);
+ const auto p2 = &install_plan.install_actions.at(1);
REQUIRE(p2->spec.name() == "a");
REQUIRE(p2->plan_type == Dependencies::InstallPlanType::BUILD_AND_INSTALL);
REQUIRE(p2->request_type == Dependencies::RequestType::USER_REQUESTED);
@@ -239,19 +197,21 @@ TEST_CASE ("long install scheme", "[plan]")
auto spec_j = spec_map.emplace("j", "k");
auto spec_k = spec_map.emplace("k");
- Dependencies::MapPortFileProvider map_port(spec_map.map);
- auto install_plan = Dependencies::create_feature_install_plan(
- map_port, {FeatureSpec{spec_a, ""}}, StatusParagraphs(std::move(status_paragraphs)));
+ PortFileProvider::MapPortFileProvider map_port(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto plan = Dependencies::create_feature_install_plan(
+ map_port, var_provider, {FullPackageSpec{spec_a}}, StatusParagraphs(std::move(status_paragraphs)));
+ auto& install_plan = plan.install_actions;
REQUIRE(install_plan.size() == 8);
- REQUIRE(install_plan.at(0).spec().name() == "h");
- REQUIRE(install_plan.at(1).spec().name() == "g");
- REQUIRE(install_plan.at(2).spec().name() == "f");
- REQUIRE(install_plan.at(3).spec().name() == "e");
- REQUIRE(install_plan.at(4).spec().name() == "d");
- REQUIRE(install_plan.at(5).spec().name() == "c");
- REQUIRE(install_plan.at(6).spec().name() == "b");
- REQUIRE(install_plan.at(7).spec().name() == "a");
+ REQUIRE(install_plan.at(0).spec.name() == "h");
+ REQUIRE(install_plan.at(1).spec.name() == "g");
+ REQUIRE(install_plan.at(2).spec.name() == "f");
+ REQUIRE(install_plan.at(3).spec.name() == "e");
+ REQUIRE(install_plan.at(4).spec.name() == "d");
+ REQUIRE(install_plan.at(5).spec.name() == "c");
+ REQUIRE(install_plan.at(6).spec.name() == "b");
+ REQUIRE(install_plan.at(7).spec.name() == "a");
}
TEST_CASE ("basic feature test 1", "[plan]")
@@ -265,14 +225,17 @@ TEST_CASE ("basic feature test 1", "[plan]")
auto spec_a = FullPackageSpec{spec_map.emplace("a", "b, b[b1]", {{"a1", "b[b2]"}}), {"a1"}};
auto spec_b = FullPackageSpec{spec_map.emplace("b", "", {{"b1", ""}, {"b2", ""}, {"b3", ""}})};
- auto install_plan = Dependencies::create_feature_install_plan(
- spec_map.map, FullPackageSpec::to_feature_specs({spec_a}), StatusParagraphs(std::move(status_paragraphs)));
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
- REQUIRE(install_plan.size() == 4);
- remove_plan_check(install_plan.at(0), "a");
- remove_plan_check(install_plan.at(1), "b");
- features_check(install_plan.at(2), "b", {"b1", "core", "b1"});
- features_check(install_plan.at(3), "a", {"a1", "core"});
+ auto plan = Dependencies::create_feature_install_plan(
+ map_port, var_provider, {spec_a}, StatusParagraphs(std::move(status_paragraphs)));
+
+ REQUIRE(plan.size() == 4);
+ remove_plan_check(plan.remove_actions.at(0), "a");
+ remove_plan_check(plan.remove_actions.at(1), "b");
+ features_check(plan.install_actions.at(0), "b", {"b1", "core", "b1"});
+ features_check(plan.install_actions.at(1), "a", {"a1", "core"});
}
TEST_CASE ("basic feature test 2", "[plan]")
@@ -284,9 +247,13 @@ TEST_CASE ("basic feature test 2", "[plan]")
auto spec_a = FullPackageSpec{spec_map.emplace("a", "b[b1]", {{"a1", "b[b2]"}}), {"a1"}};
auto spec_b = FullPackageSpec{spec_map.emplace("b", "", {{"b1", ""}, {"b2", ""}, {"b3", ""}})};
- auto install_plan = Dependencies::create_feature_install_plan(
- spec_map.map, FullPackageSpec::to_feature_specs({spec_a}), StatusParagraphs(std::move(status_paragraphs)));
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto plan = Dependencies::create_feature_install_plan(
+ map_port, var_provider, {spec_a}, StatusParagraphs(std::move(status_paragraphs)));
+ auto& install_plan = plan.install_actions;
REQUIRE(install_plan.size() == 2);
features_check(install_plan.at(0), "b", {"b1", "b2", "core"});
features_check(install_plan.at(1), "a", {"a1", "core"});
@@ -303,15 +270,18 @@ TEST_CASE ("basic feature test 3", "[plan]")
auto spec_b = FullPackageSpec{spec_map.emplace("b")};
auto spec_c = FullPackageSpec{spec_map.emplace("c", "a[a1]"), {"core"}};
- auto install_plan = Dependencies::create_feature_install_plan(spec_map.map,
- FullPackageSpec::to_feature_specs({spec_c, spec_a}),
- StatusParagraphs(std::move(status_paragraphs)));
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto plan = Dependencies::create_feature_install_plan(
+ map_port, var_provider, {spec_c, spec_a}, StatusParagraphs(std::move(status_paragraphs)));
- REQUIRE(install_plan.size() == 4);
- remove_plan_check(install_plan.at(0), "a");
- features_check(install_plan.at(1), "b", {"core"});
- features_check(install_plan.at(2), "a", {"a1", "core"});
- features_check(install_plan.at(3), "c", {"core"});
+ REQUIRE(plan.size() == 4);
+ remove_plan_check(plan.remove_actions.at(0), "a");
+ auto& install_plan = plan.install_actions;
+ features_check(install_plan.at(0), "b", {"core"});
+ features_check(install_plan.at(1), "a", {"a1", "core"});
+ features_check(install_plan.at(2), "c", {"core"});
}
TEST_CASE ("basic feature test 4", "[plan]")
@@ -326,11 +296,14 @@ TEST_CASE ("basic feature test 4", "[plan]")
auto spec_b = FullPackageSpec{spec_map.emplace("b")};
auto spec_c = FullPackageSpec{spec_map.emplace("c", "a[a1]"), {"core"}};
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
auto install_plan = Dependencies::create_feature_install_plan(
- spec_map.map, FullPackageSpec::to_feature_specs({spec_c}), StatusParagraphs(std::move(status_paragraphs)));
+ map_port, var_provider, {spec_c}, StatusParagraphs(std::move(status_paragraphs)));
REQUIRE(install_plan.size() == 1);
- features_check(install_plan.at(0), "c", {"core"});
+ features_check(install_plan.install_actions.at(0), "c", {"core"});
}
TEST_CASE ("basic feature test 5", "[plan]")
@@ -343,12 +316,15 @@ TEST_CASE ("basic feature test 5", "[plan]")
FullPackageSpec{spec_map.emplace("a", "", {{"a1", "b[b1]"}, {"a2", "b[b2]"}, {"a3", "a[a2]"}}), {"a3"}};
auto spec_b = FullPackageSpec{spec_map.emplace("b", "", {{"b1", ""}, {"b2", ""}})};
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
auto install_plan = Dependencies::create_feature_install_plan(
- spec_map.map, FullPackageSpec::to_feature_specs({spec_a}), StatusParagraphs(std::move(status_paragraphs)));
+ map_port, var_provider, {spec_a}, StatusParagraphs(std::move(status_paragraphs)));
REQUIRE(install_plan.size() == 2);
- features_check(install_plan.at(0), "b", {"core", "b2"});
- features_check(install_plan.at(1), "a", {"core", "a3", "a2"});
+ features_check(install_plan.install_actions.at(0), "b", {"core", "b2"});
+ features_check(install_plan.install_actions.at(1), "a", {"core", "a3", "a2"});
}
TEST_CASE ("basic feature test 6", "[plan]")
@@ -360,14 +336,16 @@ TEST_CASE ("basic feature test 6", "[plan]")
auto spec_a = FullPackageSpec{spec_map.emplace("a", "b[core]"), {"core"}};
auto spec_b = FullPackageSpec{spec_map.emplace("b", "", {{"b1", ""}}), {"b1"}};
- auto install_plan = Dependencies::create_feature_install_plan(spec_map.map,
- FullPackageSpec::to_feature_specs({spec_a, spec_b}),
- StatusParagraphs(std::move(status_paragraphs)));
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
- REQUIRE(install_plan.size() == 3);
- remove_plan_check(install_plan.at(0), "b");
- features_check(install_plan.at(1), "b", {"core", "b1"});
- features_check(install_plan.at(2), "a", {"core"});
+ auto plan = Dependencies::create_feature_install_plan(
+ map_port, var_provider, {spec_a, spec_b}, StatusParagraphs(std::move(status_paragraphs)));
+
+ REQUIRE(plan.size() == 3);
+ remove_plan_check(plan.remove_actions.at(0), "b");
+ features_check(plan.install_actions.at(0), "b", {"core", "b1"});
+ features_check(plan.install_actions.at(1), "a", {"core"});
}
TEST_CASE ("basic feature test 7", "[plan]")
@@ -382,20 +360,23 @@ TEST_CASE ("basic feature test 7", "[plan]")
auto spec_x = FullPackageSpec{spec_map.emplace("x", "a"), {"core"}};
auto spec_b = FullPackageSpec{spec_map.emplace("b", "", {{"b1", ""}}), {"b1"}};
- auto install_plan = Dependencies::create_feature_install_plan(
- spec_map.map, FullPackageSpec::to_feature_specs({spec_b}), StatusParagraphs(std::move(status_paragraphs)));
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto plan = Dependencies::create_feature_install_plan(
+ map_port, var_provider, {spec_b}, StatusParagraphs(std::move(status_paragraphs)));
- REQUIRE(install_plan.size() == 5);
- remove_plan_check(install_plan.at(0), "x");
- remove_plan_check(install_plan.at(1), "b");
+ REQUIRE(plan.size() == 5);
+ remove_plan_check(plan.remove_actions.at(0), "x");
+ remove_plan_check(plan.remove_actions.at(1), "b");
// TODO: order here may change but A < X, and B anywhere
- features_check(install_plan.at(2), "b", {"core", "b1"});
- features_check(install_plan.at(3), "a", {"core"});
- features_check(install_plan.at(4), "x", {"core"});
+ features_check(plan.install_actions.at(0), "b", {"core", "b1"});
+ features_check(plan.install_actions.at(1), "a", {"core"});
+ features_check(plan.install_actions.at(2), "x", {"core"});
}
-TEST_CASE ("basic feature test 8", "[plan][!mayfail]")
+TEST_CASE ("basic feature test 8", "[plan]")
{
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
status_paragraphs.push_back(make_status_pgh("a"));
@@ -413,19 +394,23 @@ TEST_CASE ("basic feature test 8", "[plan][!mayfail]")
auto spec_b_86 = FullPackageSpec{spec_map.emplace("b")};
auto spec_c_86 = FullPackageSpec{spec_map.emplace("c", "a[a1]"), {"core"}};
- auto install_plan = Dependencies::create_feature_install_plan(
- spec_map.map,
- FullPackageSpec::to_feature_specs({spec_c_64, spec_a_86, spec_a_64, spec_c_86}),
- StatusParagraphs(std::move(status_paragraphs)));
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto plan = Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {spec_c_64, spec_a_86, spec_a_64, spec_c_86},
+ StatusParagraphs(std::move(status_paragraphs)));
- remove_plan_check(install_plan.at(0), "a", Triplet::X64_WINDOWS);
- remove_plan_check(install_plan.at(1), "a");
- features_check(install_plan.at(2), "b", {"core"}, Triplet::X64_WINDOWS);
- features_check(install_plan.at(3), "a", {"a1", "core"}, Triplet::X64_WINDOWS);
+ remove_plan_check(plan.remove_actions.at(0), "a", Triplet::X64_WINDOWS);
+ remove_plan_check(plan.remove_actions.at(1), "a");
+ auto& install_plan = plan.install_actions;
+ features_check(install_plan.at(0), "b", {"core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.at(1), "a", {"a1", "core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.at(2), "b", {"core"});
+ features_check(install_plan.at(3), "a", {"a1", "core"});
features_check(install_plan.at(4), "c", {"core"}, Triplet::X64_WINDOWS);
- features_check(install_plan.at(5), "b", {"core"});
- features_check(install_plan.at(6), "a", {"a1", "core"});
- features_check(install_plan.at(7), "c", {"core"});
+ features_check(install_plan.at(5), "c", {"core"});
}
TEST_CASE ("install all features test", "[plan]")
@@ -438,13 +423,17 @@ TEST_CASE ("install all features test", "[plan]")
auto install_specs = FullPackageSpec::from_string("a[*]", Triplet::X64_WINDOWS);
REQUIRE(install_specs.has_value());
if (!install_specs.has_value()) return;
- 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)));
+
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan = Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
REQUIRE(install_plan.size() == 1);
- features_check(install_plan.at(0), "a", {"0", "1", "core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(0), "a", {"0", "1", "core"}, Triplet::X64_WINDOWS);
}
TEST_CASE ("install default features test 1", "[plan]")
@@ -457,14 +446,18 @@ TEST_CASE ("install default features test 1", "[plan]")
// 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)));
+
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan = Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
// Expect the default feature "1" to be installed, but not "0"
REQUIRE(install_plan.size() == 1);
- features_check(install_plan.at(0), "a", {"1", "core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(0), "a", {"1", "core"}, Triplet::X64_WINDOWS);
}
TEST_CASE ("install default features test 2", "[plan]")
@@ -482,16 +475,20 @@ TEST_CASE ("install default features test 2", "[plan]")
// 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)));
+
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan = Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
// Expect "a" to get removed for rebuild and then installed with default
// features.
REQUIRE(install_plan.size() == 2);
- remove_plan_check(install_plan.at(0), "a", Triplet::X64_WINDOWS);
- features_check(install_plan.at(1), "a", {"a1", "core"}, Triplet::X64_WINDOWS);
+ remove_plan_check(install_plan.remove_actions.at(0), "a", Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(0), "a", {"a1", "core"}, Triplet::X64_WINDOWS);
}
TEST_CASE ("install default features test 3", "[plan]")
@@ -504,14 +501,18 @@ TEST_CASE ("install default features test 3", "[plan]")
// Explicitly install "a" without default features
auto install_specs = FullPackageSpec::from_string("a[core]", 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)));
+
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan = Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
// Expect the default feature not to get installed.
REQUIRE(install_plan.size() == 1);
- features_check(install_plan.at(0), "a", {"core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(0), "a", {"core"}, Triplet::X64_WINDOWS);
}
TEST_CASE ("install default features of dependency test 1", "[plan]")
@@ -526,16 +527,76 @@ TEST_CASE ("install default features of dependency test 1", "[plan]")
// Install "a" (without explicit feature specification)
auto install_specs = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS);
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan = Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
+
+ // Expect "a" to get installed and defaults of "b" through the dependency,
+ // as no explicit features of "b" are installed by the user.
+ REQUIRE(install_plan.size() == 2);
+ features_check(install_plan.install_actions.at(0), "b", {"b1", "core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(1), "a", {"core"}, Triplet::X64_WINDOWS);
+}
+
+TEST_CASE ("do not install default features of dependency test 1", "[plan]")
+{
+ std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
+
+ // 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"});
+
+ // Install "a" (without explicit feature specification)
+ auto spec_a = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS);
+ auto spec_b = FullPackageSpec::from_string("b[core]", Triplet::X64_WINDOWS);
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
auto install_plan = Dependencies::create_feature_install_plan(
- spec_map.map,
- FullPackageSpec::to_feature_specs({install_specs.value_or_exit(VCPKG_LINE_INFO)}),
+ map_port,
+ var_provider,
+ {spec_a.value_or_exit(VCPKG_LINE_INFO), spec_b.value_or_exit(VCPKG_LINE_INFO)},
StatusParagraphs(std::move(status_paragraphs)));
// Expect "a" to get installed and defaults of "b" through the dependency,
// as no explicit features of "b" are installed by the user.
REQUIRE(install_plan.size() == 2);
- features_check(install_plan.at(0), "b", {"b1", "core"}, Triplet::X64_WINDOWS);
- features_check(install_plan.at(1), "a", {"core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(0), "b", {"core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(1), "a", {"core"}, Triplet::X64_WINDOWS);
+}
+
+TEST_CASE ("install default features of dependency test 2", "[plan]")
+{
+ std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
+
+ // Add a port "a" which depends on the default features of "b"
+ PackageSpecMap spec_map(Triplet::X64_WINDOWS);
+ spec_map.emplace("a", "b");
+ // "b" has two features, of which "b1" is default.
+ spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b1"});
+
+ // Install "a" (without explicit feature specification)
+ auto spec_a = FullPackageSpec::from_string("a", Triplet::X64_WINDOWS);
+ auto spec_b = FullPackageSpec::from_string("b[core]", Triplet::X64_WINDOWS);
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan = Dependencies::create_feature_install_plan(
+ map_port,
+ var_provider,
+ {spec_a.value_or_exit(VCPKG_LINE_INFO), spec_b.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
+
+ // Expect "a" to get installed and defaults of "b" through the dependency
+ REQUIRE(install_plan.size() == 2);
+ features_check(install_plan.install_actions.at(0), "b", {"b1", "core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(1), "a", {"core"}, Triplet::X64_WINDOWS);
}
TEST_CASE ("do not install default features of existing dependency", "[plan]")
@@ -554,17 +615,20 @@ TEST_CASE ("do not install default features of existing dependency", "[plan]")
// 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)));
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan = Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
// Expect "a" to get installed, but not require rebuilding "b"
REQUIRE(install_plan.size() == 1);
- features_check(install_plan.at(0), "a", {"core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(0), "a", {"core"}, Triplet::X64_WINDOWS);
}
-TEST_CASE ("install default features of dependency test 2", "[plan]")
+TEST_CASE ("install default features of dependency test 3", "[plan]")
{
std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
status_paragraphs.push_back(make_status_pgh("b"));
@@ -580,15 +644,18 @@ TEST_CASE ("install default features of dependency test 2", "[plan]")
// 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)));
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan = Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
// Expect "a" to get installed, not the defaults of "b", as the required
// dependencies are already there, installed explicitly by the user.
REQUIRE(install_plan.size() == 1);
- features_check(install_plan.at(0), "a", {"core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(0), "a", {"core"}, Triplet::X64_WINDOWS);
}
TEST_CASE ("install plan action dependencies", "[plan]")
@@ -604,19 +671,23 @@ TEST_CASE ("install plan action dependencies", "[plan]")
// 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)));
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan = Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
REQUIRE(install_plan.size() == 3);
- features_check(install_plan.at(0), "c", {"core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(0), "c", {"core"}, Triplet::X64_WINDOWS);
- features_check(install_plan.at(1), "b", {"core"}, Triplet::X64_WINDOWS);
- REQUIRE(install_plan.at(1).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_c});
+ // TODO: Figure out what to do with these tests
+ features_check(install_plan.install_actions.at(1), "b", {"core"}, Triplet::X64_WINDOWS);
+ // REQUIRE(install_plan.at(1).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_c});
- features_check(install_plan.at(2), "a", {"core"}, Triplet::X64_WINDOWS);
- REQUIRE(install_plan.at(2).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_b});
+ features_check(install_plan.install_actions.at(2), "a", {"core"}, Triplet::X64_WINDOWS);
+ // REQUIRE(install_plan.at(2).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_b});
}
TEST_CASE ("install plan action dependencies 2", "[plan]")
@@ -632,19 +703,23 @@ TEST_CASE ("install plan action dependencies 2", "[plan]")
// 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)));
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan = Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
REQUIRE(install_plan.size() == 3);
- features_check(install_plan.at(0), "c", {"core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(0), "c", {"core"}, Triplet::X64_WINDOWS);
- features_check(install_plan.at(1), "b", {"core"}, Triplet::X64_WINDOWS);
- REQUIRE(install_plan.at(1).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_c});
+ features_check(install_plan.install_actions.at(1), "b", {"core"}, Triplet::X64_WINDOWS);
+ // REQUIRE(install_plan.at(1).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_c});
- features_check(install_plan.at(2), "a", {"core"}, Triplet::X64_WINDOWS);
- REQUIRE(install_plan.at(2).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_b, spec_c});
+ features_check(install_plan.install_actions.at(2), "a", {"core"}, Triplet::X64_WINDOWS);
+ // REQUIRE(install_plan.at(2).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_b,
+ // spec_c});
}
TEST_CASE ("install plan action dependencies 3", "[plan]")
@@ -658,14 +733,17 @@ TEST_CASE ("install plan action dependencies 3", "[plan]")
// 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)));
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan = Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
REQUIRE(install_plan.size() == 1);
- features_check(install_plan.at(0), "a", {"1", "0", "core"}, Triplet::X64_WINDOWS);
- REQUIRE(install_plan.at(0).install_action.get()->computed_dependencies == std::vector<PackageSpec>{});
+ features_check(install_plan.install_actions.at(0), "a", {"1", "0", "core"}, Triplet::X64_WINDOWS);
+ // REQUIRE(install_plan.at(0).install_action.get()->computed_dependencies == std::vector<PackageSpec>{});
}
TEST_CASE ("install with default features", "[plan]")
@@ -678,14 +756,20 @@ TEST_CASE ("install with default features", "[plan]")
auto b_spec = spec_map.emplace("b", "", {{"0", ""}}, {"0"});
auto a_spec = spec_map.emplace("a", "b[core]", {{"0", ""}});
- // Install "a" and indicate that "b" should not install default features
- auto install_plan = Dependencies::create_feature_install_plan(
- spec_map.map, {FeatureSpec{a_spec, "0"}, FeatureSpec{b_spec, "core"}}, status_db);
+ PortFileProvider::MapPortFileProvider map_port{spec_map.map};
+ MockCMakeVarProvider var_provider;
+
+ auto install_plan =
+ Dependencies::create_feature_install_plan(map_port,
+ var_provider,
+ {FullPackageSpec{a_spec, {"0"}}, FullPackageSpec{b_spec, {"core"}}},
+ StatusParagraphs(std::move(status_db)));
+ // Install "a" and indicate that "b" should not install default features
REQUIRE(install_plan.size() == 3);
- remove_plan_check(install_plan.at(0), "a");
- features_check(install_plan.at(1), "b", {"core"});
- features_check(install_plan.at(2), "a", {"0", "core"});
+ remove_plan_check(install_plan.remove_actions.at(0), "a");
+ features_check(install_plan.install_actions.at(0), "b", {"core"});
+ features_check(install_plan.install_actions.at(1), "a", {"0", "core"});
}
TEST_CASE ("upgrade with default features 1", "[plan]")
@@ -699,18 +783,15 @@ TEST_CASE ("upgrade with default features 1", "[plan]")
PackageSpecMap spec_map;
auto spec_a = spec_map.emplace("a", "", {{"0", ""}, {"1", ""}}, {"1"});
- Dependencies::MapPortFileProvider provider(spec_map.map);
- Dependencies::PackageGraph graph(provider, status_db);
-
- graph.upgrade(spec_a);
- auto plan = graph.serialize();
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto plan = Dependencies::create_upgrade_plan(provider, var_provider, {spec_a}, status_db);
// The upgrade should not install the default feature
REQUIRE(plan.size() == 2);
- REQUIRE(plan.at(0).spec().name() == "a");
- remove_plan_check(plan.at(0), "a");
- features_check(plan.at(1), "a", {"core", "0"});
+ remove_plan_check(plan.remove_actions.at(0), "a");
+ features_check(plan.install_actions.at(0), "a", {"core", "0"});
}
TEST_CASE ("upgrade with default features 2", "[plan]")
@@ -726,19 +807,16 @@ TEST_CASE ("upgrade with default features 2", "[plan]")
auto spec_a = spec_map.emplace("a", "b[core]");
auto spec_b = spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b0", "b1"});
- Dependencies::MapPortFileProvider provider(spec_map.map);
- Dependencies::PackageGraph graph(provider, status_db);
-
- graph.upgrade(spec_a);
- graph.upgrade(spec_b);
- auto plan = graph.serialize();
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto plan = Dependencies::create_upgrade_plan(provider, var_provider, {spec_a, spec_b}, status_db);
// The upgrade should install the new default feature b1 but not b0
REQUIRE(plan.size() == 4);
- remove_plan_check(plan.at(0), "a", Triplet::X64_WINDOWS);
- remove_plan_check(plan.at(1), "b", Triplet::X64_WINDOWS);
- features_check(plan.at(2), "b", {"core", "b1"}, Triplet::X64_WINDOWS);
- features_check(plan.at(3), "a", {"core"}, Triplet::X64_WINDOWS);
+ remove_plan_check(plan.remove_actions.at(0), "a", Triplet::X64_WINDOWS);
+ remove_plan_check(plan.remove_actions.at(1), "b", Triplet::X64_WINDOWS);
+ features_check(plan.install_actions.at(0), "b", {"core", "b1"}, Triplet::X64_WINDOWS);
+ features_check(plan.install_actions.at(1), "a", {"core"}, Triplet::X64_WINDOWS);
}
TEST_CASE ("upgrade with default features 3", "[plan]")
@@ -754,17 +832,15 @@ TEST_CASE ("upgrade with default features 3", "[plan]")
auto spec_a = spec_map.emplace("a", "b[core]");
spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b0"});
- Dependencies::MapPortFileProvider provider(spec_map.map);
- Dependencies::PackageGraph graph(provider, status_db);
-
- graph.upgrade(spec_a);
- auto plan = graph.serialize();
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto plan = Dependencies::create_upgrade_plan(provider, var_provider, {spec_a}, status_db);
// The upgrade should install the default feature
REQUIRE(plan.size() == 3);
- remove_plan_check(plan.at(0), "a", Triplet::X64_WINDOWS);
- features_check(plan.at(1), "b", {"b0", "core"}, Triplet::X64_WINDOWS);
- features_check(plan.at(2), "a", {"core"}, Triplet::X64_WINDOWS);
+ remove_plan_check(plan.remove_actions.at(0), "a", Triplet::X64_WINDOWS);
+ features_check(plan.install_actions.at(0), "b", {"b0", "core"}, Triplet::X64_WINDOWS);
+ features_check(plan.install_actions.at(1), "a", {"core"}, Triplet::X64_WINDOWS);
}
TEST_CASE ("upgrade with new default feature", "[plan]")
@@ -777,16 +853,14 @@ TEST_CASE ("upgrade with new default feature", "[plan]")
PackageSpecMap spec_map;
auto spec_a = spec_map.emplace("a", "", {{"0", ""}, {"1", ""}, {"2", ""}}, {"0", "1"});
- Dependencies::MapPortFileProvider provider(spec_map.map);
- Dependencies::PackageGraph graph(provider, status_db);
-
- graph.upgrade(spec_a);
- auto plan = graph.serialize();
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto plan = Dependencies::create_upgrade_plan(provider, var_provider, {spec_a}, status_db);
// The upgrade should install the new default feature but not the old default feature 0
REQUIRE(plan.size() == 2);
- remove_plan_check(plan.at(0), "a", Triplet::X86_WINDOWS);
- features_check(plan.at(1), "a", {"core", "1"}, Triplet::X86_WINDOWS);
+ remove_plan_check(plan.remove_actions.at(0), "a", Triplet::X86_WINDOWS);
+ features_check(plan.install_actions.at(0), "a", {"core", "1"}, Triplet::X86_WINDOWS);
}
TEST_CASE ("transitive features test", "[plan]")
@@ -801,15 +875,18 @@ TEST_CASE ("transitive features test", "[plan]")
auto install_specs = FullPackageSpec::from_string("a[*]", Triplet::X64_WINDOWS);
REQUIRE(install_specs.has_value());
if (!install_specs.has_value()) return;
- 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)));
+
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto install_plan = Dependencies::create_feature_install_plan(provider,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
REQUIRE(install_plan.size() == 3);
- features_check(install_plan.at(0), "c", {"0", "core"}, Triplet::X64_WINDOWS);
- features_check(install_plan.at(1), "b", {"0", "core"}, Triplet::X64_WINDOWS);
- features_check(install_plan.at(2), "a", {"0", "core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(0), "c", {"0", "core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(1), "b", {"0", "core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(2), "a", {"0", "core"}, Triplet::X64_WINDOWS);
}
TEST_CASE ("no transitive features test", "[plan]")
@@ -824,15 +901,17 @@ TEST_CASE ("no transitive features test", "[plan]")
auto install_specs = FullPackageSpec::from_string("a[*]", Triplet::X64_WINDOWS);
REQUIRE(install_specs.has_value());
if (!install_specs.has_value()) return;
- 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)));
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto install_plan = Dependencies::create_feature_install_plan(provider,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
REQUIRE(install_plan.size() == 3);
- features_check(install_plan.at(0), "c", {"core"}, Triplet::X64_WINDOWS);
- features_check(install_plan.at(1), "b", {"core"}, Triplet::X64_WINDOWS);
- features_check(install_plan.at(2), "a", {"0", "core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(0), "c", {"core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(1), "b", {"core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(2), "a", {"0", "core"}, Triplet::X64_WINDOWS);
}
TEST_CASE ("only transitive features test", "[plan]")
@@ -847,15 +926,17 @@ TEST_CASE ("only transitive features test", "[plan]")
auto install_specs = FullPackageSpec::from_string("a[*]", Triplet::X64_WINDOWS);
REQUIRE(install_specs.has_value());
if (!install_specs.has_value()) return;
- 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)));
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto install_plan = Dependencies::create_feature_install_plan(provider,
+ var_provider,
+ {install_specs.value_or_exit(VCPKG_LINE_INFO)},
+ StatusParagraphs(std::move(status_paragraphs)));
REQUIRE(install_plan.size() == 3);
- features_check(install_plan.at(0), "c", {"0", "core"}, Triplet::X64_WINDOWS);
- features_check(install_plan.at(1), "b", {"0", "core"}, Triplet::X64_WINDOWS);
- features_check(install_plan.at(2), "a", {"0", "core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(0), "c", {"0", "core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(1), "b", {"0", "core"}, Triplet::X64_WINDOWS);
+ features_check(install_plan.install_actions.at(2), "a", {"0", "core"}, Triplet::X64_WINDOWS);
}
TEST_CASE ("basic remove scheme", "[plan]")
@@ -973,18 +1054,13 @@ TEST_CASE ("basic upgrade scheme", "[plan]")
PackageSpecMap spec_map;
auto spec_a = spec_map.emplace("a");
- Dependencies::MapPortFileProvider provider(spec_map.map);
- Dependencies::PackageGraph graph(provider, status_db);
-
- graph.upgrade(spec_a);
-
- auto plan = graph.serialize();
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto plan = Dependencies::create_upgrade_plan(provider, var_provider, {spec_a}, status_db);
REQUIRE(plan.size() == 2);
- REQUIRE(plan.at(0).spec().name() == "a");
- REQUIRE(plan.at(0).remove_action.has_value());
- REQUIRE(plan.at(1).spec().name() == "a");
- REQUIRE(plan.at(1).install_action.has_value());
+ remove_plan_check(plan.remove_actions.at(0), "a");
+ features_check(plan.install_actions.at(0), "a", {"core"});
}
TEST_CASE ("basic upgrade scheme with recurse", "[plan]")
@@ -998,25 +1074,15 @@ TEST_CASE ("basic upgrade scheme with recurse", "[plan]")
auto spec_a = spec_map.emplace("a");
spec_map.emplace("b", "a");
- Dependencies::MapPortFileProvider provider(spec_map.map);
- Dependencies::PackageGraph graph(provider, status_db);
-
- graph.upgrade(spec_a);
-
- auto plan = graph.serialize();
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto plan = Dependencies::create_upgrade_plan(provider, var_provider, {spec_a}, status_db);
REQUIRE(plan.size() == 4);
- REQUIRE(plan.at(0).spec().name() == "b");
- REQUIRE(plan.at(0).remove_action.has_value());
-
- REQUIRE(plan.at(1).spec().name() == "a");
- REQUIRE(plan.at(1).remove_action.has_value());
-
- REQUIRE(plan.at(2).spec().name() == "a");
- REQUIRE(plan.at(2).install_action.has_value());
-
- REQUIRE(plan.at(3).spec().name() == "b");
- REQUIRE(plan.at(3).install_action.has_value());
+ remove_plan_check(plan.remove_actions.at(0), "b");
+ remove_plan_check(plan.remove_actions.at(1), "a");
+ features_check(plan.install_actions.at(0), "a", {"core"});
+ features_check(plan.install_actions.at(1), "b", {"core"});
}
TEST_CASE ("basic upgrade scheme with bystander", "[plan]")
@@ -1030,18 +1096,13 @@ TEST_CASE ("basic upgrade scheme with bystander", "[plan]")
auto spec_a = spec_map.emplace("a");
spec_map.emplace("b", "a");
- Dependencies::MapPortFileProvider provider(spec_map.map);
- Dependencies::PackageGraph graph(provider, status_db);
-
- graph.upgrade(spec_a);
-
- auto plan = graph.serialize();
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto plan = Dependencies::create_upgrade_plan(provider, var_provider, {spec_a}, status_db);
REQUIRE(plan.size() == 2);
- REQUIRE(plan.at(0).spec().name() == "a");
- REQUIRE(plan.at(0).remove_action.has_value());
- REQUIRE(plan.at(1).spec().name() == "a");
- REQUIRE(plan.at(1).install_action.has_value());
+ remove_plan_check(plan.remove_actions.at(0), "a");
+ features_check(plan.install_actions.at(0), "a", {"core"});
}
TEST_CASE ("basic upgrade scheme with new dep", "[plan]")
@@ -1054,20 +1115,14 @@ TEST_CASE ("basic upgrade scheme with new dep", "[plan]")
auto spec_a = spec_map.emplace("a", "b");
spec_map.emplace("b");
- Dependencies::MapPortFileProvider provider(spec_map.map);
- Dependencies::PackageGraph graph(provider, status_db);
-
- graph.upgrade(spec_a);
-
- auto plan = graph.serialize();
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto plan = Dependencies::create_upgrade_plan(provider, var_provider, {spec_a}, status_db);
REQUIRE(plan.size() == 3);
- REQUIRE(plan.at(0).spec().name() == "a");
- REQUIRE(plan.at(0).remove_action.has_value());
- REQUIRE(plan.at(1).spec().name() == "b");
- REQUIRE(plan.at(1).install_action.has_value());
- REQUIRE(plan.at(2).spec().name() == "a");
- REQUIRE(plan.at(2).install_action.has_value());
+ remove_plan_check(plan.remove_actions.at(0), "a");
+ features_check(plan.install_actions.at(0), "b", {"core"});
+ features_check(plan.install_actions.at(1), "a", {"core"});
}
TEST_CASE ("basic upgrade scheme with features", "[plan]")
@@ -1080,19 +1135,13 @@ TEST_CASE ("basic upgrade scheme with features", "[plan]")
PackageSpecMap spec_map;
auto spec_a = spec_map.emplace("a", "", {{"a1", ""}});
- Dependencies::MapPortFileProvider provider(spec_map.map);
- Dependencies::PackageGraph graph(provider, status_db);
-
- graph.upgrade(spec_a);
-
- auto plan = graph.serialize();
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto plan = Dependencies::create_upgrade_plan(provider, var_provider, {spec_a}, status_db);
REQUIRE(plan.size() == 2);
-
- REQUIRE(plan.at(0).spec().name() == "a");
- REQUIRE(plan.at(0).remove_action.has_value());
-
- features_check(plan.at(1), "a", {"core", "a1"});
+ remove_plan_check(plan.remove_actions.at(0), "a");
+ features_check(plan.install_actions.at(0), "a", {"core", "a1"});
}
TEST_CASE ("basic upgrade scheme with new default feature", "[plan]")
@@ -1106,19 +1155,13 @@ TEST_CASE ("basic upgrade scheme with new default feature", "[plan]")
PackageSpecMap spec_map;
auto spec_a = spec_map.emplace("a", "", {{"a1", ""}}, {"a1"});
- Dependencies::MapPortFileProvider provider(spec_map.map);
- Dependencies::PackageGraph graph(provider, status_db);
-
- graph.upgrade(spec_a);
-
- auto plan = graph.serialize();
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto plan = Dependencies::create_upgrade_plan(provider, var_provider, {spec_a}, status_db);
REQUIRE(plan.size() == 2);
-
- REQUIRE(plan.at(0).spec().name() == "a");
- REQUIRE(plan.at(0).remove_action.has_value());
-
- features_check(plan.at(1), "a", {"core", "a1"});
+ remove_plan_check(plan.remove_actions.at(0), "a");
+ features_check(plan.install_actions.at(0), "a", {"core", "a1"});
}
TEST_CASE ("basic upgrade scheme with self features", "[plan]")
@@ -1132,21 +1175,13 @@ TEST_CASE ("basic upgrade scheme with self features", "[plan]")
PackageSpecMap spec_map;
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();
+ PortFileProvider::MapPortFileProvider provider(spec_map.map);
+ MockCMakeVarProvider var_provider;
+ auto plan = Dependencies::create_upgrade_plan(provider, var_provider, {spec_a}, status_db);
REQUIRE(plan.size() == 2);
-
- REQUIRE(plan.at(0).spec().name() == "a");
- REQUIRE(plan.at(0).remove_action.has_value());
-
- REQUIRE(plan.at(1).spec().name() == "a");
- REQUIRE(plan.at(1).install_action.has_value());
- REQUIRE(plan.at(1).install_action.get()->feature_list == std::set<std::string>{"core", "a1", "a2"});
+ remove_plan_check(plan.remove_actions.at(0), "a");
+ features_check(plan.install_actions.at(0), "a", {"a1", "a2", "core"});
}
TEST_CASE ("basic export scheme", "[plan]")
diff --git a/toolsrc/src/vcpkg-test/specifier.cpp b/toolsrc/src/vcpkg-test/specifier.cpp
index 33df8ba83..a0a3725e8 100644
--- a/toolsrc/src/vcpkg-test/specifier.cpp
+++ b/toolsrc/src/vcpkg-test/specifier.cpp
@@ -1,5 +1,6 @@
#include <catch2/catch.hpp>
+#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>
#include <vcpkg/packagespec.h>
@@ -14,11 +15,13 @@ TEST_CASE ("specifier conversion", "[specifier]")
auto a_spec = PackageSpec::from_name_and_triplet("a", Triplet::X64_WINDOWS).value_or_exit(VCPKG_LINE_INFO);
auto b_spec = PackageSpec::from_name_and_triplet("b", Triplet::X64_WINDOWS).value_or_exit(VCPKG_LINE_INFO);
- auto fspecs = FullPackageSpec::to_feature_specs({{a_spec, {"0", "1"}}, {b_spec, {"2", "3"}}});
-
+ auto fspecs = FullPackageSpec{a_spec, {"0", "1"}}.to_feature_specs({}, {});
+ auto fspecs2 = FullPackageSpec{b_spec, {"2", "3"}}.to_feature_specs({}, {});
+ Util::Vectors::append(&fspecs, fspecs2);
+ Util::sort(fspecs);
REQUIRE(fspecs.size() == SPEC_SIZE);
- std::array<const char*, SPEC_SIZE> features = {"", "0", "1", "", "2", "3"};
+ std::array<const char*, SPEC_SIZE> features = {"0", "1", "core", "2", "3", "core"};
std::array<PackageSpec*, SPEC_SIZE> specs = {&a_spec, &a_spec, &a_spec, &b_spec, &b_spec, &b_spec};
for (std::size_t i = 0; i < SPEC_SIZE; ++i)
@@ -101,19 +104,20 @@ TEST_CASE ("specifier parsing", "[specifier]")
auto zlib = vcpkg::FullPackageSpec::from_string("zlib[0,1]", Triplet::X86_UWP).value_or_exit(VCPKG_LINE_INFO);
auto openssl =
vcpkg::FullPackageSpec::from_string("openssl[*]", Triplet::X86_UWP).value_or_exit(VCPKG_LINE_INFO);
- auto specs = FullPackageSpec::to_feature_specs({zlib, openssl});
+ auto specs = zlib.to_feature_specs({}, {});
+ auto specs2 = openssl.to_feature_specs({}, {});
+ Util::Vectors::append(&specs, specs2);
Util::sort(specs);
+
auto spectargets = FeatureSpec::from_strings_and_triplet(
{
"openssl",
"zlib",
- "openssl[*]",
"zlib[0]",
"zlib[1]",
},
Triplet::X86_UWP);
Util::sort(spectargets);
-
REQUIRE(specs.size() == spectargets.size());
REQUIRE(Util::all_equal(specs, spectargets));
}
diff --git a/toolsrc/src/vcpkg-test/supports.cpp b/toolsrc/src/vcpkg-test/supports.cpp
deleted file mode 100644
index f4d8dc65a..000000000
--- a/toolsrc/src/vcpkg-test/supports.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/sourceparagraph.h>
-
-using namespace vcpkg;
-using Parse::parse_comma_list;
-
-TEST_CASE ("parse supports all", "[supports]")
-{
- auto v = Supports::parse({
- "x64",
- "x86",
- "arm",
- "windows",
- "uwp",
- "v140",
- "v141",
- "crt-static",
- "crt-dynamic",
- });
-
- REQUIRE(v.has_value());
-
- REQUIRE(v.get()->is_supported(System::CPUArchitecture::X64,
- Supports::Platform::UWP,
- Supports::Linkage::DYNAMIC,
- Supports::ToolsetVersion::V140));
- REQUIRE(v.get()->is_supported(System::CPUArchitecture::ARM,
- Supports::Platform::WINDOWS,
- Supports::Linkage::STATIC,
- Supports::ToolsetVersion::V141));
-}
-
-TEST_CASE ("parse supports invalid", "[supports]")
-{
- auto v = Supports::parse({"arm64"});
-
- REQUIRE_FALSE(v.has_value());
-
- REQUIRE(v.error().size() == 1);
- REQUIRE(v.error().at(0) == "arm64");
-}
-
-TEST_CASE ("parse supports case sensitive", "[supports]")
-{
- auto v = Supports::parse({"Windows"});
-
- REQUIRE_FALSE(v.has_value());
- REQUIRE(v.error().size() == 1);
- REQUIRE(v.error().at(0) == "Windows");
-}
-
-TEST_CASE ("parse supports some", "[supports]")
-{
- auto v = Supports::parse({
- "x64",
- "x86",
- "windows",
- });
-
- REQUIRE(v.has_value());
-
- REQUIRE(v.get()->is_supported(System::CPUArchitecture::X64,
- Supports::Platform::WINDOWS,
- Supports::Linkage::DYNAMIC,
- Supports::ToolsetVersion::V140));
- REQUIRE_FALSE(v.get()->is_supported(System::CPUArchitecture::ARM,
- Supports::Platform::WINDOWS,
- Supports::Linkage::DYNAMIC,
- Supports::ToolsetVersion::V140));
- REQUIRE_FALSE(v.get()->is_supported(System::CPUArchitecture::X64,
- Supports::Platform::UWP,
- Supports::Linkage::DYNAMIC,
- Supports::ToolsetVersion::V140));
- REQUIRE(v.get()->is_supported(System::CPUArchitecture::X64,
- Supports::Platform::WINDOWS,
- Supports::Linkage::STATIC,
- Supports::ToolsetVersion::V141));
-}
diff --git a/toolsrc/src/vcpkg-test/update.cpp b/toolsrc/src/vcpkg-test/update.cpp
index 6f1a87d23..a362df720 100644
--- a/toolsrc/src/vcpkg-test/update.cpp
+++ b/toolsrc/src/vcpkg-test/update.cpp
@@ -20,9 +20,9 @@ TEST_CASE ("find outdated packages basic", "[update]")
StatusParagraphs status_db(std::move(status_paragraphs));
std::unordered_map<std::string, SourceControlFileLocation> map;
- auto scf = unwrap(SourceControlFile::parse_control_file(Pgh{{{"Source", "a"}, {"Version", "0"}}}));
+ auto scf = unwrap(SourceControlFile::parse_control_file("", Pgh{{{"Source", "a"}, {"Version", "0"}}}));
map.emplace("a", SourceControlFileLocation{std::move(scf), ""});
- Dependencies::MapPortFileProvider provider(map);
+ PortFileProvider::MapPortFileProvider provider(map);
auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
&OutdatedPackage::compare_by_name);
@@ -44,9 +44,9 @@ TEST_CASE ("find outdated packages features", "[update]")
StatusParagraphs status_db(std::move(status_paragraphs));
std::unordered_map<std::string, SourceControlFileLocation> map;
- auto scf = unwrap(SourceControlFile::parse_control_file(Pgh{{{"Source", "a"}, {"Version", "0"}}}));
+ auto scf = unwrap(SourceControlFile::parse_control_file("", Pgh{{{"Source", "a"}, {"Version", "0"}}}));
map.emplace("a", SourceControlFileLocation{std::move(scf), ""});
- Dependencies::MapPortFileProvider provider(map);
+ PortFileProvider::MapPortFileProvider provider(map);
auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
&OutdatedPackage::compare_by_name);
@@ -70,9 +70,9 @@ TEST_CASE ("find outdated packages features 2", "[update]")
StatusParagraphs status_db(std::move(status_paragraphs));
std::unordered_map<std::string, SourceControlFileLocation> map;
- auto scf = unwrap(SourceControlFile::parse_control_file(Pgh{{{"Source", "a"}, {"Version", "0"}}}));
+ auto scf = unwrap(SourceControlFile::parse_control_file("", Pgh{{{"Source", "a"}, {"Version", "0"}}}));
map.emplace("a", SourceControlFileLocation{std::move(scf), ""});
- Dependencies::MapPortFileProvider provider(map);
+ PortFileProvider::MapPortFileProvider provider(map);
auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
&OutdatedPackage::compare_by_name);
@@ -91,9 +91,9 @@ TEST_CASE ("find outdated packages none", "[update]")
StatusParagraphs status_db(std::move(status_paragraphs));
std::unordered_map<std::string, SourceControlFileLocation> map;
- auto scf = unwrap(SourceControlFile::parse_control_file(Pgh{{{"Source", "a"}, {"Version", "2"}}}));
+ auto scf = unwrap(SourceControlFile::parse_control_file("", Pgh{{{"Source", "a"}, {"Version", "2"}}}));
map.emplace("a", SourceControlFileLocation{std::move(scf), ""});
- Dependencies::MapPortFileProvider provider(map);
+ PortFileProvider::MapPortFileProvider provider(map);
auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
&OutdatedPackage::compare_by_name);
diff --git a/toolsrc/src/vcpkg-test/util.cpp b/toolsrc/src/vcpkg-test/util.cpp
index daa21567d..db310f7a0 100644
--- a/toolsrc/src/vcpkg-test/util.cpp
+++ b/toolsrc/src/vcpkg-test/util.cpp
@@ -38,6 +38,31 @@
namespace vcpkg::Test
{
+ std::unique_ptr<SourceControlFile> make_control_file(
+ const char* name,
+ const char* depends,
+ const std::vector<std::pair<const char*, const char*>>& features,
+ const std::vector<const char*>& default_features)
+ {
+ using Pgh = std::unordered_map<std::string, std::string>;
+ std::vector<Pgh> scf_pghs;
+ scf_pghs.push_back(Pgh{{"Source", name},
+ {"Version", "0"},
+ {"Build-Depends", depends},
+ {"Default-Features", Strings::join(", ", default_features)}});
+ for (auto&& feature : features)
+ {
+ scf_pghs.push_back(Pgh{
+ {"Feature", feature.first},
+ {"Description", "feature"},
+ {"Build-Depends", feature.second},
+ });
+ }
+ auto m_pgh = vcpkg::SourceControlFile::parse_control_file("", std::move(scf_pghs));
+ REQUIRE(m_pgh.has_value());
+ return std::move(*m_pgh.get());
+ }
+
std::unique_ptr<vcpkg::StatusParagraph> make_status_pgh(const char* name,
const char* depends,
const char* default_features,
@@ -68,6 +93,23 @@ namespace vcpkg::Test
{"Status", "install ok installed"}});
}
+ PackageSpec PackageSpecMap::emplace(const char* name,
+ const char* depends,
+ const std::vector<std::pair<const char*, const char*>>& features,
+ const std::vector<const char*>& default_features)
+ {
+ auto scfl = SourceControlFileLocation{make_control_file(name, depends, features, default_features), ""};
+ return emplace(std::move(scfl));
+ }
+
+ PackageSpec PackageSpecMap::emplace(vcpkg::SourceControlFileLocation&& scfl)
+ {
+ auto spec = PackageSpec::from_name_and_triplet(scfl.source_control_file->core_paragraph->name, triplet);
+ REQUIRE(spec.has_value());
+ map.emplace(scfl.source_control_file->core_paragraph->name, std::move(scfl));
+ return PackageSpec{*spec.get()};
+ }
+
PackageSpec unsafe_pspec(std::string name, Triplet t)
{
auto m_ret = PackageSpec::from_name_and_triplet(name, t);