aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test
diff options
context:
space:
mode:
authorBilly O'Neal <bion@microsoft.com>2021-02-04 10:15:44 -0800
committerGitHub <noreply@github.com>2021-02-04 10:15:44 -0800
commitaa60b7efa56a83ead743718941d8b320ef4a05af (patch)
treedb9f9ebd6fa37598b2f5f2ad564eb858cdeddcb0 /toolsrc/src/vcpkg-test
parentf226416d2eafc495dd03572cb61542fb1670ffdc (diff)
downloadvcpkg-aa60b7efa56a83ead743718941d8b320ef4a05af.tar.gz
vcpkg-aa60b7efa56a83ead743718941d8b320ef4a05af.zip
[vcpkg] Download vcpkg.exe rather than building it in bootstrap on Windows. (#15474)
This reduces bootstrap cost for Windows customers, resolving the issue initially submitted as #12502 . The `toolsrc` tree was extracted to https://github.com/microsoft/vcpkg-tool. `bootstrap.sh` was changed to download the right source tarball, extract, and build it. This was chosen over the previous attempt, a submodule, over concerns of accidentally destroying people's local modifications.
Diffstat (limited to 'toolsrc/src/vcpkg-test')
-rw-r--r--toolsrc/src/vcpkg-test/arguments.cpp135
-rw-r--r--toolsrc/src/vcpkg-test/binarycaching.cpp290
-rw-r--r--toolsrc/src/vcpkg-test/binaryconfigparser.cpp336
-rw-r--r--toolsrc/src/vcpkg-test/catch.cpp12
-rw-r--r--toolsrc/src/vcpkg-test/chrono.cpp34
-rw-r--r--toolsrc/src/vcpkg-test/commands.cpp83
-rw-r--r--toolsrc/src/vcpkg-test/dependencies.cpp1713
-rw-r--r--toolsrc/src/vcpkg-test/downloads.cpp59
-rw-r--r--toolsrc/src/vcpkg-test/files.cpp406
-rw-r--r--toolsrc/src/vcpkg-test/hash.cpp276
-rw-r--r--toolsrc/src/vcpkg-test/json.cpp241
-rw-r--r--toolsrc/src/vcpkg-test/large-json-document.json.inc516
-rw-r--r--toolsrc/src/vcpkg-test/manifests.cpp733
-rw-r--r--toolsrc/src/vcpkg-test/mockcmakevarsprovider.cpp28
-rw-r--r--toolsrc/src/vcpkg-test/optional.cpp121
-rw-r--r--toolsrc/src/vcpkg-test/paragraph.cpp516
-rw-r--r--toolsrc/src/vcpkg-test/plan.cpp1297
-rw-r--r--toolsrc/src/vcpkg-test/platform-expression.cpp80
-rw-r--r--toolsrc/src/vcpkg-test/registries.cpp132
-rw-r--r--toolsrc/src/vcpkg-test/specifier.cpp130
-rw-r--r--toolsrc/src/vcpkg-test/statusparagraphs.cpp116
-rw-r--r--toolsrc/src/vcpkg-test/strings.cpp114
-rw-r--r--toolsrc/src/vcpkg-test/stringview.cpp19
-rw-r--r--toolsrc/src/vcpkg-test/system.cpp149
-rw-r--r--toolsrc/src/vcpkg-test/uint128.cpp68
-rw-r--r--toolsrc/src/vcpkg-test/update.cpp105
-rw-r--r--toolsrc/src/vcpkg-test/util.cpp230
-rw-r--r--toolsrc/src/vcpkg-test/versionplan.cpp152
28 files changed, 0 insertions, 8091 deletions
diff --git a/toolsrc/src/vcpkg-test/arguments.cpp b/toolsrc/src/vcpkg-test/arguments.cpp
deleted file mode 100644
index 7a7c70151..000000000
--- a/toolsrc/src/vcpkg-test/arguments.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/vcpkgcmdarguments.h>
-
-#include <vector>
-
-using vcpkg::CommandSetting;
-using vcpkg::CommandStructure;
-using vcpkg::CommandSwitch;
-using vcpkg::VcpkgCmdArguments;
-
-TEST_CASE ("VcpkgCmdArguments from lowercase argument sequence", "[arguments]")
-{
- std::vector<std::string> t = {"--vcpkg-root",
- "C:\\vcpkg",
- "--x-scripts-root=C:\\scripts",
- "--x-builtin-ports-root=C:\\ports",
- "--x-builtin-registry-versions-dir=C:\\versions",
- "--debug",
- "--sendmetrics",
- "--printmetrics",
- "--overlay-ports=C:\\ports1",
- "--overlay-ports=C:\\ports2",
- "--overlay-triplets=C:\\tripletsA",
- "--overlay-triplets=C:\\tripletsB"};
- auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
-
- REQUIRE(*v.vcpkg_root_dir == "C:\\vcpkg");
- REQUIRE(*v.scripts_root_dir == "C:\\scripts");
- REQUIRE(*v.builtin_ports_root_dir == "C:\\ports");
- REQUIRE(*v.builtin_registry_versions_dir == "C:\\versions");
- REQUIRE(v.debug);
- REQUIRE(*v.debug.get());
- REQUIRE(v.send_metrics);
- REQUIRE(*v.send_metrics.get());
- REQUIRE(v.print_metrics);
- REQUIRE(*v.print_metrics.get());
-
- REQUIRE(v.overlay_ports.size() == 2);
- REQUIRE(v.overlay_ports.at(0) == "C:\\ports1");
- REQUIRE(v.overlay_ports.at(1) == "C:\\ports2");
-
- REQUIRE(v.overlay_triplets.size() == 2);
- REQUIRE(v.overlay_triplets.at(0) == "C:\\tripletsA");
- REQUIRE(v.overlay_triplets.at(1) == "C:\\tripletsB");
-}
-
-TEST_CASE ("VcpkgCmdArguments from uppercase argument sequence", "[arguments]")
-{
- std::vector<std::string> t = {"--VCPKG-ROOT",
- "C:\\vcpkg",
- "--X-SCRIPTS-ROOT=C:\\scripts",
- "--X-BUILTIN-PORTS-ROOT=C:\\ports",
- "--X-BUILTIN-REGISTRY-VERSIONS-DIR=C:\\versions",
- "--DEBUG",
- "--SENDMETRICS",
- "--PRINTMETRICS",
- "--OVERLAY-PORTS=C:\\ports1",
- "--OVERLAY-PORTS=C:\\ports2",
- "--OVERLAY-TRIPLETS=C:\\tripletsA",
- "--OVERLAY-TRIPLETS=C:\\tripletsB"};
- auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
-
- REQUIRE(*v.vcpkg_root_dir == "C:\\vcpkg");
- REQUIRE(*v.scripts_root_dir == "C:\\scripts");
- REQUIRE(*v.builtin_ports_root_dir == "C:\\ports");
- REQUIRE(*v.builtin_registry_versions_dir == "C:\\versions");
- REQUIRE(v.debug);
- REQUIRE(*v.debug.get());
- REQUIRE(v.send_metrics);
- REQUIRE(*v.send_metrics.get());
- REQUIRE(v.print_metrics);
- REQUIRE(*v.print_metrics.get());
-
- REQUIRE(v.overlay_ports.size() == 2);
- REQUIRE(v.overlay_ports.at(0) == "C:\\ports1");
- REQUIRE(v.overlay_ports.at(1) == "C:\\ports2");
-
- REQUIRE(v.overlay_triplets.size() == 2);
- REQUIRE(v.overlay_triplets.at(0) == "C:\\tripletsA");
- REQUIRE(v.overlay_triplets.at(1) == "C:\\tripletsB");
-}
-
-TEST_CASE ("VcpkgCmdArguments from argument sequence with valued options", "[arguments]")
-{
- SECTION ("case 1")
- {
- std::array<CommandSetting, 1> settings = {{{"a", ""}}};
- CommandStructure cmdstruct = {"", 0, SIZE_MAX, {{}, settings}, nullptr};
-
- std::vector<std::string> t = {"--a=b", "command", "argument"};
- auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
- auto opts = v.parse_arguments(cmdstruct);
-
- REQUIRE(opts.settings["a"] == "b");
- REQUIRE(v.command_arguments.size() == 1);
- REQUIRE(v.command_arguments[0] == "argument");
- REQUIRE(v.command == "command");
- }
-
- SECTION ("case 2")
- {
- std::array<CommandSwitch, 2> switches = {{{"a", ""}, {"c", ""}}};
- std::array<CommandSetting, 2> settings = {{{"b", ""}, {"d", ""}}};
- CommandStructure cmdstruct = {"", 0, SIZE_MAX, {switches, settings}, nullptr};
-
- std::vector<std::string> t = {"--a", "--b=c"};
- auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
- auto opts = v.parse_arguments(cmdstruct);
-
- REQUIRE(opts.settings["b"] == "c");
- REQUIRE(opts.settings.find("d") == opts.settings.end());
- REQUIRE(opts.switches.find("a") != opts.switches.end());
- REQUIRE(opts.settings.find("c") == opts.settings.end());
- REQUIRE(v.command_arguments.size() == 0);
- }
-}
-
-TEST_CASE ("vcpkg_root parse with arg separator", "[arguments]")
-{
- std::vector<std::string> t = {"--vcpkg-root", "C:\\vcpkg"};
- auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
- auto& vcpkg_root_dir = v.vcpkg_root_dir;
- REQUIRE(vcpkg_root_dir);
- REQUIRE(*vcpkg_root_dir == "C:\\vcpkg");
-}
-
-TEST_CASE ("vcpkg_root parse with equal separator", "[arguments]")
-{
- std::vector<std::string> t = {"--vcpkg-root=C:\\vcpkg"};
- auto v = VcpkgCmdArguments::create_from_arg_sequence(t.data(), t.data() + t.size());
- auto& vcpkg_root_dir = v.vcpkg_root_dir;
- REQUIRE(vcpkg_root_dir);
- REQUIRE(*vcpkg_root_dir == "C:\\vcpkg");
-}
diff --git a/toolsrc/src/vcpkg-test/binarycaching.cpp b/toolsrc/src/vcpkg-test/binarycaching.cpp
deleted file mode 100644
index 8a1a28d23..000000000
--- a/toolsrc/src/vcpkg-test/binarycaching.cpp
+++ /dev/null
@@ -1,290 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/files.h>
-#include <vcpkg/base/xmlserializer.h>
-
-#include <vcpkg/binarycaching.h>
-#include <vcpkg/binarycaching.private.h>
-#include <vcpkg/dependencies.h>
-#include <vcpkg/paragraphs.h>
-#include <vcpkg/sourceparagraph.h>
-#include <vcpkg/vcpkgcmdarguments.h>
-
-#include <string>
-
-#include <vcpkg-test/util.h>
-
-using namespace vcpkg;
-
-#define REQUIRE_EQUAL_TEXT(lhs, rhs) \
- { \
- auto lhs_lines = Strings::split((lhs), '\n'); \
- auto rhs_lines = Strings::split((rhs), '\n'); \
- for (size_t i = 0; i < lhs_lines.size() && i < rhs_lines.size(); ++i) \
- { \
- INFO("on line: " << i); \
- REQUIRE(lhs_lines[i] == rhs_lines[i]); \
- } \
- REQUIRE(lhs_lines.size() == rhs_lines.size()); \
- }
-
-TEST_CASE ("reformat_version semver-ish", "[reformat_version]")
-{
- REQUIRE(reformat_version("0.0.0", "abitag") == "0.0.0-vcpkgabitag");
- REQUIRE(reformat_version("1.0.1", "abitag") == "1.0.1-vcpkgabitag");
- REQUIRE(reformat_version("1.01.000", "abitag") == "1.1.0-vcpkgabitag");
- REQUIRE(reformat_version("1.2", "abitag") == "1.2.0-vcpkgabitag");
- REQUIRE(reformat_version("v52", "abitag") == "52.0.0-vcpkgabitag");
- REQUIRE(reformat_version("v09.01.02", "abitag") == "9.1.2-vcpkgabitag");
- REQUIRE(reformat_version("1.1.1q", "abitag") == "1.1.1-vcpkgabitag");
- REQUIRE(reformat_version("1", "abitag") == "1.0.0-vcpkgabitag");
-}
-
-TEST_CASE ("reformat_version date", "[reformat_version]")
-{
- REQUIRE(reformat_version("2020-06-26", "abitag") == "2020.6.26-vcpkgabitag");
- REQUIRE(reformat_version("20-06-26", "abitag") == "0.0.0-vcpkgabitag");
- REQUIRE(reformat_version("2020-06-26-release", "abitag") == "2020.6.26-vcpkgabitag");
- REQUIRE(reformat_version("2020-06-26000", "abitag") == "2020.6.26-vcpkgabitag");
-}
-
-TEST_CASE ("reformat_version generic", "[reformat_version]")
-{
- REQUIRE(reformat_version("apr", "abitag") == "0.0.0-vcpkgabitag");
- REQUIRE(reformat_version("", "abitag") == "0.0.0-vcpkgabitag");
-}
-
-TEST_CASE ("generate_nuspec", "[generate_nuspec]")
-{
- auto& fsWrapper = Files::get_real_filesystem();
- VcpkgCmdArguments args = VcpkgCmdArguments::create_from_arg_sequence(nullptr, nullptr);
- args.imbue_from_environment();
- args.packages_root_dir = std::make_unique<std::string>("/");
- auto pkgPath = fsWrapper.absolute(VCPKG_LINE_INFO, fs::u8path("/zlib2_x64-windows")) / fs::u8path("**");
- pkgPath.make_preferred();
- const auto pkgPathStr = fs::u8string(pkgPath);
- VcpkgPaths paths(fsWrapper, args);
-
- auto pghs = Paragraphs::parse_paragraphs(R"(
-Source: zlib2
-Version: 1.5
-Build-Depends: zlib
-Description: a spiffy compression library wrapper
-
-Feature: a
-Description: a feature
-
-Feature: b
-Description: enable bzip capabilities
-Build-Depends: bzip
-)",
- "<testdata>");
- REQUIRE(pghs.has_value());
- auto maybe_scf = SourceControlFile::parse_control_file(fs::u8string(fs::path()), std::move(*pghs.get()));
- REQUIRE(maybe_scf.has_value());
- SourceControlFileLocation scfl{std::move(*maybe_scf.get()), fs::path()};
-
- Dependencies::InstallPlanAction ipa(PackageSpec{"zlib2", Test::X64_WINDOWS},
- scfl,
- Dependencies::RequestType::USER_REQUESTED,
- {{"a", {}}, {"b", {}}});
-
- ipa.abi_info = Build::AbiInfo{};
- ipa.abi_info.get()->package_abi = "packageabi";
- std::string tripletabi("tripletabi");
- ipa.abi_info.get()->triplet_abi = tripletabi;
- Build::CompilerInfo compiler_info;
- compiler_info.hash = "compilerhash";
- compiler_info.id = "compilerid";
- compiler_info.version = "compilerversion";
- ipa.abi_info.get()->compiler_info = compiler_info;
-
- NugetReference ref(ipa);
-
- REQUIRE(ref.nupkg_filename() == "zlib2_x64-windows.1.5.0-vcpkgpackageabi.nupkg");
-
- {
- auto nuspec = generate_nuspec(paths, ipa, ref, {});
- std::string expected = R"(<package>
- <metadata>
- <id>zlib2_x64-windows</id>
- <version>1.5.0-vcpkgpackageabi</version>
- <authors>vcpkg</authors>
- <description>NOT FOR DIRECT USE. Automatically generated cache package.
-
-a spiffy compression library wrapper
-
-Version: 1.5
-Triplet: x64-windows
-CXX Compiler id: compilerid
-CXX Compiler version: compilerversion
-Triplet/Compiler hash: tripletabi
-Features: a, b
-Dependencies:
-</description>
- <packageTypes><packageType name="vcpkg"/></packageTypes>
- </metadata>
- <files><file src=")" + pkgPathStr +
- R"(" target=""/></files>
-</package>
-)";
- REQUIRE_EQUAL_TEXT(nuspec, expected);
- }
-
- {
- auto nuspec = generate_nuspec(paths, ipa, ref, {"urlvalue"});
- std::string expected = R"(<package>
- <metadata>
- <id>zlib2_x64-windows</id>
- <version>1.5.0-vcpkgpackageabi</version>
- <authors>vcpkg</authors>
- <description>NOT FOR DIRECT USE. Automatically generated cache package.
-
-a spiffy compression library wrapper
-
-Version: 1.5
-Triplet: x64-windows
-CXX Compiler id: compilerid
-CXX Compiler version: compilerversion
-Triplet/Compiler hash: tripletabi
-Features: a, b
-Dependencies:
-</description>
- <packageTypes><packageType name="vcpkg"/></packageTypes>
- <repository type="git" url="urlvalue"/>
- </metadata>
- <files><file src=")" + pkgPathStr +
- R"(" target=""/></files>
-</package>
-)";
- REQUIRE_EQUAL_TEXT(nuspec, expected);
- }
- {
- auto nuspec = generate_nuspec(paths, ipa, ref, {"urlvalue", "branchvalue", "commitvalue"});
- std::string expected = R"(<package>
- <metadata>
- <id>zlib2_x64-windows</id>
- <version>1.5.0-vcpkgpackageabi</version>
- <authors>vcpkg</authors>
- <description>NOT FOR DIRECT USE. Automatically generated cache package.
-
-a spiffy compression library wrapper
-
-Version: 1.5
-Triplet: x64-windows
-CXX Compiler id: compilerid
-CXX Compiler version: compilerversion
-Triplet/Compiler hash: tripletabi
-Features: a, b
-Dependencies:
-</description>
- <packageTypes><packageType name="vcpkg"/></packageTypes>
- <repository type="git" url="urlvalue" branch="branchvalue" commit="commitvalue"/>
- </metadata>
- <files><file src=")" + pkgPathStr +
- R"(" target=""/></files>
-</package>
-)";
- REQUIRE_EQUAL_TEXT(nuspec, expected);
- }
-}
-
-TEST_CASE ("XmlSerializer", "[XmlSerializer]")
-{
- XmlSerializer xml;
- xml.open_tag("a");
- xml.open_tag("b");
- xml.simple_tag("c", "d");
- xml.close_tag("b");
- xml.text("escaping: & < > \" '");
-
- REQUIRE(xml.buf == R"(<a><b><c>d</c></b>escaping: &amp; &lt; &gt; &quot; &apos;)");
-
- xml = XmlSerializer();
- xml.emit_declaration();
- xml.start_complex_open_tag("a")
- .text_attr("b", "<")
- .text_attr("c", " ")
- .finish_self_closing_complex_tag()
- .line_break();
- xml.simple_tag("d", "e");
- REQUIRE(xml.buf == R"(<?xml version="1.0" encoding="utf-8"?><a b="&lt;" c=" "/>)"
- "\n<d>e</d>");
-
- xml = XmlSerializer();
- xml.start_complex_open_tag("a").finish_complex_open_tag();
- REQUIRE(xml.buf == R"(<a>)");
-
- xml = XmlSerializer();
- xml.line_break();
- xml.open_tag("a").line_break().line_break();
- xml.close_tag("a").line_break().line_break();
- REQUIRE(xml.buf == "\n<a>\n\n</a>\n\n");
-
- xml = XmlSerializer();
- xml.start_complex_open_tag("a")
- .text_attr("b", "<")
- .line_break()
- .text_attr("c", " ")
- .finish_complex_open_tag()
- .line_break();
- xml.simple_tag("d", "e").line_break();
- REQUIRE(xml.buf == "<a b=\"&lt;\"\n c=\" \">\n <d>e</d>\n");
-}
-
-TEST_CASE ("generate_nuget_packages_config", "[generate_nuget_packages_config]")
-{
- Dependencies::ActionPlan plan;
- auto packageconfig = generate_nuget_packages_config(plan);
- REQUIRE(packageconfig == R"(<?xml version="1.0" encoding="utf-8"?>
-<packages>
-</packages>
-)");
-
- auto pghs = Paragraphs::parse_paragraphs(R"(
-Source: zlib
-Version: 1.5
-Description: a spiffy compression library wrapper
-)",
- "<testdata>");
- REQUIRE(pghs.has_value());
- auto maybe_scf = SourceControlFile::parse_control_file(fs::u8string(fs::path()), std::move(*pghs.get()));
- REQUIRE(maybe_scf.has_value());
- SourceControlFileLocation scfl{std::move(*maybe_scf.get()), fs::path()};
- plan.install_actions.push_back(Dependencies::InstallPlanAction());
- plan.install_actions[0].spec = PackageSpec("zlib", Test::X64_ANDROID);
- plan.install_actions[0].source_control_file_location = scfl;
- plan.install_actions[0].abi_info = Build::AbiInfo{};
- plan.install_actions[0].abi_info.get()->package_abi = "packageabi";
-
- packageconfig = generate_nuget_packages_config(plan);
- REQUIRE(packageconfig == R"(<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="zlib_x64-android" version="1.5.0-vcpkgpackageabi"/>
-</packages>
-)");
-
- auto pghs2 = Paragraphs::parse_paragraphs(R"(
-Source: zlib2
-Version: 1.52
-Description: a spiffy compression library wrapper
-)",
- "<testdata>");
- REQUIRE(pghs2.has_value());
- auto maybe_scf2 = SourceControlFile::parse_control_file(fs::u8string(fs::path()), std::move(*pghs2.get()));
- REQUIRE(maybe_scf2.has_value());
- SourceControlFileLocation scfl2{std::move(*maybe_scf2.get()), fs::path()};
- plan.install_actions.push_back(Dependencies::InstallPlanAction());
- plan.install_actions[1].spec = PackageSpec("zlib2", Test::X64_ANDROID);
- plan.install_actions[1].source_control_file_location = scfl2;
- plan.install_actions[1].abi_info = Build::AbiInfo{};
- plan.install_actions[1].abi_info.get()->package_abi = "packageabi2";
-
- packageconfig = generate_nuget_packages_config(plan);
- REQUIRE(packageconfig == R"(<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="zlib_x64-android" version="1.5.0-vcpkgpackageabi"/>
- <package id="zlib2_x64-android" version="1.52.0-vcpkgpackageabi2"/>
-</packages>
-)");
-}
diff --git a/toolsrc/src/vcpkg-test/binaryconfigparser.cpp b/toolsrc/src/vcpkg-test/binaryconfigparser.cpp
deleted file mode 100644
index 1c46790bf..000000000
--- a/toolsrc/src/vcpkg-test/binaryconfigparser.cpp
+++ /dev/null
@@ -1,336 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/binarycaching.h>
-
-using namespace vcpkg;
-
-#if defined(_WIN32)
-#define ABSOLUTE_PATH "C:\\foo"
-#else
-#define ABSOLUTE_PATH "/foo"
-#endif
-
-TEST_CASE ("BinaryConfigParser empty", "[binaryconfigparser]")
-{
- auto parsed = create_binary_provider_from_configs_pure("", {});
- REQUIRE(parsed.has_value());
-}
-
-TEST_CASE ("BinaryConfigParser unacceptable provider", "[binaryconfigparser]")
-{
- auto parsed = create_binary_provider_from_configs_pure("unacceptable", {});
- REQUIRE(!parsed.has_value());
-}
-
-TEST_CASE ("BinaryConfigParser files provider", "[binaryconfigparser]")
-{
- {
- auto parsed = create_binary_provider_from_configs_pure("files", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files,relative-path", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files,C:foo", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH, {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH ",nonsense", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH ",read", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH ",write", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH ",readwrite", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH ",readwrite,extra", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files,,upload", {});
- REQUIRE(!parsed.has_value());
- }
-}
-
-TEST_CASE ("BinaryConfigParser nuget source provider", "[binaryconfigparser]")
-{
- {
- auto parsed = create_binary_provider_from_configs_pure("nuget", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nuget,relative-path", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nuget,http://example.org/", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nuget," ABSOLUTE_PATH, {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nuget," ABSOLUTE_PATH ",nonsense", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nuget," ABSOLUTE_PATH ",readwrite", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nuget," ABSOLUTE_PATH ",readwrite,extra", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nuget,,readwrite", {});
- REQUIRE(!parsed.has_value());
- }
-}
-
-TEST_CASE ("BinaryConfigParser nuget config provider", "[binaryconfigparser]")
-{
- {
- auto parsed = create_binary_provider_from_configs_pure("nugetconfig", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nugetconfig,relative-path", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nugetconfig,http://example.org/", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nugetconfig," ABSOLUTE_PATH, {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nugetconfig," ABSOLUTE_PATH ",nonsense", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nugetconfig," ABSOLUTE_PATH ",read", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nugetconfig," ABSOLUTE_PATH ",write", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nugetconfig," ABSOLUTE_PATH ",readwrite", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nugetconfig," ABSOLUTE_PATH ",readwrite,extra", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("nugetconfig,,readwrite", {});
- REQUIRE(!parsed.has_value());
- }
-}
-
-TEST_CASE ("BinaryConfigParser default provider", "[binaryconfigparser]")
-{
- {
- auto parsed = create_binary_provider_from_configs_pure("default", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("default,nonsense", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("default,read", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("default,readwrite", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("default,write", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("default,read,extra", {});
- REQUIRE(!parsed.has_value());
- }
-}
-
-TEST_CASE ("BinaryConfigParser clear provider", "[binaryconfigparser]")
-{
- {
- auto parsed = create_binary_provider_from_configs_pure("clear", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("clear,upload", {});
- REQUIRE(!parsed.has_value());
- }
-}
-
-TEST_CASE ("BinaryConfigParser interactive provider", "[binaryconfigparser]")
-{
- {
- auto parsed = create_binary_provider_from_configs_pure("interactive", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("interactive,read", {});
- REQUIRE(!parsed.has_value());
- }
-}
-
-TEST_CASE ("BinaryConfigParser multiple providers", "[binaryconfigparser]")
-{
- {
- auto parsed = create_binary_provider_from_configs_pure("clear;default", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("clear;default,read", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("clear;default,write", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("clear;default,readwrite", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("clear;default,readwrite;clear;clear", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("clear;files,relative;default", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure(";;;clear;;;;", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure(";;;,;;;;", {});
- REQUIRE(!parsed.has_value());
- }
-}
-
-TEST_CASE ("BinaryConfigParser escaping", "[binaryconfigparser]")
-{
- {
- auto parsed = create_binary_provider_from_configs_pure(";;;;;;;`", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure(";;;;;;;`defaul`t", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH "`", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH "`,", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH "``", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH "```", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH "````", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH ",", {});
- REQUIRE(!parsed.has_value());
- }
-}
-
-TEST_CASE ("BinaryConfigParser args", "[binaryconfigparser]")
-{
- {
- auto parsed =
- create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH, std::vector<std::string>{"clear"});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed =
- create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH, std::vector<std::string>{"clear;default"});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH,
- std::vector<std::string>{"clear;default,"});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH,
- std::vector<std::string>{"clear", "clear;default,"});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("files," ABSOLUTE_PATH,
- std::vector<std::string>{"clear", "clear"});
- REQUIRE(parsed.has_value());
- }
-}
-
-TEST_CASE ("BinaryConfigParser azblob provider", "[binaryconfigparser]")
-{
- {
- auto parsed = create_binary_provider_from_configs_pure("x-azblob,https://azure/container,sas", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("x-azblob,https://azure/container,?sas", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("x-azblob,,sas", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("x-azblob,https://azure/container", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("x-azblob,https://azure/container,sas,invalid", {});
- REQUIRE(!parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("x-azblob,https://azure/container,sas,read", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("x-azblob,https://azure/container,sas,write", {});
- REQUIRE(parsed.has_value());
- }
- {
- auto parsed = create_binary_provider_from_configs_pure("x-azblob,https://azure/container,sas,readwrite", {});
- REQUIRE(parsed.has_value());
- }
-}
diff --git a/toolsrc/src/vcpkg-test/catch.cpp b/toolsrc/src/vcpkg-test/catch.cpp
deleted file mode 100644
index fb62c5d06..000000000
--- a/toolsrc/src/vcpkg-test/catch.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-#define CATCH_CONFIG_RUNNER
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/system.debug.h>
-#include <vcpkg/base/system.h>
-
-int main(int argc, char** argv)
-{
- if (vcpkg::System::get_environment_variable("VCPKG_DEBUG").value_or("") == "1") vcpkg::Debug::g_debugging = true;
-
- return Catch::Session().run(argc, argv);
-}
diff --git a/toolsrc/src/vcpkg-test/chrono.cpp b/toolsrc/src/vcpkg-test/chrono.cpp
deleted file mode 100644
index fb8a0dee9..000000000
--- a/toolsrc/src/vcpkg-test/chrono.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/chrono.h>
-
-namespace Chrono = vcpkg::Chrono;
-
-TEST_CASE ("parse time", "[chrono]")
-{
- auto timestring = "1990-02-03T04:05:06.0Z";
- auto maybe_time = Chrono::CTime::parse(timestring);
-
- REQUIRE(maybe_time.has_value());
- REQUIRE(maybe_time.get()->to_string() == timestring);
-}
-
-TEST_CASE ("parse blank time", "[chrono]")
-{
- auto maybe_time = Chrono::CTime::parse("");
-
- REQUIRE_FALSE(maybe_time.has_value());
-}
-
-TEST_CASE ("difference of times", "[chrono]")
-{
- auto maybe_time1 = Chrono::CTime::parse("1990-02-03T04:05:06.0Z");
- auto maybe_time2 = Chrono::CTime::parse("1990-02-10T04:05:06.0Z");
-
- REQUIRE(maybe_time1.has_value());
- REQUIRE(maybe_time2.has_value());
-
- auto delta = maybe_time2.get()->to_time_point() - maybe_time1.get()->to_time_point();
-
- REQUIRE(std::chrono::duration_cast<std::chrono::hours>(delta).count() == 24 * 7);
-}
diff --git a/toolsrc/src/vcpkg-test/commands.cpp b/toolsrc/src/vcpkg-test/commands.cpp
deleted file mode 100644
index 1a582beb3..000000000
--- a/toolsrc/src/vcpkg-test/commands.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/commands.contact.h>
-#include <vcpkg/commands.h>
-#include <vcpkg/commands.upload-metrics.h>
-#include <vcpkg/commands.version.h>
-
-#include <stddef.h>
-
-using namespace vcpkg;
-
-namespace
-{
- template<class CommandListT, size_t ExpectedCount>
- void check_all_commands(const CommandListT& actual_commands, const char* const (&expected_commands)[ExpectedCount])
- {
- CHECK(actual_commands.size() == ExpectedCount); // makes sure this test is updated if we add a command
- for (const char* expected_command : expected_commands)
- {
- CHECK(Commands::find(StringView{expected_command, strlen(expected_command)}, actual_commands) != nullptr);
- }
-
- CHECK(Commands::find("x-never-will-exist", actual_commands) == nullptr);
- }
-} // unnamed namespace
-
-// clang-format tries to wrap the following lists inappropriately
-
-// clang-format off
-TEST_CASE ("get_available_basic_commands works", "[commands]")
-{
- check_all_commands(Commands::get_available_basic_commands(), {
- "contact",
- "version",
-#if defined(_WIN32)
- "x-upload-metrics",
-#endif // defined(_WIN32)
- });
-}
-
-TEST_CASE ("get_available_paths_commands works", "[commands]")
-{
- check_all_commands(Commands::get_available_paths_commands(), {
- "/?",
- "help",
- "search",
- "list",
- "integrate",
- "owns",
- "update",
- "edit",
- "create",
- "cache",
- "portsdiff",
- "autocomplete",
- "hash",
- "fetch",
- "format-manifest",
- "x-ci-clean",
- "x-history",
- "x-package-info",
- "x-vsinstances",
- "x-ci-verify-versions",
- "x-add-version",
- });
-}
-
-TEST_CASE ("get_available_commands_type_a works", "[commands]")
-{
- check_all_commands(Commands::get_available_triplet_commands(), {
- "install",
- "x-set-installed",
- "ci",
- "remove",
- "upgrade",
- "build",
- "env",
- "build-external",
- "export",
- "depend-info",
- });
-}
-// clang-format on
diff --git a/toolsrc/src/vcpkg-test/dependencies.cpp b/toolsrc/src/vcpkg-test/dependencies.cpp
deleted file mode 100644
index c6241ebe0..000000000
--- a/toolsrc/src/vcpkg-test/dependencies.cpp
+++ /dev/null
@@ -1,1713 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/graphs.h>
-
-#include <vcpkg/dependencies.h>
-#include <vcpkg/portfileprovider.h>
-#include <vcpkg/sourceparagraph.h>
-#include <vcpkg/triplet.h>
-
-#include <memory>
-#include <unordered_map>
-#include <vector>
-
-#include <vcpkg-test/mockcmakevarprovider.h>
-#include <vcpkg-test/util.h>
-
-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;
-
-struct MockBaselineProvider : PortFileProvider::IBaselineProvider
-{
- mutable std::map<std::string, Versions::Version, std::less<>> v;
-
- Optional<Versions::Version> get_baseline_version(StringView name) const override
- {
- auto it = v.find(name);
- if (it == v.end()) return nullopt;
- return it->second;
- }
-};
-
-struct MockVersionedPortfileProvider : PortFileProvider::IVersionedPortfileProvider
-{
- mutable std::map<std::string, std::map<Versions::Version, SourceControlFileLocation, VersionTMapLess>> v;
-
- ExpectedS<const SourceControlFileLocation&> get_control_file(
- const vcpkg::Versions::VersionSpec& versionspec) const override
- {
- return get_control_file(versionspec.port_name, versionspec.version);
- }
-
- ExpectedS<const SourceControlFileLocation&> get_control_file(const std::string& name,
- const vcpkg::Versions::Version& version) const
- {
- auto it = v.find(name);
- if (it == v.end()) return std::string("Unknown port name");
- auto it2 = it->second.find(version);
- if (it2 == it->second.end()) return std::string("Unknown port version");
- return it2->second;
- }
-
- virtual View<vcpkg::VersionT> get_port_versions(StringView) const override { Checks::unreachable(VCPKG_LINE_INFO); }
-
- SourceControlFileLocation& emplace(std::string&& name,
- Versions::Version&& version,
- Versions::Scheme scheme = Versions::Scheme::String)
- {
- auto it = v.find(name);
- if (it == v.end())
- it = v.emplace(name, std::map<Versions::Version, SourceControlFileLocation, VersionTMapLess>{}).first;
-
- auto it2 = it->second.find(version);
- if (it2 == it->second.end())
- {
- auto scf = std::make_unique<SourceControlFile>();
- auto core = std::make_unique<SourceParagraph>();
- core->name = name;
- core->version = version.text();
- core->port_version = version.port_version();
- core->version_scheme = scheme;
- scf->core_paragraph = std::move(core);
- it2 = it->second.emplace(version, SourceControlFileLocation{std::move(scf), fs::u8path(name)}).first;
- }
- return it2->second;
- }
-
- virtual void load_all_control_files(std::map<std::string, const SourceControlFileLocation*>&) const override
- {
- Checks::unreachable(VCPKG_LINE_INFO);
- }
-};
-
-using Versions::Constraint;
-using Versions::Scheme;
-
-template<class T>
-T unwrap(ExpectedS<T> e)
-{
- if (!e.has_value())
- {
- INFO(e.error());
- REQUIRE(false);
- }
- return std::move(*e.get());
-}
-
-static void check_name_and_version(const Dependencies::InstallPlanAction& ipa,
- StringLiteral name,
- Versions::Version v,
- std::initializer_list<StringLiteral> features = {})
-{
- CHECK(ipa.spec.name() == name);
- CHECK(ipa.source_control_file_location.has_value());
- CHECK(ipa.feature_list.size() == features.size() + 1);
- {
- INFO("ipa.feature_list = [" << Strings::join(", ", ipa.feature_list) << "]");
- for (auto&& f : features)
- {
- INFO("f = \"" << f.c_str() << "\"");
- CHECK(Util::find(ipa.feature_list, f) != ipa.feature_list.end());
- }
- CHECK(Util::find(ipa.feature_list, "core") != ipa.feature_list.end());
- }
- if (auto scfl = ipa.source_control_file_location.get())
- {
- CHECK(scfl->source_control_file->core_paragraph->version == v.text());
- CHECK(scfl->source_control_file->core_paragraph->port_version == v.port_version());
- }
-}
-
-static void check_semver_version(const ExpectedS<Versions::SemanticVersion>& maybe_version,
- const std::string& version_string,
- const std::string& prerelease_string,
- uint64_t major,
- uint64_t minor,
- uint64_t patch,
- const std::vector<std::string>& identifiers)
-{
- auto actual_version = unwrap(maybe_version);
- CHECK(actual_version.version_string == version_string);
- CHECK(actual_version.prerelease_string == prerelease_string);
- REQUIRE(actual_version.version.size() == 3);
- CHECK(actual_version.version[0] == major);
- CHECK(actual_version.version[1] == minor);
- CHECK(actual_version.version[2] == patch);
- CHECK(actual_version.identifiers == identifiers);
-}
-
-static void check_relaxed_version(const ExpectedS<Versions::RelaxedVersion>& maybe_version,
- const std::vector<uint64_t>& version)
-{
- auto actual_version = unwrap(maybe_version);
- CHECK(actual_version.version == version);
-}
-
-static void check_date_version(const ExpectedS<Versions::DateVersion>& maybe_version,
- const std::string& version_string,
- const std::string& identifiers_string,
- const std::vector<uint64_t>& identifiers)
-{
- auto actual_version = unwrap(maybe_version);
- CHECK(actual_version.version_string == version_string);
- CHECK(actual_version.identifiers_string == identifiers_string);
- CHECK(actual_version.identifiers == identifiers);
-}
-
-static const PackageSpec& toplevel_spec()
-{
- static const PackageSpec ret("toplevel-spec", Test::X86_WINDOWS);
- return ret;
-}
-
-struct MockOverlayProvider : PortFileProvider::IOverlayProvider, Util::ResourceBase
-{
- virtual Optional<const SourceControlFileLocation&> get_control_file(StringView name) const override
- {
- auto it = mappings.find(name);
- if (it != mappings.end())
- return it->second;
- else
- return nullopt;
- }
-
- SourceControlFileLocation& emplace(const std::string& name,
- Versions::Version&& version,
- Versions::Scheme scheme = Versions::Scheme::String)
- {
- auto it = mappings.find(name);
- if (it == mappings.end())
- {
- auto scf = std::make_unique<SourceControlFile>();
- auto core = std::make_unique<SourceParagraph>();
- core->name = name;
- core->version = version.text();
- core->port_version = version.port_version();
- core->version_scheme = scheme;
- scf->core_paragraph = std::move(core);
- it = mappings.emplace(name, SourceControlFileLocation{std::move(scf), fs::u8path(name)}).first;
- }
- return it->second;
- }
-
- virtual void load_all_control_files(std::map<std::string, const SourceControlFileLocation*>&) const override
- {
- Checks::unreachable(VCPKG_LINE_INFO);
- }
-
-private:
- std::map<std::string, SourceControlFileLocation, std::less<>> mappings;
-};
-
-static const MockOverlayProvider s_empty_mock_overlay;
-
-static ExpectedS<Dependencies::ActionPlan> create_versioned_install_plan(
- const PortFileProvider::IVersionedPortfileProvider& provider,
- const PortFileProvider::IBaselineProvider& bprovider,
- const CMakeVars::CMakeVarProvider& var_provider,
- const std::vector<Dependency>& deps,
- const std::vector<DependencyOverride>& overrides,
- const PackageSpec& toplevel)
-{
- return Dependencies::create_versioned_install_plan(
- provider, bprovider, s_empty_mock_overlay, var_provider, deps, overrides, toplevel);
-}
-
-TEST_CASE ("basic version install single", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"1", 0});
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan = unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- REQUIRE(install_plan.install_actions.at(0).spec.name() == "a");
-}
-
-TEST_CASE ("basic version install detect cycle", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
- bp.v["b"] = {"1", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"1", 0}).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{}},
- };
- vp.emplace("b", {"1", 0}).source_control_file->core_paragraph->dependencies = {
- Dependency{"a", {}, {}, DependencyConstraint{}},
- };
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec());
-
- REQUIRE(!install_plan.has_value());
-}
-
-TEST_CASE ("basic version install scheme", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
- bp.v["b"] = {"1", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"1", 0}).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{}},
- };
- vp.emplace("b", {"1", 0});
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan = unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec()));
-
- CHECK(install_plan.size() == 2);
-
- StringLiteral names[] = {"b", "a"};
- for (size_t i = 0; i < install_plan.install_actions.size() && i < 2; ++i)
- {
- CHECK(install_plan.install_actions[i].spec.name() == names[i]);
- }
-}
-
-TEST_CASE ("basic version install scheme diamond", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
- bp.v["b"] = {"1", 0};
- bp.v["c"] = {"1", 0};
- bp.v["d"] = {"1", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"1", 0}).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{}},
- Dependency{"c", {}, {}, DependencyConstraint{}},
- };
- vp.emplace("b", {"1", 0}).source_control_file->core_paragraph->dependencies = {
- Dependency{"c", {}, {}, DependencyConstraint{}},
- Dependency{"d", {}, {}, DependencyConstraint{}},
- };
- vp.emplace("c", {"1", 0}).source_control_file->core_paragraph->dependencies = {
- Dependency{"d", {}, {}, DependencyConstraint{}},
- };
- vp.emplace("d", {"1", 0});
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan = unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec()));
-
- CHECK(install_plan.size() == 4);
-
- StringLiteral names[] = {"d", "c", "b", "a"};
- for (size_t i = 0; i < install_plan.install_actions.size() && i < 4; ++i)
- {
- CHECK(install_plan.install_actions[i].spec.name() == names[i]);
- }
-}
-
-TEST_CASE ("basic version install scheme baseline missing", "[versionplan]")
-{
- MockBaselineProvider bp;
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"1", 0});
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec());
-
- REQUIRE(!install_plan.has_value());
-}
-
-TEST_CASE ("basic version install scheme baseline missing success", "[versionplan]")
-{
- MockBaselineProvider bp;
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"1", 0});
- vp.emplace("a", {"2", 0});
- vp.emplace("a", {"3", 0});
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "2"}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"2", 0});
-}
-
-TEST_CASE ("basic version install scheme baseline", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"1", 0});
- vp.emplace("a", {"2", 0});
- vp.emplace("a", {"3", 0});
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan = unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"2", 0});
-}
-
-TEST_CASE ("version string baseline agree", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"1", 0});
- vp.emplace("a", {"2", 0});
- vp.emplace("a", {"3", 0});
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan = create_versioned_install_plan(
- vp, bp, var_provider, {Dependency{"a", {}, {}, {Constraint::Type::Minimum, "2"}}}, {}, toplevel_spec());
-
- REQUIRE(install_plan.has_value());
-}
-
-TEST_CASE ("version install scheme baseline conflict", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"1", 0});
- vp.emplace("a", {"2", 0});
- vp.emplace("a", {"3", 0});
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan = create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "3"}},
- },
- {},
- toplevel_spec());
-
- REQUIRE(!install_plan.has_value());
-}
-
-TEST_CASE ("version install string port version", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2", 0});
- vp.emplace("a", {"2", 1});
- vp.emplace("a", {"2", 2});
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "2", 1}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"2", 1});
-}
-
-TEST_CASE ("version install string port version 2", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2", 1};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2", 0});
- vp.emplace("a", {"2", 1});
- vp.emplace("a", {"2", 2});
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "2", 0}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"2", 1});
-}
-
-TEST_CASE ("version install transitive string", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2", 0}).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "1"}},
- };
- vp.emplace("a", {"2", 1}).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "2"}},
- };
- vp.emplace("b", {"1", 0});
- vp.emplace("b", {"2", 0});
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "2", 1}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "b", {"2", 0});
- check_name_and_version(install_plan.install_actions[1], "a", {"2", 1});
-}
-
-TEST_CASE ("version install simple relaxed", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2", 0}, Scheme::Relaxed);
- vp.emplace("a", {"3", 0}, Scheme::Relaxed);
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "3", 0}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"3", 0});
-}
-
-TEST_CASE ("version install transitive relaxed", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2", 0};
- bp.v["b"] = {"2", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2", 0}, Scheme::Relaxed);
- vp.emplace("a", {"3", 0}, Scheme::Relaxed).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "3"}},
- };
- vp.emplace("b", {"2", 0}, Scheme::Relaxed);
- vp.emplace("b", {"3", 0}, Scheme::Relaxed);
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "3", 0}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "b", {"3", 0});
- check_name_and_version(install_plan.install_actions[1], "a", {"3", 0});
-}
-
-TEST_CASE ("version install diamond relaxed", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2", 0};
- bp.v["b"] = {"3", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2", 0}, Scheme::Relaxed);
- vp.emplace("a", {"3", 0}, Scheme::Relaxed).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "2", 1}},
- Dependency{"c", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "5", 1}},
- };
- vp.emplace("b", {"2", 1}, Scheme::Relaxed);
- vp.emplace("b", {"3", 0}, Scheme::Relaxed).source_control_file->core_paragraph->dependencies = {
- Dependency{"c", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "9", 2}},
- };
- vp.emplace("c", {"5", 1}, Scheme::Relaxed);
- vp.emplace("c", {"9", 2}, Scheme::Relaxed);
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "3", 0}},
- Dependency{"b", {}, {}, {Constraint::Type::Minimum, "2", 1}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 3);
- check_name_and_version(install_plan.install_actions[0], "c", {"9", 2});
- check_name_and_version(install_plan.install_actions[1], "b", {"3", 0});
- check_name_and_version(install_plan.install_actions[2], "a", {"3", 0});
-}
-
-TEST_CASE ("version parse semver", "[versionplan]")
-{
- auto version_basic = Versions::SemanticVersion::from_string("1.2.3");
- check_semver_version(version_basic, "1.2.3", "", 1, 2, 3, {});
-
- auto version_simple_tag = Versions::SemanticVersion::from_string("1.0.0-alpha");
- check_semver_version(version_simple_tag, "1.0.0", "alpha", 1, 0, 0, {"alpha"});
-
- auto version_alphanumeric_tag = Versions::SemanticVersion::from_string("1.0.0-0alpha0");
- check_semver_version(version_alphanumeric_tag, "1.0.0", "0alpha0", 1, 0, 0, {"0alpha0"});
-
- auto version_complex_tag = Versions::SemanticVersion::from_string("1.0.0-alpha.1.0.0");
- check_semver_version(version_complex_tag, "1.0.0", "alpha.1.0.0", 1, 0, 0, {"alpha", "1", "0", "0"});
-
- auto version_complexer_tag = Versions::SemanticVersion::from_string("1.0.0-alpha.1.x.y.z.0-alpha.0-beta.l-a-s-t");
- check_semver_version(version_complexer_tag,
- "1.0.0",
- "alpha.1.x.y.z.0-alpha.0-beta.l-a-s-t",
- 1,
- 0,
- 0,
- {"alpha", "1", "x", "y", "z", "0-alpha", "0-beta", "l-a-s-t"});
-
- auto version_ridiculous_tag = Versions::SemanticVersion::from_string("1.0.0----------------------------------");
- check_semver_version(version_ridiculous_tag,
- "1.0.0",
- "---------------------------------",
- 1,
- 0,
- 0,
- {"---------------------------------"});
-
- auto version_build_tag = Versions::SemanticVersion::from_string("1.0.0+build");
- check_semver_version(version_build_tag, "1.0.0", "", 1, 0, 0, {});
-
- auto version_prerelease_build_tag = Versions::SemanticVersion::from_string("1.0.0-alpha+build");
- check_semver_version(version_prerelease_build_tag, "1.0.0", "alpha", 1, 0, 0, {"alpha"});
-
- auto version_invalid_incomplete = Versions::SemanticVersion::from_string("1.0-alpha");
- CHECK(!version_invalid_incomplete.has_value());
-
- auto version_invalid_leading_zeroes = Versions::SemanticVersion::from_string("1.02.03-alpha+build");
- CHECK(!version_invalid_leading_zeroes.has_value());
-
- auto version_invalid_leading_zeroes_in_tag = Versions::SemanticVersion::from_string("1.0.0-01");
- CHECK(!version_invalid_leading_zeroes_in_tag.has_value());
-
- auto version_invalid_characters = Versions::SemanticVersion::from_string("1.0.0-alpha#2");
- CHECK(!version_invalid_characters.has_value());
-}
-
-TEST_CASE ("version parse relaxed", "[versionplan]")
-{
- auto version_basic = Versions::RelaxedVersion::from_string("1.2.3");
- check_relaxed_version(version_basic, {1, 2, 3});
-
- auto version_short = Versions::RelaxedVersion::from_string("1");
- check_relaxed_version(version_short, {1});
-
- auto version_long =
- Versions::RelaxedVersion::from_string("1.20.300.4000.50000.6000000.70000000.80000000.18446744073709551610");
- check_relaxed_version(version_long, {1, 20, 300, 4000, 50000, 6000000, 70000000, 80000000, 18446744073709551610u});
-
- auto version_invalid_characters = Versions::RelaxedVersion::from_string("1.a.0");
- CHECK(!version_invalid_characters.has_value());
-
- auto version_invalid_identifiers_2 = Versions::RelaxedVersion::from_string("1.1a.2");
- CHECK(!version_invalid_identifiers_2.has_value());
-
- auto version_invalid_leading_zeroes = Versions::RelaxedVersion::from_string("01.002.003");
- CHECK(!version_invalid_leading_zeroes.has_value());
-}
-
-TEST_CASE ("version parse date", "[versionplan]")
-{
- auto version_basic = Versions::DateVersion::from_string("2020-12-25");
- check_date_version(version_basic, "2020-12-25", "", {});
-
- auto version_identifiers = Versions::DateVersion::from_string("2020-12-25.1.2.3");
- check_date_version(version_identifiers, "2020-12-25", "1.2.3", {1, 2, 3});
-
- auto version_invalid_date = Versions::DateVersion::from_string("2020-1-1");
- CHECK(!version_invalid_date.has_value());
-
- auto version_invalid_identifiers = Versions::DateVersion::from_string("2020-01-01.alpha");
- CHECK(!version_invalid_identifiers.has_value());
-
- auto version_invalid_identifiers_2 = Versions::DateVersion::from_string("2020-01-01.2a");
- CHECK(!version_invalid_identifiers_2.has_value());
-
- auto version_invalid_leading_zeroes = Versions::DateVersion::from_string("2020-01-01.01");
- CHECK(!version_invalid_leading_zeroes.has_value());
-}
-
-TEST_CASE ("version sort semver", "[versionplan]")
-{
- std::vector<Versions::SemanticVersion> versions{unwrap(Versions::SemanticVersion::from_string("1.0.0")),
- unwrap(Versions::SemanticVersion::from_string("0.0.0")),
- unwrap(Versions::SemanticVersion::from_string("1.1.0")),
- unwrap(Versions::SemanticVersion::from_string("2.0.0")),
- unwrap(Versions::SemanticVersion::from_string("1.1.1")),
- unwrap(Versions::SemanticVersion::from_string("1.0.1")),
- unwrap(Versions::SemanticVersion::from_string("1.0.0-alpha.1")),
- unwrap(Versions::SemanticVersion::from_string("1.0.0-beta")),
- unwrap(Versions::SemanticVersion::from_string("1.0.0-alpha")),
- unwrap(Versions::SemanticVersion::from_string("1.0.0-alpha.beta")),
- unwrap(Versions::SemanticVersion::from_string("1.0.0-rc")),
- unwrap(Versions::SemanticVersion::from_string("1.0.0-beta.2")),
- unwrap(Versions::SemanticVersion::from_string("1.0.0-beta.20")),
- unwrap(Versions::SemanticVersion::from_string("1.0.0-beta.3")),
- unwrap(Versions::SemanticVersion::from_string("1.0.0-1")),
- unwrap(Versions::SemanticVersion::from_string("1.0.0-0alpha"))};
-
- std::sort(std::begin(versions), std::end(versions), [](const auto& lhs, const auto& rhs) -> bool {
- return Versions::compare(lhs, rhs) == Versions::VerComp::lt;
- });
-
- CHECK(versions[0].original_string == "0.0.0");
- CHECK(versions[1].original_string == "1.0.0-1");
- CHECK(versions[2].original_string == "1.0.0-0alpha");
- CHECK(versions[3].original_string == "1.0.0-alpha");
- CHECK(versions[4].original_string == "1.0.0-alpha.1");
- CHECK(versions[5].original_string == "1.0.0-alpha.beta");
- CHECK(versions[6].original_string == "1.0.0-beta");
- CHECK(versions[7].original_string == "1.0.0-beta.2");
- CHECK(versions[8].original_string == "1.0.0-beta.3");
- CHECK(versions[9].original_string == "1.0.0-beta.20");
- CHECK(versions[10].original_string == "1.0.0-rc");
- CHECK(versions[11].original_string == "1.0.0");
- CHECK(versions[12].original_string == "1.0.1");
- CHECK(versions[13].original_string == "1.1.0");
- CHECK(versions[14].original_string == "1.1.1");
- CHECK(versions[15].original_string == "2.0.0");
-}
-
-TEST_CASE ("version sort relaxed", "[versionplan]")
-{
- std::vector<Versions::RelaxedVersion> versions{unwrap(Versions::RelaxedVersion::from_string("1.0.0")),
- unwrap(Versions::RelaxedVersion::from_string("1.0")),
- unwrap(Versions::RelaxedVersion::from_string("1")),
- unwrap(Versions::RelaxedVersion::from_string("2")),
- unwrap(Versions::RelaxedVersion::from_string("1.1")),
- unwrap(Versions::RelaxedVersion::from_string("1.10.1")),
- unwrap(Versions::RelaxedVersion::from_string("1.0.1")),
- unwrap(Versions::RelaxedVersion::from_string("1.0.0.1")),
- unwrap(Versions::RelaxedVersion::from_string("1.0.0.2"))};
-
- std::sort(std::begin(versions), std::end(versions), [](const auto& lhs, const auto& rhs) -> bool {
- return Versions::compare(lhs, rhs) == Versions::VerComp::lt;
- });
-
- CHECK(versions[0].original_string == "1");
- CHECK(versions[1].original_string == "1.0");
- CHECK(versions[2].original_string == "1.0.0");
- CHECK(versions[3].original_string == "1.0.0.1");
- CHECK(versions[4].original_string == "1.0.0.2");
- CHECK(versions[5].original_string == "1.0.1");
- CHECK(versions[6].original_string == "1.1");
- CHECK(versions[7].original_string == "1.10.1");
- CHECK(versions[8].original_string == "2");
-}
-
-TEST_CASE ("version sort date", "[versionplan]")
-{
- std::vector<Versions::DateVersion> versions{unwrap(Versions::DateVersion::from_string("2021-01-01.2")),
- unwrap(Versions::DateVersion::from_string("2021-01-01.1")),
- unwrap(Versions::DateVersion::from_string("2021-01-01.1.1")),
- unwrap(Versions::DateVersion::from_string("2021-01-01.1.0")),
- unwrap(Versions::DateVersion::from_string("2021-01-01")),
- unwrap(Versions::DateVersion::from_string("2021-01-01")),
- unwrap(Versions::DateVersion::from_string("2020-12-25")),
- unwrap(Versions::DateVersion::from_string("2020-12-31")),
- unwrap(Versions::DateVersion::from_string("2021-01-01.10"))};
-
- std::sort(std::begin(versions), std::end(versions), [](const auto& lhs, const auto& rhs) -> bool {
- return Versions::compare(lhs, rhs) == Versions::VerComp::lt;
- });
-
- CHECK(versions[0].original_string == "2020-12-25");
- CHECK(versions[1].original_string == "2020-12-31");
- CHECK(versions[2].original_string == "2021-01-01");
- CHECK(versions[3].original_string == "2021-01-01");
- CHECK(versions[4].original_string == "2021-01-01.1");
- CHECK(versions[5].original_string == "2021-01-01.1.0");
- CHECK(versions[6].original_string == "2021-01-01.1.1");
- CHECK(versions[7].original_string == "2021-01-01.2");
- CHECK(versions[8].original_string == "2021-01-01.10");
-}
-
-TEST_CASE ("version install simple semver", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2.0.0", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2.0.0", 0}, Scheme::Semver);
- vp.emplace("a", {"3.0.0", 0}, Scheme::Semver);
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "3.0.0", 0}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"3.0.0", 0});
-}
-
-TEST_CASE ("version install transitive semver", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2.0.0", 0};
- bp.v["b"] = {"2.0.0", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2.0.0", 0}, Scheme::Semver);
- vp.emplace("a", {"3.0.0", 0}, Scheme::Semver).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "3.0.0"}},
- };
- vp.emplace("b", {"2.0.0", 0}, Scheme::Semver);
- vp.emplace("b", {"3.0.0", 0}, Scheme::Semver);
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "3.0.0", 0}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "b", {"3.0.0", 0});
- check_name_and_version(install_plan.install_actions[1], "a", {"3.0.0", 0});
-}
-
-TEST_CASE ("version install diamond semver", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2.0.0", 0};
- bp.v["b"] = {"3.0.0", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2.0.0", 0}, Scheme::Semver);
- vp.emplace("a", {"3.0.0", 0}, Scheme::Semver).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "2.0.0", 1}},
- Dependency{"c", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "5.0.0", 1}},
- };
- vp.emplace("b", {"2.0.0", 1}, Scheme::Semver);
- vp.emplace("b", {"3.0.0", 0}, Scheme::Semver).source_control_file->core_paragraph->dependencies = {
- Dependency{"c", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "9.0.0", 2}},
- };
- vp.emplace("c", {"5.0.0", 1}, Scheme::Semver);
- vp.emplace("c", {"9.0.0", 2}, Scheme::Semver);
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "3.0.0", 0}},
- Dependency{"b", {}, {}, {Constraint::Type::Minimum, "2.0.0", 1}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 3);
- check_name_and_version(install_plan.install_actions[0], "c", {"9.0.0", 2});
- check_name_and_version(install_plan.install_actions[1], "b", {"3.0.0", 0});
- check_name_and_version(install_plan.install_actions[2], "a", {"3.0.0", 0});
-}
-
-TEST_CASE ("version install simple date", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2020-02-01", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2020-02-01", 0}, Scheme::Date);
- vp.emplace("a", {"2020-03-01", 0}, Scheme::Date);
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "2020-03-01", 0}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"2020-03-01", 0});
-}
-
-TEST_CASE ("version install transitive date", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2020-01-01.2", 0};
- bp.v["b"] = {"2020-01-01.3", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2020-01-01.2", 0}, Scheme::Date);
- vp.emplace("a", {"2020-01-01.3", 0}, Scheme::Date).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "2020-01-01.3"}},
- };
- vp.emplace("b", {"2020-01-01.2", 0}, Scheme::Date);
- vp.emplace("b", {"2020-01-01.3", 0}, Scheme::Date);
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan = unwrap(
- create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "2020-01-01.3", 0}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "b", {"2020-01-01.3", 0});
- check_name_and_version(install_plan.install_actions[1], "a", {"2020-01-01.3", 0});
-}
-
-TEST_CASE ("version install diamond date", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"2020-01-02", 0};
- bp.v["b"] = {"2020-01-03", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2020-01-02", 0}, Scheme::Date);
- vp.emplace("a", {"2020-01-03", 0}, Scheme::Date).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "2020-01-02", 1}},
- Dependency{"c", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "2020-01-05", 1}},
- };
- vp.emplace("b", {"2020-01-02", 1}, Scheme::Date);
- vp.emplace("b", {"2020-01-03", 0}, Scheme::Date).source_control_file->core_paragraph->dependencies = {
- Dependency{"c", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "2020-01-09", 2}},
- };
- vp.emplace("c", {"2020-01-05", 1}, Scheme::Date);
- vp.emplace("c", {"2020-01-09", 2}, Scheme::Date);
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "2020-01-03", 0}},
- Dependency{"b", {}, {}, {Constraint::Type::Minimum, "2020-01-02", 1}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 3);
- check_name_and_version(install_plan.install_actions[0], "c", {"2020-01-09", 2});
- check_name_and_version(install_plan.install_actions[1], "b", {"2020-01-03", 0});
- check_name_and_version(install_plan.install_actions[2], "a", {"2020-01-03", 0});
-}
-
-TEST_CASE ("version install scheme failure", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"1.0.0", 0}, Scheme::Semver);
- vp.emplace("a", {"1.0.1", 0}, Scheme::Relaxed);
- vp.emplace("a", {"1.0.2", 0}, Scheme::Semver);
-
- MockCMakeVarProvider var_provider;
-
- SECTION ("lower baseline")
- {
- MockBaselineProvider bp;
- bp.v["a"] = {"1.0.0", 0};
-
- auto install_plan =
- create_versioned_install_plan(vp,
- bp,
- var_provider,
- {Dependency{"a", {}, {}, {Constraint::Type::Minimum, "1.0.1", 0}}},
- {},
- toplevel_spec());
-
- REQUIRE(!install_plan.error().empty());
- CHECK(install_plan.error() == "Version conflict on a@1.0.1: baseline required 1.0.0");
- }
- SECTION ("higher baseline")
- {
- MockBaselineProvider bp;
- bp.v["a"] = {"1.0.2", 0};
-
- auto install_plan =
- create_versioned_install_plan(vp,
- bp,
- var_provider,
- {Dependency{"a", {}, {}, {Constraint::Type::Minimum, "1.0.1", 0}}},
- {},
- toplevel_spec());
-
- REQUIRE(!install_plan.error().empty());
- CHECK(install_plan.error() == "Version conflict on a@1.0.1: baseline required 1.0.2");
- }
-}
-
-TEST_CASE ("version install scheme change in port version", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"2", 0}).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "1"}},
- };
- vp.emplace("a", {"2", 1}).source_control_file->core_paragraph->dependencies = {
- Dependency{"b", {}, {}, DependencyConstraint{Constraint::Type::Minimum, "1", 1}},
- };
- vp.emplace("b", {"1", 0}, Scheme::String);
- vp.emplace("b", {"1", 1}, Scheme::Relaxed);
-
- MockCMakeVarProvider var_provider;
-
- SECTION ("lower baseline")
- {
- MockBaselineProvider bp;
- bp.v["a"] = {"2", 0};
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "2", 1}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "b", {"1", 1});
- check_name_and_version(install_plan.install_actions[1], "a", {"2", 1});
- }
- SECTION ("higher baseline")
- {
- MockBaselineProvider bp;
- bp.v["a"] = {"2", 1};
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "2", 0}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "b", {"1", 1});
- check_name_and_version(install_plan.install_actions[1], "a", {"2", 1});
- }
-}
-
-TEST_CASE ("version install simple feature", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
- auto a_x = std::make_unique<FeatureParagraph>();
- a_x->name = "x";
- vp.emplace("a", {"1", 0}, Scheme::Relaxed).source_control_file->feature_paragraphs.push_back(std::move(a_x));
-
- MockCMakeVarProvider var_provider;
-
- SECTION ("with baseline")
- {
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
-
- auto install_plan = unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {"x"}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x"});
- }
-
- SECTION ("without baseline")
- {
- MockBaselineProvider bp;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {"x"}, {}, {Constraint::Type::Minimum, "1", 0}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x"});
- }
-}
-
-static std::unique_ptr<FeatureParagraph> make_fpgh(std::string name)
-{
- auto f = std::make_unique<FeatureParagraph>();
- f->name = std::move(name);
- return f;
-}
-
-TEST_CASE ("version install transitive features", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
-
- auto a_x = make_fpgh("x");
- a_x->dependencies.push_back(Dependency{"b", {"y"}});
- vp.emplace("a", {"1", 0}, Scheme::Relaxed).source_control_file->feature_paragraphs.push_back(std::move(a_x));
-
- auto b_y = make_fpgh("y");
- vp.emplace("b", {"1", 0}, Scheme::Relaxed).source_control_file->feature_paragraphs.push_back(std::move(b_y));
-
- MockCMakeVarProvider var_provider;
-
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
- bp.v["b"] = {"1", 0};
-
- auto install_plan = unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {"x"}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "b", {"1", 0}, {"y"});
- check_name_and_version(install_plan.install_actions[1], "a", {"1", 0}, {"x"});
-}
-
-TEST_CASE ("version install transitive feature versioned", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
-
- auto a_x = make_fpgh("x");
- a_x->dependencies.push_back(Dependency{"b", {"y"}, {}, {Constraint::Type::Minimum, "2", 0}});
- vp.emplace("a", {"1", 0}, Scheme::Relaxed).source_control_file->feature_paragraphs.push_back(std::move(a_x));
-
- {
- auto b_y = make_fpgh("y");
- vp.emplace("b", {"1", 0}, Scheme::Relaxed).source_control_file->feature_paragraphs.push_back(std::move(b_y));
- }
- {
- auto b_y = make_fpgh("y");
- b_y->dependencies.push_back(Dependency{"c"});
- vp.emplace("b", {"2", 0}, Scheme::Relaxed).source_control_file->feature_paragraphs.push_back(std::move(b_y));
- }
-
- vp.emplace("c", {"1", 0}, Scheme::Relaxed);
-
- MockCMakeVarProvider var_provider;
-
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
- bp.v["c"] = {"1", 0};
-
- auto install_plan = unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"a", {"x"}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 3);
- check_name_and_version(install_plan.install_actions[0], "c", {"1", 0});
- check_name_and_version(install_plan.install_actions[1], "b", {"2", 0}, {"y"});
- check_name_and_version(install_plan.install_actions[2], "a", {"1", 0}, {"x"});
-}
-
-TEST_CASE ("version install constraint-reduction", "[versionplan]")
-{
- MockCMakeVarProvider var_provider;
-
- SECTION ("higher baseline")
- {
- MockVersionedPortfileProvider vp;
-
- vp.emplace("b", {"1", 0}, Scheme::Relaxed).source_control_file->core_paragraph->dependencies = {
- Dependency{"c", {}, {}, {Constraint::Type::Minimum, "2"}},
- };
- vp.emplace("b", {"2", 0}, Scheme::Relaxed).source_control_file->core_paragraph->dependencies = {
- Dependency{"c", {}, {}, {Constraint::Type::Minimum, "1"}},
- };
-
- vp.emplace("c", {"1", 0}, Scheme::Relaxed);
- // c@2 is used to detect if certain constraints were evaluated
- vp.emplace("c", {"2", 0}, Scheme::Relaxed);
-
- MockBaselineProvider bp;
- bp.v["b"] = {"2", 0};
- bp.v["c"] = {"1", 0};
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"b", {}, {}, {Constraint::Type::Minimum, "1"}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "c", {"1", 0});
- check_name_and_version(install_plan.install_actions[1], "b", {"2", 0});
- }
-
- SECTION ("higher toplevel")
- {
- MockVersionedPortfileProvider vp;
-
- vp.emplace("b", {"1", 0}, Scheme::Relaxed).source_control_file->core_paragraph->dependencies = {
- Dependency{"c", {}, {}, {Constraint::Type::Minimum, "2"}},
- };
- vp.emplace("b", {"2", 0}, Scheme::Relaxed).source_control_file->core_paragraph->dependencies = {
- Dependency{"c", {}, {}, {Constraint::Type::Minimum, "1"}},
- };
-
- vp.emplace("c", {"1", 0}, Scheme::Relaxed);
- // c@2 is used to detect if certain constraints were evaluated
- vp.emplace("c", {"2", 0}, Scheme::Relaxed);
-
- MockBaselineProvider bp;
- bp.v["b"] = {"1", 0};
- bp.v["c"] = {"1", 0};
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {
- Dependency{"b", {}, {}, {Constraint::Type::Minimum, "2"}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "c", {"1", 0});
- check_name_and_version(install_plan.install_actions[1], "b", {"2", 0});
- }
-}
-
-TEST_CASE ("version install overrides", "[versionplan]")
-{
- MockCMakeVarProvider var_provider;
-
- MockVersionedPortfileProvider vp;
-
- vp.emplace("b", {"1", 0}, Scheme::Relaxed);
- vp.emplace("b", {"2", 0}, Scheme::Relaxed);
- vp.emplace("c", {"1", 0}, Scheme::String);
- vp.emplace("c", {"2", 0}, Scheme::String);
-
- MockBaselineProvider bp;
- bp.v["b"] = {"2", 0};
- bp.v["c"] = {"2", 0};
-
- SECTION ("string")
- {
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {Dependency{"c"}},
- {DependencyOverride{"b", "1"}, DependencyOverride{"c", "1"}},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "c", {"1", 0});
- }
-
- SECTION ("relaxed")
- {
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {Dependency{"b"}},
- {DependencyOverride{"b", "1"}, DependencyOverride{"c", "1"}},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "b", {"1", 0});
- }
-}
-
-TEST_CASE ("version install transitive overrides", "[versionplan]")
-{
- MockCMakeVarProvider var_provider;
-
- MockVersionedPortfileProvider vp;
-
- vp.emplace("b", {"1", 0}, Scheme::Relaxed)
- .source_control_file->core_paragraph->dependencies.push_back(
- {"c", {}, {}, {Constraint::Type::Minimum, "2", 1}});
- vp.emplace("b", {"2", 0}, Scheme::Relaxed);
- vp.emplace("c", {"1", 0}, Scheme::String);
- vp.emplace("c", {"2", 1}, Scheme::String);
-
- MockBaselineProvider bp;
- bp.v["b"] = {"2", 0};
- bp.v["c"] = {"2", 1};
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp,
- bp,
- var_provider,
- {Dependency{"b"}},
- {DependencyOverride{"b", "1"}, DependencyOverride{"c", "1"}},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "c", {"1", 0});
- check_name_and_version(install_plan.install_actions[1], "b", {"1", 0});
-}
-
-TEST_CASE ("version install default features", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
-
- auto a_x = make_fpgh("x");
- auto& a_scf = vp.emplace("a", {"1", 0}, Scheme::Relaxed).source_control_file;
- a_scf->core_paragraph->default_features.push_back("x");
- a_scf->feature_paragraphs.push_back(std::move(a_x));
-
- MockCMakeVarProvider var_provider;
-
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp, bp, var_provider, {Dependency{"a"}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x"});
-}
-
-TEST_CASE ("version dont install default features", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
-
- auto a_x = make_fpgh("x");
- auto& a_scf = vp.emplace("a", {"1", 0}, Scheme::Relaxed).source_control_file;
- a_scf->core_paragraph->default_features.push_back("x");
- a_scf->feature_paragraphs.push_back(std::move(a_x));
-
- MockCMakeVarProvider var_provider;
-
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp, bp, var_provider, {Dependency{"a", {"core"}}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"1", 0});
-}
-
-TEST_CASE ("version install transitive default features", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
-
- auto a_x = make_fpgh("x");
- auto& a_scf = vp.emplace("a", {"1", 0}, Scheme::Relaxed).source_control_file;
- a_scf->core_paragraph->default_features.push_back("x");
- a_scf->feature_paragraphs.push_back(std::move(a_x));
-
- auto& b_scf = vp.emplace("b", {"1", 0}, Scheme::Relaxed).source_control_file;
- b_scf->core_paragraph->dependencies.push_back({"a", {"core"}});
-
- MockCMakeVarProvider var_provider;
-
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
- bp.v["b"] = {"1", 0};
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp, bp, var_provider, {Dependency{"b"}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x"});
- check_name_and_version(install_plan.install_actions[1], "b", {"1", 0});
-}
-
-static PlatformExpression::Expr parse_platform(StringView l)
-{
- return unwrap(PlatformExpression::parse_platform_expression(l, PlatformExpression::MultipleBinaryOperators::Deny));
-}
-
-TEST_CASE ("version install qualified dependencies", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
-
- vp.emplace("b", {"1", 0}, Scheme::Relaxed);
- vp.emplace("c", {"1", 0}, Scheme::Relaxed);
-
- MockBaselineProvider bp;
- bp.v["b"] = {"1", 0};
- bp.v["c"] = {"1", 0};
-
- SECTION ("windows")
- {
- MockCMakeVarProvider var_provider;
- var_provider.dep_info_vars[toplevel_spec()] = {{"VCPKG_CMAKE_SYSTEM_NAME", "Windows"}};
-
- auto install_plan = unwrap(
- create_versioned_install_plan(vp,
- bp,
- var_provider,
- {{"b", {}, parse_platform("!linux")}, {"c", {}, parse_platform("linux")}},
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "b", {"1", 0});
- }
-
- SECTION ("linux")
- {
- MockCMakeVarProvider var_provider;
- var_provider.dep_info_vars[toplevel_spec()] = {{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}};
-
- auto install_plan = unwrap(
- create_versioned_install_plan(vp,
- bp,
- var_provider,
- {{"b", {}, parse_platform("!linux")}, {"c", {}, parse_platform("linux")}},
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "c", {"1", 0});
- }
-}
-
-TEST_CASE ("version install qualified default suppression", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
-
- auto& a_scf = vp.emplace("a", {"1", 0}, Scheme::Relaxed).source_control_file;
- a_scf->core_paragraph->default_features.push_back("x");
- a_scf->feature_paragraphs.push_back(make_fpgh("x"));
-
- vp.emplace("b", {"1", 0}, Scheme::Relaxed)
- .source_control_file->core_paragraph->dependencies.push_back({"a", {"core"}});
-
- MockCMakeVarProvider var_provider;
-
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
- bp.v["b"] = {"1", 0};
-
- auto install_plan = unwrap(
- create_versioned_install_plan(vp,
- bp,
- var_provider,
- {{"b", {}, parse_platform("!linux")}, {"a", {"core"}, parse_platform("linux")}},
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x"});
- check_name_and_version(install_plan.install_actions[1], "b", {"1", 0});
-}
-
-TEST_CASE ("version install qualified transitive", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
-
- vp.emplace("a", {"1", 0}, Scheme::Relaxed);
- vp.emplace("c", {"1", 0}, Scheme::Relaxed);
-
- auto& b_scf = vp.emplace("b", {"1", 0}, Scheme::Relaxed).source_control_file;
- b_scf->core_paragraph->dependencies.push_back({"a", {}, parse_platform("!linux")});
- b_scf->core_paragraph->dependencies.push_back({"c", {}, parse_platform("linux")});
-
- MockCMakeVarProvider var_provider;
-
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
- bp.v["b"] = {"1", 0};
- bp.v["c"] = {"1", 0};
-
- auto install_plan = unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"b"}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "a", {"1", 0});
- check_name_and_version(install_plan.install_actions[1], "b", {"1", 0});
-}
-
-TEST_CASE ("version install different vars", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
-
- auto& b_scf = vp.emplace("b", {"1", 0}, Scheme::Relaxed).source_control_file;
- b_scf->core_paragraph->dependencies.push_back({"a", {}, parse_platform("!linux")});
-
- auto& a_scf = vp.emplace("a", {"1", 0}, Scheme::Relaxed).source_control_file;
- a_scf->core_paragraph->dependencies.push_back({"c", {}, parse_platform("linux")});
-
- vp.emplace("c", {"1", 0}, Scheme::Relaxed);
-
- MockCMakeVarProvider var_provider;
- var_provider.dep_info_vars[PackageSpec{"a", Test::X86_WINDOWS}] = {{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}};
-
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
- bp.v["b"] = {"1", 0};
- bp.v["c"] = {"1", 0};
-
- auto install_plan = unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"b"}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 3);
- check_name_and_version(install_plan.install_actions[0], "c", {"1", 0});
- check_name_and_version(install_plan.install_actions[1], "a", {"1", 0});
- check_name_and_version(install_plan.install_actions[2], "b", {"1", 0});
-}
-
-TEST_CASE ("version install qualified features", "[versionplan]")
-{
- MockVersionedPortfileProvider vp;
-
- auto& b_scf = vp.emplace("b", {"1", 0}, Scheme::Relaxed).source_control_file;
- b_scf->core_paragraph->default_features.push_back("x");
- b_scf->feature_paragraphs.push_back(make_fpgh("x"));
- b_scf->feature_paragraphs.back()->dependencies.push_back({"a", {}, parse_platform("!linux")});
-
- auto& a_scf = vp.emplace("a", {"1", 0}, Scheme::Relaxed).source_control_file;
- a_scf->core_paragraph->default_features.push_back("y");
- a_scf->feature_paragraphs.push_back(make_fpgh("y"));
- a_scf->feature_paragraphs.back()->dependencies.push_back({"c", {}, parse_platform("linux")});
-
- auto& c_scf = vp.emplace("c", {"1", 0}, Scheme::Relaxed).source_control_file;
- c_scf->core_paragraph->default_features.push_back("z");
- c_scf->feature_paragraphs.push_back(make_fpgh("z"));
- c_scf->feature_paragraphs.back()->dependencies.push_back({"d", {}, parse_platform("linux")});
-
- vp.emplace("d", {"1", 0}, Scheme::Relaxed);
-
- MockCMakeVarProvider var_provider;
- var_provider.dep_info_vars[PackageSpec{"a", Test::X86_WINDOWS}] = {{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}};
-
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
- bp.v["b"] = {"1", 0};
- bp.v["c"] = {"1", 0};
- bp.v["d"] = {"1", 0};
-
- auto install_plan = unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"b"}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 3);
- check_name_and_version(install_plan.install_actions[0], "c", {"1", 0}, {"z"});
- check_name_and_version(install_plan.install_actions[1], "a", {"1", 0}, {"y"});
- check_name_and_version(install_plan.install_actions[2], "b", {"1", 0}, {"x"});
-}
-
-TEST_CASE ("version install self features", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
-
- MockVersionedPortfileProvider vp;
- auto& a_scf = vp.emplace("a", {"1", 0}).source_control_file;
- a_scf->feature_paragraphs.push_back(make_fpgh("x"));
- a_scf->feature_paragraphs.back()->dependencies.push_back({"a", {"core", "y"}});
- a_scf->feature_paragraphs.push_back(make_fpgh("y"));
- a_scf->feature_paragraphs.push_back(make_fpgh("z"));
-
- MockCMakeVarProvider var_provider;
-
- auto install_plan =
- unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"a", {"x"}}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x", "y"});
-}
-
-TEST_CASE ("version overlay ports", "[versionplan]")
-{
- MockBaselineProvider bp;
- bp.v["a"] = {"1", 0};
- bp.v["b"] = {"1", 0};
- bp.v["c"] = {"1", 0};
-
- MockVersionedPortfileProvider vp;
- vp.emplace("a", {"1", 0});
- vp.emplace("a", {"1", 1});
- vp.emplace("a", {"2", 0});
- vp.emplace("b", {"1", 0}).source_control_file->core_paragraph->dependencies.emplace_back(Dependency{"a"});
- vp.emplace("c", {"1", 0})
- .source_control_file->core_paragraph->dependencies.emplace_back(
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "1", 1}});
-
- MockCMakeVarProvider var_provider;
-
- MockOverlayProvider oprovider;
- oprovider.emplace("a", {"overlay", 0});
-
- SECTION ("no baseline")
- {
- const MockBaselineProvider empty_bp;
-
- auto install_plan = unwrap(Dependencies::create_versioned_install_plan(
- vp, empty_bp, oprovider, var_provider, {{"a"}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0});
- }
-
- SECTION ("transitive")
- {
- auto install_plan = unwrap(
- Dependencies::create_versioned_install_plan(vp, bp, oprovider, var_provider, {{"b"}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0});
- check_name_and_version(install_plan.install_actions[1], "b", {"1", 0});
- }
-
- SECTION ("transitive constraint")
- {
- auto install_plan = unwrap(
- Dependencies::create_versioned_install_plan(vp, bp, oprovider, var_provider, {{"c"}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 2);
- check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0});
- check_name_and_version(install_plan.install_actions[1], "c", {"1", 0});
- }
-
- SECTION ("none")
- {
- auto install_plan = unwrap(
- Dependencies::create_versioned_install_plan(vp, bp, oprovider, var_provider, {{"a"}}, {}, toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0});
- }
- SECTION ("constraint")
- {
- auto install_plan = unwrap(Dependencies::create_versioned_install_plan(
- vp,
- bp,
- oprovider,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "1", 1}},
- },
- {},
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0});
- }
- SECTION ("constraint+override")
- {
- auto install_plan = unwrap(Dependencies::create_versioned_install_plan(
- vp,
- bp,
- oprovider,
- var_provider,
- {
- Dependency{"a", {}, {}, {Constraint::Type::Minimum, "1", 1}},
- },
- {
- DependencyOverride{"a", {"2", 0}},
- },
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0});
- }
- SECTION ("override")
- {
- auto install_plan = unwrap(Dependencies::create_versioned_install_plan(vp,
- bp,
- oprovider,
- var_provider,
- {
- Dependency{"a"},
- },
- {
- DependencyOverride{"a", {"2", 0}},
- },
- toplevel_spec()));
-
- REQUIRE(install_plan.size() == 1);
- check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0});
- }
-}
diff --git a/toolsrc/src/vcpkg-test/downloads.cpp b/toolsrc/src/vcpkg-test/downloads.cpp
deleted file mode 100644
index b182e46d6..000000000
--- a/toolsrc/src/vcpkg-test/downloads.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/downloads.h>
-
-using namespace vcpkg;
-
-TEST_CASE ("Downloads::details::split_uri_view", "[downloads]")
-{
- {
- auto x = Downloads::details::split_uri_view("https://github.com/Microsoft/vcpkg");
- REQUIRE(x.has_value());
- REQUIRE(x.get()->scheme == "https");
- REQUIRE(x.get()->authority.value_or("") == "//github.com");
- REQUIRE(x.get()->path_query_fragment == "/Microsoft/vcpkg");
- }
- {
- auto x = Downloads::details::split_uri_view("");
- REQUIRE(!x.has_value());
- }
- {
- auto x = Downloads::details::split_uri_view("hello");
- REQUIRE(!x.has_value());
- }
- {
- auto x = Downloads::details::split_uri_view("file:");
- REQUIRE(x.has_value());
- REQUIRE(x.get()->scheme == "file");
- REQUIRE(!x.get()->authority.has_value());
- REQUIRE(x.get()->path_query_fragment == "");
- }
- {
- auto x = Downloads::details::split_uri_view("file:path");
- REQUIRE(x.has_value());
- REQUIRE(x.get()->scheme == "file");
- REQUIRE(!x.get()->authority.has_value());
- REQUIRE(x.get()->path_query_fragment == "path");
- }
- {
- auto x = Downloads::details::split_uri_view("file:/path");
- REQUIRE(x.has_value());
- REQUIRE(x.get()->scheme == "file");
- REQUIRE(!x.get()->authority.has_value());
- REQUIRE(x.get()->path_query_fragment == "/path");
- }
- {
- auto x = Downloads::details::split_uri_view("file://user:pw@host");
- REQUIRE(x.has_value());
- REQUIRE(x.get()->scheme == "file");
- REQUIRE(x.get()->authority.value_or({}) == "//user:pw@host");
- REQUIRE(x.get()->path_query_fragment == "");
- }
- {
- auto x = Downloads::details::split_uri_view("ftp://host:port/");
- REQUIRE(x.has_value());
- REQUIRE(x.get()->scheme == "ftp");
- REQUIRE(x.get()->authority.value_or({}) == "//host:port");
- REQUIRE(x.get()->path_query_fragment == "/");
- }
-}
diff --git a/toolsrc/src/vcpkg-test/files.cpp b/toolsrc/src/vcpkg-test/files.cpp
deleted file mode 100644
index ffa72d0fb..000000000
--- a/toolsrc/src/vcpkg-test/files.cpp
+++ /dev/null
@@ -1,406 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/files.h>
-#include <vcpkg/base/strings.h>
-
-#include <iostream>
-#include <random>
-#include <vector>
-
-#include <vcpkg-test/util.h>
-
-using vcpkg::Test::AllowSymlinks;
-using vcpkg::Test::base_temporary_directory;
-using vcpkg::Test::can_create_symlinks;
-
-#define CHECK_EC_ON_FILE(file, ec) \
- do \
- { \
- if (ec) \
- { \
- FAIL(file << ": " << ec.message()); \
- } \
- } while (0)
-
-namespace
-{
- using uid_t = std::uniform_int_distribution<std::uint64_t>;
- using urbg_t = std::mt19937_64;
-
- urbg_t get_urbg(std::uint64_t index)
- {
- // smallest prime > 2**63 - 1
- return urbg_t{index + 9223372036854775837ULL};
- }
-
- std::string get_random_filename(urbg_t& urbg) { return vcpkg::Strings::b32_encode(uid_t{}(urbg)); }
-
- struct MaxDepth
- {
- std::uint64_t i;
- explicit MaxDepth(std::uint64_t i) : i(i) { }
- operator uint64_t() const { return i; }
- };
-
- struct Width
- {
- std::uint64_t i;
- explicit Width(std::uint64_t i) : i(i) { }
- operator uint64_t() const { return i; }
- };
-
- struct CurrentDepth
- {
- std::uint64_t i;
- explicit CurrentDepth(std::uint64_t i) : i(i) { }
- operator uint64_t() const { return i; }
- CurrentDepth incremented() const { return CurrentDepth{i + 1}; }
- };
-
- void create_directory_tree(urbg_t& urbg,
- vcpkg::Files::Filesystem& fs,
- const fs::path& base,
- MaxDepth max_depth,
- AllowSymlinks allow_symlinks = AllowSymlinks::Yes,
- Width width = Width{5},
- CurrentDepth current_depth = CurrentDepth{0})
- {
- // we want ~70% of our "files" to be directories, and then a third
- // each of the remaining ~30% to be regular files, directory symlinks,
- // and regular symlinks
- constexpr std::uint64_t directory_min_tag = 0;
- constexpr std::uint64_t directory_max_tag = 6;
- constexpr std::uint64_t regular_file_tag = 7;
- constexpr std::uint64_t regular_symlink_tag = 8;
- constexpr std::uint64_t directory_symlink_tag = 9;
-
- allow_symlinks = AllowSymlinks{allow_symlinks && can_create_symlinks()};
-
- // if we're at the max depth, we only want to build non-directories
- std::uint64_t file_type;
- if (current_depth >= max_depth)
- {
- file_type = uid_t{regular_file_tag, directory_symlink_tag}(urbg);
- }
- else if (current_depth < 2)
- {
- file_type = directory_min_tag;
- }
- else
- {
- file_type = uid_t{directory_min_tag, regular_symlink_tag}(urbg);
- }
-
- if (!allow_symlinks && file_type > regular_file_tag)
- {
- file_type = regular_file_tag;
- }
-
- std::error_code ec;
- if (file_type <= directory_max_tag)
- {
- fs.create_directory(base, ec);
- if (ec)
- {
- CHECK_EC_ON_FILE(base, ec);
- }
-
- for (std::uint64_t i = 0; i < width; ++i)
- {
- create_directory_tree(urbg,
- fs,
- base / get_random_filename(urbg),
- max_depth,
- allow_symlinks,
- width,
- current_depth.incremented());
- }
- }
- else if (file_type == regular_file_tag)
- {
- // regular file
- fs.write_contents(base, "", ec);
- }
- else if (file_type == regular_symlink_tag)
- {
- // regular symlink
- auto base_link = base;
- base_link.replace_filename(fs::u8string(base.filename()) + "-orig");
- fs.write_contents(base_link, "", ec);
- CHECK_EC_ON_FILE(base_link, ec);
- vcpkg::Test::create_symlink(base_link, base, ec);
- }
- else // file_type == directory_symlink_tag
- {
- // directory symlink
- auto parent = base;
- parent.remove_filename();
- vcpkg::Test::create_directory_symlink(parent, base, ec);
- }
-
- CHECK_EC_ON_FILE(base, ec);
- REQUIRE(fs::exists(fs.symlink_status(base, ec)));
- CHECK_EC_ON_FILE(base, ec);
- }
-
- vcpkg::Files::Filesystem& setup()
- {
- auto& fs = vcpkg::Files::get_real_filesystem();
-
- std::error_code ec;
- fs.create_directory(base_temporary_directory(), ec);
- CHECK_EC_ON_FILE(base_temporary_directory(), ec);
-
- return fs;
- }
-}
-
-TEST_CASE ("fs::combine works correctly", "[filesystem][files]")
-{
- using namespace fs;
- using namespace vcpkg::Files;
- CHECK(combine(u8path("/a/b"), u8path("c/d")) == u8path("/a/b/c/d"));
- CHECK(combine(u8path("a/b"), u8path("c/d")) == u8path("a/b/c/d"));
- CHECK(combine(u8path("/a/b"), u8path("/c/d")) == u8path("/c/d"));
-
-#if defined(_WIN32)
- CHECK(combine(u8path("C:/a/b"), u8path("c/d")) == u8path("C:/a/b/c/d"));
- CHECK(combine(u8path("C:a/b"), u8path("c/d")) == u8path("C:a/b/c/d"));
- CHECK(combine(u8path("C:a/b"), u8path("/c/d")) == u8path("C:/c/d"));
- CHECK(combine(u8path("C:/a/b"), u8path("/c/d")) == u8path("C:/c/d"));
- CHECK(combine(u8path("C:/a/b"), u8path("D:/c/d")) == u8path("D:/c/d"));
- CHECK(combine(u8path("C:/a/b"), u8path("D:c/d")) == u8path("D:c/d"));
- CHECK(combine(u8path("C:/a/b"), u8path("C:c/d")) == u8path("C:/a/b/c/d"));
-#endif
-}
-
-TEST_CASE ("remove all", "[files]")
-{
- auto urbg = get_urbg(0);
-
- auto& fs = setup();
-
- fs::path temp_dir = base_temporary_directory() / get_random_filename(urbg);
- INFO("temp dir is: " << temp_dir);
-
- create_directory_tree(urbg, fs, temp_dir, MaxDepth{5});
-
- std::error_code ec;
- fs::path fp;
- fs.remove_all(temp_dir, ec, fp);
- CHECK_EC_ON_FILE(fp, ec);
-
- REQUIRE_FALSE(fs.exists(temp_dir, ec));
- CHECK_EC_ON_FILE(temp_dir, ec);
-}
-
-TEST_CASE ("lexically_normal", "[files]")
-{
- const auto lexically_normal = [](const char* s) { return fs::lexically_normal(fs::u8path(s)); };
- const auto native = [](const char* s) { return std::move(fs::u8path(s).make_preferred()); };
- CHECK(fs::lexically_normal(fs::path()).native() == fs::path().native());
-
- // these test cases are taken from the MS STL tests
- CHECK(lexically_normal("cat/./dog/..").native() == native("cat/").native());
- CHECK(lexically_normal("cat/.///dog/../").native() == native("cat/").native());
-
- CHECK(lexically_normal("cat/./dog/..").native() == native("cat/").native());
- CHECK(lexically_normal("cat/.///dog/../").native() == native("cat/").native());
-
- CHECK(lexically_normal(".").native() == native(".").native());
- CHECK(lexically_normal("./").native() == native(".").native());
- CHECK(lexically_normal("./.").native() == native(".").native());
- CHECK(lexically_normal("././").native() == native(".").native());
-
- CHECK(lexically_normal("../../..").native() == native("../../..").native());
- CHECK(lexically_normal("../../../").native() == native("../../..").native());
-
- CHECK(lexically_normal("../../../a/b/c").native() == native("../../../a/b/c").native());
-
- CHECK(lexically_normal("/../../..").native() == native("/").native());
- CHECK(lexically_normal("/../../../").native() == native("/").native());
-
- CHECK(lexically_normal("/../../../a/b/c").native() == native("/a/b/c").native());
-
- CHECK(lexically_normal("a/..").native() == native(".").native());
- CHECK(lexically_normal("a/../").native() == native(".").native());
-
-#if defined(_WIN32)
- CHECK(lexically_normal(R"(X:)").native() == LR"(X:)");
-
- CHECK(lexically_normal(R"(X:DriveRelative)").native() == LR"(X:DriveRelative)");
-
- CHECK(lexically_normal(R"(X:\)").native() == LR"(X:\)");
- CHECK(lexically_normal(R"(X:/)").native() == LR"(X:\)");
- CHECK(lexically_normal(R"(X:\\\)").native() == LR"(X:\)");
- CHECK(lexically_normal(R"(X:///)").native() == LR"(X:\)");
-
- CHECK(lexically_normal(R"(X:\DosAbsolute)").native() == LR"(X:\DosAbsolute)");
- CHECK(lexically_normal(R"(X:/DosAbsolute)").native() == LR"(X:\DosAbsolute)");
- CHECK(lexically_normal(R"(X:\\\DosAbsolute)").native() == LR"(X:\DosAbsolute)");
- CHECK(lexically_normal(R"(X:///DosAbsolute)").native() == LR"(X:\DosAbsolute)");
-
- CHECK(lexically_normal(R"(\RootRelative)").native() == LR"(\RootRelative)");
- CHECK(lexically_normal(R"(/RootRelative)").native() == LR"(\RootRelative)");
- CHECK(lexically_normal(R"(\\\RootRelative)").native() == LR"(\RootRelative)");
- CHECK(lexically_normal(R"(///RootRelative)").native() == LR"(\RootRelative)");
-
- CHECK(lexically_normal(R"(\\server\share)").native() == LR"(\\server\share)");
- CHECK(lexically_normal(R"(//server/share)").native() == LR"(\\server\share)");
- CHECK(lexically_normal(R"(\\server\\\share)").native() == LR"(\\server\share)");
- CHECK(lexically_normal(R"(//server///share)").native() == LR"(\\server\share)");
-
- CHECK(lexically_normal(R"(\\?\device)").native() == LR"(\\?\device)");
- CHECK(lexically_normal(R"(//?/device)").native() == LR"(\\?\device)");
-
- CHECK(lexically_normal(R"(\??\device)").native() == LR"(\??\device)");
- CHECK(lexically_normal(R"(/??/device)").native() == LR"(\??\device)");
-
- CHECK(lexically_normal(R"(\\.\device)").native() == LR"(\\.\device)");
- CHECK(lexically_normal(R"(//./device)").native() == LR"(\\.\device)");
-
- CHECK(lexically_normal(R"(\\?\UNC\server\share)").native() == LR"(\\?\UNC\server\share)");
- CHECK(lexically_normal(R"(//?/UNC/server/share)").native() == LR"(\\?\UNC\server\share)");
-
- CHECK(lexically_normal(R"(C:\a/b\\c\/d/\e//f)").native() == LR"(C:\a\b\c\d\e\f)");
-
- CHECK(lexically_normal(R"(C:\meow\)").native() == LR"(C:\meow\)");
- CHECK(lexically_normal(R"(C:\meow/)").native() == LR"(C:\meow\)");
- CHECK(lexically_normal(R"(C:\meow\\)").native() == LR"(C:\meow\)");
- CHECK(lexically_normal(R"(C:\meow\/)").native() == LR"(C:\meow\)");
- CHECK(lexically_normal(R"(C:\meow/\)").native() == LR"(C:\meow\)");
- CHECK(lexically_normal(R"(C:\meow//)").native() == LR"(C:\meow\)");
-
- CHECK(lexically_normal(R"(C:\a\.\b\.\.\c\.\.\.)").native() == LR"(C:\a\b\c\)");
- CHECK(lexically_normal(R"(C:\a\.\b\.\.\c\.\.\.\)").native() == LR"(C:\a\b\c\)");
-
- CHECK(lexically_normal(R"(C:\a\b\c\d\e\..\f\..\..\..\g\h)").native() == LR"(C:\a\b\g\h)");
-
- CHECK(lexically_normal(R"(C:\a\b\c\d\e\..\f\..\..\..\g\h\..)").native() == LR"(C:\a\b\g\)");
- CHECK(lexically_normal(R"(C:\a\b\c\d\e\..\f\..\..\..\g\h\..\)").native() == LR"(C:\a\b\g\)");
- CHECK(lexically_normal(
- R"(/\server/\share/\a/\b/\c/\./\./\d/\../\../\../\../\../\../\../\other/x/y/z/.././..\meow.txt)")
- .native() == LR"(\\server\other\x\meow.txt)");
-#endif
-}
-
-#if defined(_WIN32)
-TEST_CASE ("win32_fix_path_case", "[files]")
-{
- using vcpkg::Files::win32_fix_path_case;
-
- // This test assumes that the Windows directory is C:\Windows
-
- CHECK(win32_fix_path_case(L"") == L"");
-
- CHECK(win32_fix_path_case(L"C:") == L"C:");
- CHECK(win32_fix_path_case(L"c:") == L"C:");
- CHECK(win32_fix_path_case(L"C:/") == L"C:\\");
- CHECK(win32_fix_path_case(L"C:\\") == L"C:\\");
- CHECK(win32_fix_path_case(L"c:\\") == L"C:\\");
- CHECK(win32_fix_path_case(L"C:\\WiNdOws") == L"C:\\Windows");
- CHECK(win32_fix_path_case(L"c:\\WiNdOws\\") == L"C:\\Windows\\");
- CHECK(win32_fix_path_case(L"C://///////WiNdOws") == L"C:\\Windows");
- CHECK(win32_fix_path_case(L"c:\\/\\/WiNdOws\\/") == L"C:\\Windows\\");
-
- auto& fs = vcpkg::Files::get_real_filesystem();
- auto original_cwd = fs.current_path(VCPKG_LINE_INFO);
- fs.current_path(L"C:\\", VCPKG_LINE_INFO);
- CHECK(win32_fix_path_case(L"\\") == L"\\");
- CHECK(win32_fix_path_case(L"\\/\\WiNdOws") == L"\\Windows");
- CHECK(win32_fix_path_case(L"\\WiNdOws") == L"\\Windows");
- CHECK(win32_fix_path_case(L"\\WiNdOws") == L"\\Windows");
- CHECK(win32_fix_path_case(L"c:WiNdOws") == L"C:Windows");
- CHECK(win32_fix_path_case(L"c:WiNdOws/system32") == L"C:Windows\\System32");
- fs.current_path(original_cwd, VCPKG_LINE_INFO);
-
- fs.create_directories("SuB/Dir/Ectory", VCPKG_LINE_INFO);
- CHECK(win32_fix_path_case(L"sub") == L"SuB");
- CHECK(win32_fix_path_case(L"SUB") == L"SuB");
- CHECK(win32_fix_path_case(L"sub/") == L"SuB\\");
- CHECK(win32_fix_path_case(L"sub/dir") == L"SuB\\Dir");
- CHECK(win32_fix_path_case(L"sub/dir/") == L"SuB\\Dir\\");
- CHECK(win32_fix_path_case(L"sub/dir/ectory") == L"SuB\\Dir\\Ectory");
- CHECK(win32_fix_path_case(L"sub/dir/ectory/") == L"SuB\\Dir\\Ectory\\");
- fs.remove_all("SuB", VCPKG_LINE_INFO);
-
- CHECK(win32_fix_path_case(L"//nonexistent_server\\nonexistent_share\\") ==
- L"\\\\nonexistent_server\\nonexistent_share\\");
- CHECK(win32_fix_path_case(L"\\\\nonexistent_server\\nonexistent_share\\") ==
- L"\\\\nonexistent_server\\nonexistent_share\\");
- CHECK(win32_fix_path_case(L"\\\\nonexistent_server\\nonexistent_share") ==
- L"\\\\nonexistent_server\\nonexistent_share");
-
- CHECK(win32_fix_path_case(L"///three_slashes_not_a_server\\subdir\\") == L"\\three_slashes_not_a_server\\subdir\\");
-
- CHECK(win32_fix_path_case(L"\\??\\c:\\WiNdOws") == L"\\??\\c:\\WiNdOws");
- CHECK(win32_fix_path_case(L"\\\\?\\c:\\WiNdOws") == L"\\\\?\\c:\\WiNdOws");
- CHECK(win32_fix_path_case(L"\\\\.\\c:\\WiNdOws") == L"\\\\.\\c:\\WiNdOws");
- CHECK(win32_fix_path_case(L"c:\\/\\/Nonexistent\\/path/here") == L"C:\\Nonexistent\\path\\here");
-}
-#endif // _WIN32
-
-#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
-TEST_CASE ("remove all -- benchmarks", "[files][!benchmark]")
-{
- auto urbg = get_urbg(1);
- auto& fs = setup();
-
- struct
- {
- urbg_t& urbg;
- vcpkg::Files::Filesystem& fs;
-
- void operator()(Catch::Benchmark::Chronometer& meter, MaxDepth max_depth, AllowSymlinks allow_symlinks) const
- {
- std::vector<fs::path> temp_dirs;
- temp_dirs.resize(meter.runs());
-
- std::generate(begin(temp_dirs), end(temp_dirs), [&] {
- fs::path temp_dir = base_temporary_directory() / get_random_filename(urbg);
- create_directory_tree(urbg, fs, temp_dir, max_depth, allow_symlinks);
- return temp_dir;
- });
-
- meter.measure([&](int run) {
- std::error_code ec;
- fs::path fp;
- const auto& temp_dir = temp_dirs[run];
-
- fs.remove_all(temp_dir, ec, fp);
- CHECK_EC_ON_FILE(fp, ec);
- });
-
- for (const auto& dir : temp_dirs)
- {
- std::error_code ec;
- REQUIRE_FALSE(fs.exists(dir, ec));
- CHECK_EC_ON_FILE(dir, ec);
- }
- }
- } do_benchmark = {urbg, fs};
-
- BENCHMARK_ADVANCED("small directory, no symlinks")(Catch::Benchmark::Chronometer meter)
- {
- do_benchmark(meter, MaxDepth{2}, AllowSymlinks::No);
- };
-
- BENCHMARK_ADVANCED("large directory, no symlinks")(Catch::Benchmark::Chronometer meter)
- {
- do_benchmark(meter, MaxDepth{5}, AllowSymlinks::No);
- };
-
- if (can_create_symlinks())
- {
- BENCHMARK_ADVANCED("small directory, symlinks")(Catch::Benchmark::Chronometer meter)
- {
- do_benchmark(meter, MaxDepth{2}, AllowSymlinks::Yes);
- };
-
- BENCHMARK_ADVANCED("large directory, symlinks")(Catch::Benchmark::Chronometer meter)
- {
- do_benchmark(meter, MaxDepth{5}, AllowSymlinks::Yes);
- };
- }
-}
-#endif
diff --git a/toolsrc/src/vcpkg-test/hash.cpp b/toolsrc/src/vcpkg-test/hash.cpp
deleted file mode 100644
index 9f3ccc25e..000000000
--- a/toolsrc/src/vcpkg-test/hash.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/hash.h>
-
-#include <algorithm>
-#include <iostream>
-#include <iterator>
-#include <map>
-
-namespace Hash = vcpkg::Hash;
-using vcpkg::StringView;
-
-// Require algorithm: Hash::Algorithm::Tag to be in scope
-#define CHECK_HASH(size, value, real_hash) \
- do \
- { \
- unsigned char data[size]; \
- std::fill(std::begin(data), std::end(data), static_cast<unsigned char>(value)); \
- const auto hash = Hash::get_bytes_hash(data, data + size, algorithm); \
- REQUIRE(hash == real_hash); \
- } while (0)
-
-#define CHECK_HASH_OF(data, real_hash) \
- do \
- { \
- const auto hash = Hash::get_bytes_hash(std::begin(data), std::end(data), algorithm); \
- REQUIRE(hash == real_hash); \
- } while (0)
-
-#define CHECK_HASH_STRING(data, real_hash) \
- do \
- { \
- const auto hash = Hash::get_string_hash(data, algorithm); \
- REQUIRE(hash == real_hash); \
- } while (0)
-
-// Requires hasher: std::unique_ptr<Hash::Hasher> to be in scope
-#define CHECK_HASH_LARGE(size, value, real_hash) \
- do \
- { \
- hasher->clear(); \
- std::uint64_t remaining = size; \
- unsigned char buffer[512]; \
- std::fill(std::begin(buffer), std::end(buffer), static_cast<unsigned char>(value)); \
- while (remaining) \
- { \
- if (remaining < 512) \
- { \
- hasher->add_bytes(std::begin(buffer), std::begin(buffer) + remaining); \
- remaining = 0; \
- } \
- else \
- { \
- hasher->add_bytes(std::begin(buffer), std::end(buffer)); \
- remaining -= 512; \
- } \
- } \
- REQUIRE(hasher->get_hash() == real_hash); \
- } while (0)
-
-TEST_CASE ("SHA1: basic tests", "[hash][sha1]")
-{
- const auto algorithm = Hash::Algorithm::Sha1;
-
- CHECK_HASH_STRING("", "da39a3ee5e6b4b0d3255bfef95601890afd80709");
- CHECK_HASH_STRING(";", "2d14ab97cc3dc294c51c0d6814f4ea45f4b4e312");
- CHECK_HASH_STRING("asdifasdfnas", "b77eb8a1b4c2ef6716d7d302647e4511b1a638a6");
- CHECK_HASH_STRING("asdfanvoinaoifawenflawenfiwnofvnasfjvnaslkdfjlkasjdfanm,"
- "werflawoienfowanevoinwai32910u2740918741o;j;wejfqwioaher9283hrpf;asd",
- "c69bcd30c196c7050906d212722dd7a7659aad04");
-}
-
-TEST_CASE ("SHA1: NIST test cases (small)", "[hash][sha1]")
-{
- const auto algorithm = Hash::Algorithm::Sha1;
-
- CHECK_HASH_STRING("abc", "a9993e364706816aba3e25717850c26c9cd0d89d");
- CHECK_HASH_STRING("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
-}
-
-TEST_CASE ("SHA256: basic tests", "[hash][sha256]")
-{
- const auto algorithm = Hash::Algorithm::Sha256;
-
- CHECK_HASH_STRING("", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
- CHECK_HASH_STRING(";", "41b805ea7ac014e23556e98bb374702a08344268f92489a02f0880849394a1e4");
- CHECK_HASH_STRING("asdifasdfnas", "2bb1fb910831fdc11d5a3996425a84ace27aeb81c9c20ace9f60ac1b3218b291");
- CHECK_HASH_STRING("asdfanvoinaoifawenflawenfiwnofvnasfjvnaslkdfjlkasjdfanm,"
- "werflawoienfowanevoinwai32910u2740918741o;j;wejfqwioaher9283hrpf;asd",
- "10c98034b424d4e40ca933bc524ea38b4e53290d76e8b38edc4ea2fec7f529aa");
-}
-
-TEST_CASE ("SHA256: NIST test cases (small)", "[hash][sha256]")
-{
- const auto algorithm = Hash::Algorithm::Sha256;
-
- CHECK_HASH(1, 0xbd, "68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b");
- {
- const unsigned char data[] = {0xc9, 0x8c, 0x8e, 0x55};
- CHECK_HASH_OF(data, "7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504");
- }
- CHECK_HASH(55, 0, "02779466cdec163811d078815c633f21901413081449002f24aa3e80f0b88ef7");
- CHECK_HASH(56, 0, "d4817aa5497628e7c77e6b606107042bbba3130888c5f47a375e6179be789fbb");
- CHECK_HASH(57, 0, "65a16cb7861335d5ace3c60718b5052e44660726da4cd13bb745381b235a1785");
- CHECK_HASH(64, 0, "f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b");
- CHECK_HASH(1000, 0, "541b3e9daa09b20bf85fa273e5cbd3e80185aa4ec298e765db87742b70138a53");
- CHECK_HASH(1000, 'A', "c2e686823489ced2017f6059b8b239318b6364f6dcd835d0a519105a1eadd6e4");
- CHECK_HASH(1005, 'U', "f4d62ddec0f3dd90ea1380fa16a5ff8dc4c54b21740650f24afc4120903552b0");
-}
-
-TEST_CASE ("SHA512: NIST test cases (small)", "[hash][sha512]")
-{
- const auto algorithm = Hash::Algorithm::Sha512;
-
- CHECK_HASH_STRING("",
- "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f"
- "63b931bd47417a81a538327af927da3e");
-
- CHECK_HASH(111,
- 0,
- "77ddd3a542e530fd047b8977c657ba6ce72f1492e360b2b2212cd264e75ec03882e4ff0525517ab4207d14c70c2259ba88d4d33"
- "5ee0e7e20543d22102ab1788c");
- CHECK_HASH(112,
- 0,
- "2be2e788c8a8adeaa9c89a7f78904cacea6e39297d75e0573a73c756234534d6627ab4156b48a6657b29ab8beb73334040ad39e"
- "ad81446bb09c70704ec707952");
- CHECK_HASH(113,
- 0,
- "0e67910bcf0f9ccde5464c63b9c850a12a759227d16b040d98986d54253f9f34322318e56b8feb86c5fb2270ed87f31252f7f68"
- "493ee759743909bd75e4bb544");
- CHECK_HASH(122,
- 0,
- "4f3f095d015be4a7a7cc0b8c04da4aa09e74351e3a97651f744c23716ebd9b3e822e5077a01baa5cc0ed45b9249e88ab343d433"
- "3539df21ed229da6f4a514e0f");
- CHECK_HASH(1000,
- 0,
- "ca3dff61bb23477aa6087b27508264a6f9126ee3a004f53cb8db942ed345f2f2d229b4b59c859220a1cf1913f34248e3803bab6"
- "50e849a3d9a709edc09ae4a76");
- CHECK_HASH(1000,
- 'A',
- "329c52ac62d1fe731151f2b895a00475445ef74f50b979c6f7bb7cae349328c1d4cb4f7261a0ab43f936a24b000651d4a824fcd"
- "d577f211aef8f806b16afe8af");
- CHECK_HASH(1005,
- 'U',
- "59f5e54fe299c6a8764c6b199e44924a37f59e2b56c3ebad939b7289210dc8e4c21b9720165b0f4d4374c90f1bf4fb4a5ace17a"
- "1161798015052893a48c3d161");
-}
-
-TEST_CASE ("SHA256: NIST test cases (large)", "[.][hash-expensive][sha256-expensive]")
-{
- auto hasher = Hash::get_hasher_for(Hash::Algorithm::Sha256);
- CHECK_HASH_LARGE(1'000'000, 0, "d29751f2649b32ff572b5e0a9f541ea660a50f94ff0beedfb0b692b924cc8025");
- CHECK_HASH_LARGE(0x2000'0000, 'Z', "15a1868c12cc53951e182344277447cd0979536badcc512ad24c67e9b2d4f3dd");
- CHECK_HASH_LARGE(0x4100'0000, 0, "461c19a93bd4344f9215f5ec64357090342bc66b15a148317d276e31cbc20b53");
- CHECK_HASH_LARGE(0x6000'003E, 'B', "c23ce8a7895f4b21ec0daf37920ac0a262a220045a03eb2dfed48ef9b05aabea");
-}
-
-TEST_CASE ("SHA512: NIST test cases (large)", "[.][hash-expensive][sha512-expensive]")
-{
- auto hasher = Hash::get_hasher_for(Hash::Algorithm::Sha512);
- CHECK_HASH_LARGE(1'000'000,
- 0,
- "ce044bc9fd43269d5bbc946cbebc3bb711341115cc4abdf2edbc3ff2c57ad4b15deb699bda257fea5aef9c6e55fcf4cf9"
- "dc25a8c3ce25f2efe90908379bff7ed");
- CHECK_HASH_LARGE(0x2000'0000,
- 'Z',
- "da172279f3ebbda95f6b6e1e5f0ebec682c25d3d93561a1624c2fa9009d64c7e9923f3b46bcaf11d39a531f43297992ba"
- "4155c7e827bd0f1e194ae7ed6de4cac");
- CHECK_HASH_LARGE(0x4100'0000,
- 0,
- "14b1be901cb43549b4d831e61e5f9df1c791c85b50e85f9d6bc64135804ad43ce8402750edbe4e5c0fc170b99cf78b9f4"
- "ecb9c7e02a157911d1bd1832d76784f");
- CHECK_HASH_LARGE(0x6000'003E,
- 'B',
- "fd05e13eb771f05190bd97d62647157ea8f1f6949a52bb6daaedbad5f578ec59b1b8d6c4a7ecb2feca6892b4dc1387716"
- "70a0f3bd577eea326aed40ab7dd58b1");
-}
-
-#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
-using Catch::Benchmark::Chronometer;
-void benchmark_hasher(Chronometer& meter, Hash::Hasher& hasher, std::uint64_t size, unsigned char byte) noexcept
-{
- unsigned char buffer[1024];
- std::fill(std::begin(buffer), std::end(buffer), byte);
-
- meter.measure([&] {
- hasher.clear();
- std::uint64_t remaining = size;
- while (remaining)
- {
- if (remaining < 512)
- {
- hasher.add_bytes(std::begin(buffer), std::begin(buffer) + remaining);
- remaining = 0;
- }
- else
- {
- hasher.add_bytes(std::begin(buffer), std::end(buffer));
- remaining -= 512;
- }
- }
- hasher.get_hash();
- });
-}
-
-TEST_CASE ("SHA1: benchmark", "[.][hash][sha256][!benchmark]")
-{
- using Catch::Benchmark::Chronometer;
-
- auto hasher = Hash::get_hasher_for(Hash::Algorithm::Sha1);
-
- BENCHMARK_ADVANCED("0 x 1'000'000")(Catch::Benchmark::Chronometer meter)
- {
- benchmark_hasher(meter, *hasher, 1'000'000, 0);
- };
- BENCHMARK_ADVANCED("'Z' x 0x2000'0000")(Catch::Benchmark::Chronometer meter)
- {
- benchmark_hasher(meter, *hasher, 0x2000'0000, 'Z');
- };
- BENCHMARK_ADVANCED("0 x 0x4100'0000")(Catch::Benchmark::Chronometer meter)
- {
- benchmark_hasher(meter, *hasher, 0x4100'0000, 0);
- };
- BENCHMARK_ADVANCED("'B' x 0x6000'003E")(Catch::Benchmark::Chronometer meter)
- {
- benchmark_hasher(meter, *hasher, 0x6000'003E, 'B');
- };
-}
-
-TEST_CASE ("SHA256: benchmark", "[.][hash][sha256][!benchmark]")
-{
- using Catch::Benchmark::Chronometer;
-
- auto hasher = Hash::get_hasher_for(Hash::Algorithm::Sha256);
-
- BENCHMARK_ADVANCED("0 x 1'000'000")(Catch::Benchmark::Chronometer meter)
- {
- benchmark_hasher(meter, *hasher, 1'000'000, 0);
- };
- BENCHMARK_ADVANCED("'Z' x 0x2000'0000")(Catch::Benchmark::Chronometer meter)
- {
- benchmark_hasher(meter, *hasher, 0x2000'0000, 'Z');
- };
- BENCHMARK_ADVANCED("0 x 0x4100'0000")(Catch::Benchmark::Chronometer meter)
- {
- benchmark_hasher(meter, *hasher, 0x4100'0000, 0);
- };
- BENCHMARK_ADVANCED("'B' x 0x6000'003E")(Catch::Benchmark::Chronometer meter)
- {
- benchmark_hasher(meter, *hasher, 0x6000'003E, 'B');
- };
-}
-
-TEST_CASE ("SHA512: large -- benchmark", "[.][hash][sha512][!benchmark]")
-{
- auto hasher = Hash::get_hasher_for(Hash::Algorithm::Sha512);
-
- BENCHMARK_ADVANCED("0 x 1'000'000")(Catch::Benchmark::Chronometer meter)
- {
- benchmark_hasher(meter, *hasher, 1'000'000, 0);
- };
- BENCHMARK_ADVANCED("'Z' x 0x2000'0000")(Catch::Benchmark::Chronometer meter)
- {
- benchmark_hasher(meter, *hasher, 0x2000'0000, 'Z');
- };
- BENCHMARK_ADVANCED("0 x 0x4100'0000")(Catch::Benchmark::Chronometer meter)
- {
- benchmark_hasher(meter, *hasher, 0x4100'0000, 0);
- };
- BENCHMARK_ADVANCED("'B' x 0x6000'003E")(Catch::Benchmark::Chronometer meter)
- {
- benchmark_hasher(meter, *hasher, 0x6000'003E, 'B');
- };
-}
-#endif
diff --git a/toolsrc/src/vcpkg-test/json.cpp b/toolsrc/src/vcpkg-test/json.cpp
deleted file mode 100644
index b03fe2aec..000000000
--- a/toolsrc/src/vcpkg-test/json.cpp
+++ /dev/null
@@ -1,241 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/json.h>
-#include <vcpkg/base/unicode.h>
-
-#include <iostream>
-
-#include "math.h"
-
-// TODO: remove this once we switch to C++20 completely
-// This is the worst, but we also can't really deal with it any other way.
-#if __cpp_char8_t
-template<size_t Sz>
-static auto _u8_string_to_char_string(const char8_t (&literal)[Sz]) -> const char (&)[Sz]
-{
- return reinterpret_cast<const char(&)[Sz]>(literal);
-}
-
-#define U8_STR(s) (::vcpkg::Unicode::_u8_string_to_char_string(u8"" s))
-#else
-#define U8_STR(s) (u8"" s)
-#endif
-
-namespace Json = vcpkg::Json;
-using Json::Value;
-
-static std::string mystringify(const Value& val) { return Json::stringify(val, Json::JsonStyle{}); }
-
-TEST_CASE ("JSON stringify weird strings", "[json]")
-{
- std::string str = U8_STR("😀 😁 😂 🤣 😃 😄 😅 😆 😉");
- REQUIRE(mystringify(Value::string(str)) == ('"' + str + "\"\n"));
- REQUIRE(mystringify(Value::string("\xED\xA0\x80")) == "\"\\ud800\"\n"); // unpaired surrogate
-}
-
-TEST_CASE ("JSON parse keywords", "[json]")
-{
- auto res = Json::parse("true");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_boolean());
- REQUIRE(res.get()->first.boolean());
- res = Json::parse(" false ");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_boolean());
- REQUIRE(!res.get()->first.boolean());
- res = Json::parse(" null\t ");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_null());
-}
-
-TEST_CASE ("JSON parse strings", "[json]")
-{
- auto res = Json::parse(R"("")");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string().size() == 0);
-
- res = Json::parse(R"("\ud800")"); // unpaired surrogate
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string() == "\xED\xA0\x80");
-
- const auto make_json_string = [](vcpkg::StringView sv) { return '"' + sv.to_string() + '"'; };
- const vcpkg::StringView radical = U8_STR("⎷");
- const vcpkg::StringView grin = U8_STR("😁");
-
- res = Json::parse(R"("\uD83D\uDE01")"); // paired surrogates for grin
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string() == grin.to_string());
-
- res = Json::parse(make_json_string(radical)); // character in BMP
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string() == radical);
-
- res = Json::parse(make_json_string(grin)); // character above BMP
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string() == grin);
-}
-
-TEST_CASE ("JSON parse strings with escapes", "[json]")
-{
- auto res = Json::parse(R"("\t")");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string() == "\t");
-
- res = Json::parse(R"("\\")");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string() == "\\");
-
- res = Json::parse(R"("\/")");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string() == "/");
-
- res = Json::parse(R"("\b")");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string() == "\b");
-
- res = Json::parse(R"("\f")");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string() == "\f");
-
- res = Json::parse(R"("\n")");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string() == "\n");
-
- res = Json::parse(R"("\r")");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string() == "\r");
-
- res = Json::parse(R"("This is a \"test\", hopefully it worked")");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_string());
- REQUIRE(res.get()->first.string() == R"(This is a "test", hopefully it worked)");
-}
-
-TEST_CASE ("JSON parse integers", "[json]")
-{
- auto res = Json::parse("0");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_integer());
- REQUIRE(res.get()->first.integer() == 0);
- res = Json::parse("12345");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_integer());
- REQUIRE(res.get()->first.integer() == 12345);
- res = Json::parse("-12345");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_integer());
- REQUIRE(res.get()->first.integer() == -12345);
- res = Json::parse("9223372036854775807"); // INT64_MAX
- REQUIRE(res);
- REQUIRE(res.get()->first.is_integer());
- REQUIRE(res.get()->first.integer() == 9223372036854775807);
- res = Json::parse("-9223372036854775808");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_integer());
- REQUIRE(res.get()->first.integer() == (-9223372036854775807 - 1)); // INT64_MIN (C++'s parser is fun)
-}
-
-TEST_CASE ("JSON parse floats", "[json]")
-{
- auto res = Json::parse("0.0");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_number());
- REQUIRE(!res.get()->first.is_integer());
- REQUIRE(res.get()->first.number() == 0.0);
- REQUIRE(!signbit(res.get()->first.number()));
- res = Json::parse("-0.0");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_number());
- REQUIRE(res.get()->first.number() == 0.0);
- REQUIRE(signbit(res.get()->first.number()));
- res = Json::parse("12345.6789");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_number());
- REQUIRE_THAT(res.get()->first.number(), Catch::WithinULP(12345.6789, 3));
- res = Json::parse("-12345.6789");
- REQUIRE(res);
- REQUIRE(res.get()->first.is_number());
- REQUIRE_THAT(res.get()->first.number(), Catch::WithinULP(-12345.6789, 3));
-}
-
-TEST_CASE ("JSON parse arrays", "[json]")
-{
- auto res = Json::parse("[]");
- REQUIRE(res);
- auto val = std::move(res.get()->first);
- REQUIRE(val.is_array());
- REQUIRE(val.array().size() == 0);
-
- res = Json::parse("[123]");
- REQUIRE(res);
- val = std::move(res.get()->first);
- REQUIRE(val.is_array());
- REQUIRE(val.array().size() == 1);
- REQUIRE(val.array()[0].is_integer());
- REQUIRE(val.array()[0].integer() == 123);
-
- res = Json::parse("[123, 456]");
- REQUIRE(res);
- val = std::move(res.get()->first);
- REQUIRE(val.is_array());
- REQUIRE(val.array().size() == 2);
- REQUIRE(val.array()[0].is_integer());
- REQUIRE(val.array()[0].integer() == 123);
- REQUIRE(val.array()[1].is_integer());
- REQUIRE(val.array()[1].integer() == 456);
-
- res = Json::parse("[123, 456, [null]]");
- REQUIRE(res);
- val = std::move(res.get()->first);
- REQUIRE(val.is_array());
- REQUIRE(val.array().size() == 3);
- REQUIRE(val.array()[2].is_array());
- REQUIRE(val.array()[2].array().size() == 1);
- REQUIRE(val.array()[2].array()[0].is_null());
-}
-
-TEST_CASE ("JSON parse objects", "[json]")
-{
- auto res = Json::parse("{}");
- REQUIRE(res);
- auto val = std::move(res.get()->first);
- REQUIRE(val.is_object());
- REQUIRE(val.object().size() == 0);
-}
-
-TEST_CASE ("JSON parse full file", "[json]")
-{
- vcpkg::StringView json =
-#include "large-json-document.json.inc"
- ;
-
- auto res = Json::parse(json);
- if (!res)
- {
- std::cerr << res.error()->format() << '\n';
- }
- REQUIRE(res);
-}
-
-TEST_CASE ("JSON track newlines", "[json]")
-{
- auto res = Json::parse("{\n,", fs::u8path("filename"));
- REQUIRE(!res);
- REQUIRE(res.error()->format() ==
- R"(filename:2:1: error: Unexpected character; expected property name
- on expression: ,
- ^
-)");
-}
diff --git a/toolsrc/src/vcpkg-test/large-json-document.json.inc b/toolsrc/src/vcpkg-test/large-json-document.json.inc
deleted file mode 100644
index 6cab7cf21..000000000
--- a/toolsrc/src/vcpkg-test/large-json-document.json.inc
+++ /dev/null
@@ -1,516 +0,0 @@
-// randomly generated by json-generator.com
-R"json([
- {
- "_id": "5e7a86c71cf688019f4c4b9f",
- "index": 0,
- "guid": "0e3c8a89-9960-4d87-8634-f9d3fcdaf735",
- "isActive": false,
- "balance": "$2,473.46",
- "picture": "http://placehold.it/32x32",
- "age": 21,
- "eyeColor": "blue",
- "name": {
- "first": "Dana",
- "last": "Romero"
- },
- "company": "NETPLODE",
- "email": "dana.romero@netplode.info",
- "phone": "+1 (981) 479-2769",
- "address": "501 Cass Place, Strykersville, Missouri, 8329",
- "about": "Incididunt in fugiat ipsum proident aliqua voluptate Lorem nostrud laboris ut velit minim. Dolor culpa magna tempor cupidatat. Id esse quis ipsum incididunt. Aliqua deserunt aliquip esse minim cillum esse aliquip veniam non labore dolor incididunt. Sint ea consectetur exercitation aliqua proident reprehenderit tempor ea eu. Amet ipsum labore magna elit.",
- "registered": "Wednesday, September 4, 2019 8:29 AM",
- "latitude": "-49.844379",
- "longitude": "-5.565357",
- "tags": [
- "dolor",
- "fugiat",
- "ea",
- "nisi",
- "non"
- ],
- "range": [
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9
- ],
- "friends": [
- {
- "id": 0,
- "name": "Elena Suarez"
- },
- {
- "id": 1,
- "name": "Pruitt Leach"
- },
- {
- "id": 2,
- "name": "Pugh Robinson"
- }
- ],
- "greeting": "Hello, Dana! You have 8 unread messages.",
- "favoriteFruit": "apple"
- },
- {
- "_id": "5e7a86c70efbf62ab5579408",
- "index": 1,
- "guid": "2c64c2d3-a830-4598-a399-f68f798ba6dc",
- "isActive": true,
- "balance": "$1,838.58",
- "picture": "http://placehold.it/32x32",
- "age": 33,
- "eyeColor": "brown",
- "name": {
- "first": "Ladonna",
- "last": "Willis"
- },
- "company": "JOVIOLD",
- "email": "ladonna.willis@joviold.us",
- "phone": "+1 (921) 591-2296",
- "address": "441 Highland Place, Leyner, Pennsylvania, 1788",
- "about": "Consequat deserunt nisi sit ex occaecat. Magna pariatur irure nisi duis laborum proident ipsum duis. Tempor qui consectetur consequat sunt proident ex ad id sint cupidatat sint.",
- "registered": "Wednesday, January 13, 2016 6:03 PM",
- "latitude": "-62.130182",
- "longitude": "-102.884995",
- "tags": [
- "fugiat",
- "ipsum",
- "ut",
- "pariatur",
- "enim"
- ],
- "range": [
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9
- ],
- "friends": [
- {
- "id": 0,
- "name": "Gamble Rose"
- },
- {
- "id": 1,
- "name": "Olive Horn"
- },
- {
- "id": 2,
- "name": "Benita Ochoa"
- }
- ],
- "greeting": "Hello, Ladonna! You have 6 unread messages.",
- "favoriteFruit": "banana"
- },
- {
- "_id": "5e7a86c71e30c95bbb0ff386",
- "index": 2,
- "guid": "04e45222-d785-461b-99be-b330585eb1a1",
- "isActive": true,
- "balance": "$3,591.60",
- "picture": "http://placehold.it/32x32",
- "age": 32,
- "eyeColor": "brown",
- "name": {
- "first": "Lee",
- "last": "Buckley"
- },
- "company": "TELEQUIET",
- "email": "lee.buckley@telequiet.biz",
- "phone": "+1 (897) 511-2132",
- "address": "675 Argyle Road, Kempton, Ohio, 4411",
- "about": "Sunt aliquip excepteur veniam fugiat consequat commodo ex est nulla laboris cillum enim. Laboris cupidatat et ipsum anim reprehenderit officia officia aute aliqua tempor. Incididunt sunt cupidatat mollit deserunt id nisi esse elit nisi est eiusmod aliquip. Lorem cillum ipsum quis aliquip laboris ex minim eu quis. Dolore incididunt officia labore enim Lorem in occaecat aliquip. Mollit ad duis non non qui et Lorem cillum.",
- "registered": "Tuesday, January 16, 2018 3:14 PM",
- "latitude": "-51.283144",
- "longitude": "-112.569722",
- "tags": [
- "id",
- "veniam",
- "dolor",
- "nulla",
- "pariatur"
- ],
- "range": [
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9
- ],
- "friends": [
- {
- "id": 0,
- "name": "Dina Craft"
- },
- {
- "id": 1,
- "name": "Ashlee Ferrell"
- },
- {
- "id": 2,
- "name": "Mcbride Gill"
- }
- ],
- "greeting": "Hello, Lee! You have 7 unread messages.",
- "favoriteFruit": "banana"
- },
- {
- "_id": "5e7a86c70e08bf0c278749f9",
- "index": 3,
- "guid": "0928ccac-e028-405a-a614-76628ba131b4",
- "isActive": false,
- "balance": "$2,867.88",
- "picture": "http://placehold.it/32x32",
- "age": 26,
- "eyeColor": "green",
- "name": {
- "first": "Chen",
- "last": "Rosa"
- },
- "company": "EXPOSA",
- "email": "chen.rosa@exposa.me",
- "phone": "+1 (956) 519-3064",
- "address": "239 Amersfort Place, Fillmore, South Carolina, 2443",
- "about": "Est ipsum cillum proident veniam voluptate enim sit eu excepteur veniam sit. Sunt aliqua qui incididunt id irure nulla qui. Et consequat ad anim proident minim dolor quis aliquip Lorem qui fugiat voluptate ex.",
- "registered": "Wednesday, April 9, 2014 12:45 PM",
- "latitude": "-15.222992",
- "longitude": "76.730424",
- "tags": [
- "eiusmod",
- "sit",
- "do",
- "aute",
- "ea"
- ],
- "range": [
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9
- ],
- "friends": [
- {
- "id": 0,
- "name": "Huff Townsend"
- },
- {
- "id": 1,
- "name": "Stacie Downs"
- },
- {
- "id": 2,
- "name": "Liza Barron"
- }
- ],
- "greeting": "Hello, Chen! You have 8 unread messages.",
- "favoriteFruit": "banana"
- },
- {
- "_id": "5e7a86c7086fc15efc387abc",
- "index": 4,
- "guid": "c71e62aa-8428-44cd-a2a5-7c30aaf963fe",
- "isActive": true,
- "balance": "$3,022.64",
- "picture": "http://placehold.it/32x32",
- "age": 32,
- "eyeColor": "blue",
- "name": {
- "first": "Walton",
- "last": "Mendez"
- },
- "company": "BUZZNESS",
- "email": "walton.mendez@buzzness.tv",
- "phone": "+1 (849) 560-2058",
- "address": "507 Colonial Court, Collins, New York, 7941",
- "about": "Et nisi in excepteur velit non incididunt sit. Consectetur magna sunt dolor eu Lorem adipisicing incididunt laborum consequat proident. Laboris ut dolor laboris esse ut dolor adipisicing ad fugiat commodo fugiat incididunt pariatur anim. Amet reprehenderit aute fugiat incididunt irure eu duis sint amet aliquip excepteur tempor dolore. Anim reprehenderit commodo irure sint et tempor occaecat fugiat ex commodo consectetur. Id ex dolor et culpa mollit. Voluptate magna est ex proident deserunt ullamco enim quis nulla cupidatat voluptate culpa exercitation Lorem.",
- "registered": "Tuesday, May 9, 2017 2:38 PM",
- "latitude": "86.083203",
- "longitude": "57.386268",
- "tags": [
- "Lorem",
- "aute",
- "proident",
- "eu",
- "incididunt"
- ],
- "range": [
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9
- ],
- "friends": [
- {
- "id": 0,
- "name": "Byers Sims"
- },
- {
- "id": 1,
- "name": "Suzanne Gonzalez"
- },
- {
- "id": 2,
- "name": "Vicki Velasquez"
- }
- ],
- "greeting": "Hello, Walton! You have 5 unread messages.",
- "favoriteFruit": "banana"
- },
- {
- "_id": "5e7a86c7dc9b82ffcb2868a2",
- "index": 5,
- "guid": "76f1c1cc-9164-43df-8858-633ee696df1c",
- "isActive": true,
- "balance": "$2,625.28",
- "picture": "http://placehold.it/32x32",
- "age": 40,
- "eyeColor": "green",
- "name": {
- "first": "Wise",
- "last": "Head"
- },
- "company": "FARMEX",
- "email": "wise.head@farmex.com",
- "phone": "+1 (850) 478-3280",
- "address": "425 Kent Street, Witmer, New Jersey, 2411",
- "about": "Velit amet fugiat enim occaecat do. Nulla sint officia anim ullamco. Ea quis excepteur excepteur enim ullamco. Amet aliqua mollit ad excepteur minim voluptate in velit sunt elit duis quis consequat nulla. Est dolor quis culpa aute id occaecat adipisicing mollit do consectetur fugiat. Mollit elit ex nostrud pariatur. Deserunt proident et voluptate occaecat labore occaecat Lorem exercitation est minim magna.",
- "registered": "Monday, March 23, 2015 10:14 PM",
- "latitude": "29.880281",
- "longitude": "126.094567",
- "tags": [
- "enim",
- "sunt",
- "cupidatat",
- "officia",
- "aute"
- ],
- "range": [
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9
- ],
- "friends": [
- {
- "id": 0,
- "name": "Fuentes Tyler"
- },
- {
- "id": 1,
- "name": "Flora Massey"
- },
- {
- "id": 2,
- "name": "Manuela Parks"
- }
- ],
- "greeting": "Hello, Wise! You have 8 unread messages.",
- "favoriteFruit": "strawberry"
- },
- {
- "_id": "5e7a86c7b3605b4ab198b25f",
- "index": 6,
- "guid": "818a0d46-9595-4066-a819-c93979220983",
- "isActive": true,
- "balance": "$3,193.77",
- "picture": "http://placehold.it/32x32",
- "age": 30,
- "eyeColor": "brown",
- "name": {
- "first": "Baldwin",
- "last": "Mcguire"
- },
- "company": "ZILCH",
- "email": "baldwin.mcguire@zilch.io",
- "phone": "+1 (803) 562-3968",
- "address": "address replaced",
- "about": "Nostrud exercitation Lorem reprehenderit commodo aliquip. Exercitation exercitation proident aliquip et do cillum id ad ad reprehenderit ipsum elit nostrud. Occaecat velit sit commodo aliquip esse.",
- "registered": "Saturday, January 14, 2017 3:13 AM",
- "latitude": "-38.674801",
- "longitude": "78.160951",
- "tags": [
- "reprehenderit",
- "eu",
- "magna",
- "nulla",
- "non"
- ],
- "range": [
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9
- ],
- "friends": [
- {
- "id": 0,
- "name": "Austin Gonzales"
- },
- {
- "id": 1,
- "name": "Polly Mcknight"
- },
- {
- "id": 2,
- "name": "Lucy Wagner"
- }
- ],
- "greeting": "Hello, Baldwin! You have 7 unread messages.",
- "favoriteFruit": "banana"
- },
- {
- "_id": "5e7a86c700d93af1dcbe69f3",
- "index": 7,
- "guid": "09dc8fc1-207f-45f2-9d2c-f1e70e278e9a",
- "isActive": true,
- "balance": "$3,895.90",
- "picture": "http://placehold.it/32x32",
- "age": 21,
- "eyeColor": "brown",
- "name": {
- "first": "Key",
- "last": "Bolton"
- },
- "company": "MAGNINA",
- "email": "key.bolton@magnina.net",
- "phone": "+1 (918) 466-2785",
- "address": "139 Blake Court, Chautauqua, Georgia, 3570",
- "about": "Cupidatat excepteur reprehenderit eiusmod aute ea commodo ipsum pariatur dolore veniam adipisicing dolor. Excepteur ex in laborum cupidatat cillum cillum qui dolore consequat excepteur. Lorem deserunt eiusmod esse proident et ullamco reprehenderit ad ea. Cupidatat veniam deserunt magna eu labore ipsum et officia officia irure non eiusmod.",
- "registered": "Wednesday, October 5, 2016 8:28 AM",
- "latitude": "89.82294",
- "longitude": "45.807834",
- "tags": [
- "et",
- "excepteur",
- "sunt",
- "ea",
- "irure"
- ],
- "range": [
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9
- ],
- "friends": [
- {
- "id": 0,
- "name": "Farmer Adkins"
- },
- {
- "id": 1,
- "name": "Summers Huffman"
- },
- {
- "id": 2,
- "name": "Lessie Holden"
- }
- ],
- "greeting": "Hello, Key! You have 9 unread messages.",
- "favoriteFruit": "strawberry"
- },
- {
- "_id": "5e7a86c7a3fcbd25660a493d",
- "index": 8,
- "guid": "7d58a9c2-6940-499e-ba24-75227b1a09d9",
- "isActive": true,
- "balance": "$1,606.76",
- "picture": "http://placehold.it/32x32",
- "age": 31,
- "eyeColor": "green",
- "name": {
- "first": "Gonzales",
- "last": "Manning"
- },
- "company": "ORGANICA",
- "email": "gonzales.manning@organica.name",
- "phone": "+1 (993) 556-2745",
- "address": "690 Regent Place, Rodman, Marshall Islands, 7114",
- "about": "Magna ullamco voluptate nostrud et magna ea aute sint id quis proident ad excepteur ullamco. Aliquip nostrud qui quis duis occaecat commodo laborum labore aute. Mollit ullamco in qui eu voluptate dolore aute mollit sint do sit nulla aliqua. Occaecat laborum ex velit ea ex ad eiusmod enim fugiat.",
- "registered": "Monday, December 1, 2014 6:32 AM",
- "latitude": "48.780262",
- "longitude": "-75.333042",
- "tags": [
- "non",
- "laborum",
- "et",
- "Lorem",
- "id"
- ],
- "range": [
- 0,
- 1,
- 2,
- 3,
- 4,
- 5,
- 6,
- 7,
- 8,
- 9
- ],
- "friends": [
- {
- "id": 0,
- "name": "Hester Finch"
- },
- {
- "id": 1,
- "name": "Tia Cooley"
- },
- {
- "id": 2,
- "name": "Cathryn Howe"
- }
- ],
- "greeting": "Hello, Gonzales! You have 5 unread messages.",
- "favoriteFruit": "apple"
- }
-])json"
diff --git a/toolsrc/src/vcpkg-test/manifests.cpp b/toolsrc/src/vcpkg-test/manifests.cpp
deleted file mode 100644
index bbbe0c96c..000000000
--- a/toolsrc/src/vcpkg-test/manifests.cpp
+++ /dev/null
@@ -1,733 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/json.h>
-#include <vcpkg/base/util.h>
-
-#include <vcpkg/paragraphs.h>
-#include <vcpkg/sourceparagraph.h>
-#include <vcpkg/vcpkgcmdarguments.h>
-#include <vcpkg/vcpkgpaths.h>
-
-#include <vcpkg-test/util.h>
-
-#if defined(_MSC_VER)
-#pragma warning(disable : 6237)
-#endif
-
-using namespace vcpkg;
-using namespace vcpkg::Paragraphs;
-using namespace vcpkg::Test;
-
-static Json::Object parse_json_object(StringView sv)
-{
- auto json = Json::parse(sv);
- // we're not testing json parsing here, so just fail on errors
- if (auto r = json.get())
- {
- return std::move(r->first.object());
- }
- else
- {
- Checks::exit_with_message(VCPKG_LINE_INFO, json.error()->format());
- }
-}
-
-static Parse::ParseExpected<SourceControlFile> test_parse_manifest(StringView sv, bool expect_fail = false)
-{
- auto object = parse_json_object(sv);
- auto res = SourceControlFile::parse_manifest_file(fs::u8path("<test manifest>"), object);
- if (!res.has_value() && !expect_fail)
- {
- print_error_message(res.error());
- }
- REQUIRE(res.has_value() == !expect_fail);
- return res;
-}
-
-static const FeatureFlagSettings feature_flags_with_versioning{false, false, false, true};
-static const FeatureFlagSettings feature_flags_without_versioning{false, false, false, false};
-
-TEST_CASE ("manifest construct minimum", "[manifests]")
-{
- auto m_pgh = test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "1.2.8"
- })json");
-
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->name == "zlib");
- REQUIRE(pgh.core_paragraph->version == "1.2.8");
- REQUIRE(pgh.core_paragraph->maintainers.empty());
- REQUIRE(pgh.core_paragraph->description.empty());
- REQUIRE(pgh.core_paragraph->dependencies.empty());
- REQUIRE(!pgh.core_paragraph->builtin_baseline.has_value());
-
- REQUIRE(!pgh.check_against_feature_flags({}, feature_flags_without_versioning));
-}
-
-TEST_CASE ("manifest versioning", "[manifests]")
-{
- std::tuple<StringLiteral, Versions::Scheme, StringLiteral> data[] = {
- {R"json({
- "name": "zlib",
- "version-string": "abcd"
-}
-)json",
- Versions::Scheme::String,
- "abcd"},
- {R"json({
- "name": "zlib",
- "version-date": "2020-01-01"
-}
-)json",
- Versions::Scheme::Date,
- "2020-01-01"},
- {R"json({
- "name": "zlib",
- "version": "1.2.3.4.5"
-}
-)json",
- Versions::Scheme::Relaxed,
- "1.2.3.4.5"},
- {R"json({
- "name": "zlib",
- "version-semver": "1.2.3-rc3"
-}
-)json",
- Versions::Scheme::Semver,
- "1.2.3-rc3"},
- };
- for (auto v : data)
- {
- auto m_pgh = test_parse_manifest(std::get<0>(v));
-
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
- REQUIRE(Json::stringify(serialize_manifest(pgh), Json::JsonStyle::with_spaces(4)) == std::get<0>(v));
- REQUIRE(pgh.core_paragraph->version_scheme == std::get<1>(v));
- REQUIRE(pgh.core_paragraph->version == std::get<2>(v));
- }
-
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd",
- "version-semver": "1.2.3-rc3"
- })json",
- true);
-
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd#1"
- })json",
- true);
- test_parse_manifest(R"json({
- "name": "zlib",
- "version": "abcd#1"
- })json",
- true);
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-date": "abcd#1"
- })json",
- true);
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-semver": "abcd#1"
- })json",
- true);
-
- SECTION ("version syntax")
- {
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-semver": "2020-01-01"
- })json",
- true);
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-date": "1.1.1"
- })json",
- true);
- test_parse_manifest(R"json({
- "name": "zlib",
- "version": "1.2.3-rc3"
- })json",
- true);
- }
-}
-
-TEST_CASE ("manifest constraints hash", "[manifests]")
-{
- auto p = unwrap(test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd",
- "dependencies": [
- {
- "name": "d",
- "version>=": "2018-09-01#1"
- }
- ]
-})json"));
- REQUIRE(p->core_paragraph->dependencies.at(0).constraint.value == "2018-09-01");
- REQUIRE(p->core_paragraph->dependencies.at(0).constraint.port_version == 1);
-
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd",
- "dependencies": [
- {
- "name": "d",
- "version>=": "2018-09-01#0"
- }
- ]
-})json",
- true);
-
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd",
- "dependencies": [
- {
- "name": "d",
- "version>=": "2018-09-01#-1"
- }
- ]
-})json",
- true);
-
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd",
- "dependencies": [
- {
- "name": "d",
- "version>=": "2018-09-01",
- "port-version": 1
- }
- ]
-})json",
- true);
-}
-
-TEST_CASE ("manifest overrides error hash", "[manifests]")
-{
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd",
- "overrides": [
- {
- "name": "d",
- "version-string": "abcd#1"
- }
- ]
-})json",
- true);
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd",
- "overrides": [
- {
- "name": "d",
- "version-date": "2018-01-01#1"
- }
- ]
-})json",
- true);
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd",
- "overrides": [
- {
- "name": "d",
- "version": "1.2#1"
- }
- ]
-})json",
- true);
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd",
- "overrides": [
- {
- "name": "d",
- "version-semver": "1.2#1"
- }
- ]
-})json",
- true);
-}
-
-TEST_CASE ("manifest constraints", "[manifests]")
-{
- std::string raw = R"json({
- "name": "zlib",
- "version-string": "abcd",
- "builtin-baseline": "089fa4de7dca22c67dcab631f618d5cd0697c8d4",
- "dependencies": [
- "a",
- {
- "$extra": null,
- "name": "c"
- },
- {
- "name": "d",
- "version>=": "2018-09-01"
- }
- ]
-}
-)json";
- auto m_pgh = test_parse_manifest(raw);
-
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
- REQUIRE(pgh.check_against_feature_flags({}, feature_flags_without_versioning));
- REQUIRE(!pgh.check_against_feature_flags({}, feature_flags_with_versioning));
- REQUIRE(Json::stringify(serialize_manifest(pgh), Json::JsonStyle::with_spaces(4)) == raw);
- REQUIRE(pgh.core_paragraph->dependencies.size() == 3);
- REQUIRE(pgh.core_paragraph->dependencies[0].name == "a");
- REQUIRE(pgh.core_paragraph->dependencies[0].constraint ==
- DependencyConstraint{Versions::Constraint::Type::None, "", 0});
- REQUIRE(pgh.core_paragraph->dependencies[1].name == "c");
- REQUIRE(pgh.core_paragraph->dependencies[1].constraint ==
- DependencyConstraint{Versions::Constraint::Type::None, "", 0});
- REQUIRE(pgh.core_paragraph->dependencies[2].name == "d");
- REQUIRE(pgh.core_paragraph->dependencies[2].constraint ==
- DependencyConstraint{Versions::Constraint::Type::Minimum, "2018-09-01", 0});
- REQUIRE(pgh.core_paragraph->builtin_baseline == "089fa4de7dca22c67dcab631f618d5cd0697c8d4");
-
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd",
- "dependencies": [
- {
- "name": "d",
- "port-version": 5
- }
- ]
- })json",
- true);
-}
-
-TEST_CASE ("manifest builtin-baseline", "[manifests]")
-{
- SECTION ("valid baseline")
- {
- std::string raw = R"json({
- "name": "zlib",
- "version-string": "abcd",
- "builtin-baseline": "089fa4de7dca22c67dcab631f618d5cd0697c8d4"
-}
-)json";
- auto m_pgh = test_parse_manifest(raw);
-
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
- REQUIRE(pgh.check_against_feature_flags({}, feature_flags_without_versioning));
- REQUIRE(!pgh.check_against_feature_flags({}, feature_flags_with_versioning));
- REQUIRE(pgh.core_paragraph->builtin_baseline.value_or("does not have a value") ==
- "089fa4de7dca22c67dcab631f618d5cd0697c8d4");
- }
-
- SECTION ("empty baseline")
- {
- std::string raw = R"json({
- "name": "zlib",
- "version-string": "abcd",
- "builtin-baseline": ""
-}
-)json";
-
- auto m_pgh = test_parse_manifest(raw);
-
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
- REQUIRE(pgh.check_against_feature_flags({}, feature_flags_without_versioning));
- REQUIRE(!pgh.check_against_feature_flags({}, feature_flags_with_versioning));
- REQUIRE(pgh.core_paragraph->builtin_baseline.value_or("does not have a value") == "");
- }
-}
-
-TEST_CASE ("manifest overrides", "[manifests]")
-{
- std::tuple<StringLiteral, Versions::Scheme, StringLiteral> data[] = {
- {R"json({
- "name": "zlib",
- "version-date": "2020-01-01",
- "overrides": [
- {
- "name": "abc",
- "version-string": "abcd"
- }
- ]
-}
-)json",
- Versions::Scheme::String,
- "abcd"},
- {R"json({
- "name": "zlib",
- "version": "1.2.3.4.5",
- "overrides": [
- {
- "name": "abc",
- "version-date": "2020-01-01"
- }
- ]
-}
-)json",
- Versions::Scheme::Date,
- "2020-01-01"},
- {R"json({
- "name": "zlib",
- "version-date": "2020-01-01",
- "overrides": [
- {
- "name": "abc",
- "version": "1.2.3.4.5"
- }
- ]
-}
-)json",
- Versions::Scheme::Relaxed,
- "1.2.3.4.5"},
- {R"json({
- "name": "zlib",
- "version-date": "2020-01-01",
- "overrides": [
- {
- "name": "abc",
- "version-semver": "1.2.3-rc3"
- }
- ]
-}
-)json",
- Versions::Scheme::Semver,
- "1.2.3-rc3"},
- };
- for (auto v : data)
- {
- auto m_pgh = test_parse_manifest(std::get<0>(v));
-
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
- REQUIRE(Json::stringify(serialize_manifest(pgh), Json::JsonStyle::with_spaces(4)) == std::get<0>(v));
- REQUIRE(pgh.core_paragraph->overrides.size() == 1);
- REQUIRE(pgh.core_paragraph->overrides[0].version_scheme == std::get<1>(v));
- REQUIRE(pgh.core_paragraph->overrides[0].version == std::get<2>(v));
- REQUIRE(pgh.check_against_feature_flags({}, feature_flags_without_versioning));
- REQUIRE(!pgh.check_against_feature_flags({}, feature_flags_with_versioning));
- }
-
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd",
- "overrides": [
- {
- "name": "abc",
- "version-semver": "1.2.3-rc3",
- "version-string": "1.2.3-rc3"
- }
- ]})json",
- true);
-
- test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "abcd",
- "overrides": [
- {
- "name": "abc",
- "port-version": 5
- }
- ]})json",
- true);
-
- std::string raw = R"json({
- "name": "zlib",
- "version-string": "abcd",
- "overrides": [
- {
- "name": "abc",
- "version-string": "hello",
- "port-version": 5
- },
- {
- "name": "abcd",
- "version-string": "hello",
- "port-version": 7
- }
- ]
-}
-)json";
- auto m_pgh = test_parse_manifest(raw);
-
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
- REQUIRE(Json::stringify(serialize_manifest(pgh), Json::JsonStyle::with_spaces(4)) == raw);
- REQUIRE(pgh.core_paragraph->overrides.size() == 2);
- REQUIRE(pgh.core_paragraph->overrides[0].name == "abc");
- REQUIRE(pgh.core_paragraph->overrides[0].port_version == 5);
- REQUIRE(pgh.core_paragraph->overrides[1].name == "abcd");
- REQUIRE(pgh.core_paragraph->overrides[1].port_version == 7);
-
- REQUIRE(pgh.check_against_feature_flags({}, feature_flags_without_versioning));
- REQUIRE(!pgh.check_against_feature_flags({}, feature_flags_with_versioning));
-}
-
-TEST_CASE ("manifest construct maximum", "[manifests]")
-{
- auto m_pgh = test_parse_manifest(R"json({
- "name": "s",
- "version-string": "v",
- "maintainers": ["m"],
- "description": "d",
- "dependencies": ["bd"],
- "default-features": ["df"],
- "features": [
- {
- "name": "iroh",
- "description": "zuko's uncle",
- "dependencies": [
- "firebending",
- {
- "name": "tea"
- },
- {
- "name": "order.white-lotus",
- "features": [ "the-ancient-ways" ],
- "platform": "!(windows & arm)"
- }
- ]
- },
- {
- "name": "zuko",
- "description": ["son of the fire lord", "firebending 師父"]
- }
- ]
- })json");
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->name == "s");
- REQUIRE(pgh.core_paragraph->version == "v");
- REQUIRE(pgh.core_paragraph->maintainers.size() == 1);
- REQUIRE(pgh.core_paragraph->maintainers[0] == "m");
- REQUIRE(pgh.core_paragraph->description.size() == 1);
- REQUIRE(pgh.core_paragraph->description[0] == "d");
- REQUIRE(pgh.core_paragraph->dependencies.size() == 1);
- REQUIRE(pgh.core_paragraph->dependencies[0].name == "bd");
- REQUIRE(pgh.core_paragraph->default_features.size() == 1);
- REQUIRE(pgh.core_paragraph->default_features[0] == "df");
-
- REQUIRE(pgh.feature_paragraphs.size() == 2);
-
- REQUIRE(pgh.feature_paragraphs[0]->name == "iroh");
- REQUIRE(pgh.feature_paragraphs[0]->description.size() == 1);
- REQUIRE(pgh.feature_paragraphs[0]->description[0] == "zuko's uncle");
- REQUIRE(pgh.feature_paragraphs[0]->dependencies.size() == 3);
- REQUIRE(pgh.feature_paragraphs[0]->dependencies[0].name == "firebending");
-
- REQUIRE(pgh.feature_paragraphs[0]->dependencies[1].name == "order.white-lotus");
- REQUIRE(pgh.feature_paragraphs[0]->dependencies[1].features.size() == 1);
- REQUIRE(pgh.feature_paragraphs[0]->dependencies[1].features[0] == "the-ancient-ways");
- REQUIRE_FALSE(pgh.feature_paragraphs[0]->dependencies[1].platform.evaluate(
- {{"VCPKG_CMAKE_SYSTEM_NAME", ""}, {"VCPKG_TARGET_ARCHITECTURE", "arm"}}));
- REQUIRE(pgh.feature_paragraphs[0]->dependencies[1].platform.evaluate(
- {{"VCPKG_CMAKE_SYSTEM_NAME", ""}, {"VCPKG_TARGET_ARCHITECTURE", "x86"}}));
- REQUIRE(pgh.feature_paragraphs[0]->dependencies[1].platform.evaluate(
- {{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}, {"VCPKG_TARGET_ARCHITECTURE", "x86"}}));
-
- REQUIRE(pgh.feature_paragraphs[0]->dependencies[2].name == "tea");
-
- REQUIRE(pgh.feature_paragraphs[1]->name == "zuko");
- REQUIRE(pgh.feature_paragraphs[1]->description.size() == 2);
- REQUIRE(pgh.feature_paragraphs[1]->description[0] == "son of the fire lord");
- REQUIRE(pgh.feature_paragraphs[1]->description[1] == "firebending 師父");
-
- REQUIRE(!pgh.check_against_feature_flags({}, feature_flags_without_versioning));
-}
-
-TEST_CASE ("SourceParagraph manifest two dependencies", "[manifests]")
-{
- auto m_pgh = test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "1.2.8",
- "dependencies": ["z", "openssl"]
- })json");
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->dependencies.size() == 2);
- REQUIRE(pgh.core_paragraph->dependencies[0].name == "openssl");
- REQUIRE(pgh.core_paragraph->dependencies[1].name == "z");
-}
-
-TEST_CASE ("SourceParagraph manifest three dependencies", "[manifests]")
-{
- auto m_pgh = test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "1.2.8",
- "dependencies": ["z", "openssl", "xyz"]
- })json");
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->dependencies.size() == 3);
- // should be ordered
- REQUIRE(pgh.core_paragraph->dependencies[0].name == "openssl");
- REQUIRE(pgh.core_paragraph->dependencies[1].name == "xyz");
- REQUIRE(pgh.core_paragraph->dependencies[2].name == "z");
-}
-
-TEST_CASE ("SourceParagraph manifest construct qualified dependencies", "[manifests]")
-{
- auto m_pgh = test_parse_manifest(R"json({
- "name": "zlib",
- "version-string": "1.2.8",
- "dependencies": [
- {
- "name": "liba",
- "platform": "windows"
- },
- {
- "name": "libb",
- "platform": "uwp"
- }
- ]
- })json");
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->name == "zlib");
- REQUIRE(pgh.core_paragraph->version == "1.2.8");
- REQUIRE(pgh.core_paragraph->maintainers.empty());
- REQUIRE(pgh.core_paragraph->description.empty());
- REQUIRE(pgh.core_paragraph->dependencies.size() == 2);
- REQUIRE(pgh.core_paragraph->dependencies[0].name == "liba");
- REQUIRE(pgh.core_paragraph->dependencies[0].platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}}));
- REQUIRE(pgh.core_paragraph->dependencies[1].name == "libb");
- REQUIRE(pgh.core_paragraph->dependencies[1].platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "WindowsStore"}}));
-}
-
-TEST_CASE ("SourceParagraph manifest default features", "[manifests]")
-{
- auto m_pgh = test_parse_manifest(R"json({
- "name": "a",
- "version-string": "1.0",
- "default-features": ["a1"]
- })json");
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->default_features.size() == 1);
- REQUIRE(pgh.core_paragraph->default_features[0] == "a1");
-}
-
-TEST_CASE ("SourceParagraph manifest description paragraph", "[manifests]")
-{
- auto m_pgh = test_parse_manifest(R"json({
- "name": "a",
- "version-string": "1.0",
- "description": ["line 1", "line 2", "line 3"]
- })json");
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->description.size() == 3);
- REQUIRE(pgh.core_paragraph->description[0] == "line 1");
- REQUIRE(pgh.core_paragraph->description[1] == "line 2");
- REQUIRE(pgh.core_paragraph->description[2] == "line 3");
-}
-
-TEST_CASE ("SourceParagraph manifest supports", "[manifests]")
-{
- auto m_pgh = test_parse_manifest(R"json({
- "name": "a",
- "version-string": "1.0",
- "supports": "!(windows | osx)"
- })json");
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->supports_expression.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}}));
- REQUIRE_FALSE(pgh.core_paragraph->supports_expression.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}}));
- REQUIRE_FALSE(pgh.core_paragraph->supports_expression.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Darwin"}}));
-}
-
-TEST_CASE ("SourceParagraph manifest empty supports", "[manifests]")
-{
- auto m_pgh = test_parse_manifest(R"json({
- "name": "a",
- "version-string": "1.0",
- "supports": ""
- })json",
- true);
- REQUIRE_FALSE(m_pgh.has_value());
-}
-
-TEST_CASE ("SourceParagraph manifest non-string supports", "[manifests]")
-{
- auto m_pgh = test_parse_manifest(R"json({
- "name": "a",
- "version-string": "1.0",
- "supports": true
- })json",
- true);
- REQUIRE_FALSE(m_pgh.has_value());
-}
-
-TEST_CASE ("Serialize all the ports", "[manifests]")
-{
- std::vector<std::string> args_list = {"format-manifest"};
- auto& fs = Files::get_real_filesystem();
- auto args = VcpkgCmdArguments::create_from_arg_sequence(args_list.data(), args_list.data() + args_list.size());
- args.imbue_from_environment();
- VcpkgPaths paths{fs, args};
-
- std::vector<SourceControlFile> scfs;
-
- for (auto dir : fs::directory_iterator(paths.builtin_ports_directory()))
- {
- const auto control = dir / fs::u8path("CONTROL");
- const auto manifest = dir / fs::u8path("vcpkg.json");
- if (fs.exists(control))
- {
- INFO(fs::u8string(control));
- auto contents = fs.read_contents(control, VCPKG_LINE_INFO);
- auto pghs = Paragraphs::parse_paragraphs(contents, fs::u8string(control));
- REQUIRE(pghs);
-
- auto scf = SourceControlFile::parse_control_file(fs::u8string(control),
- std::move(pghs).value_or_exit(VCPKG_LINE_INFO));
- if (!scf)
- {
- INFO(scf.error()->name);
- INFO(scf.error()->error);
- REQUIRE(scf);
- }
-
- scfs.push_back(std::move(*scf.value_or_exit(VCPKG_LINE_INFO)));
- }
- else if (fs.exists(manifest))
- {
- std::error_code ec;
- auto contents = Json::parse_file(fs, manifest, ec);
- REQUIRE_FALSE(ec);
- REQUIRE(contents);
-
- auto scf = SourceControlFile::parse_manifest_file(manifest,
- contents.value_or_exit(VCPKG_LINE_INFO).first.object());
- REQUIRE(scf);
-
- scfs.push_back(std::move(*scf.value_or_exit(VCPKG_LINE_INFO)));
- }
- }
-
- for (auto& scf : scfs)
- {
- auto serialized = serialize_manifest(scf);
- auto serialized_scf = SourceControlFile::parse_manifest_file({}, serialized).value_or_exit(VCPKG_LINE_INFO);
-
- REQUIRE(*serialized_scf == scf);
- }
-}
diff --git a/toolsrc/src/vcpkg-test/mockcmakevarsprovider.cpp b/toolsrc/src/vcpkg-test/mockcmakevarsprovider.cpp
deleted file mode 100644
index 77a796fad..000000000
--- a/toolsrc/src/vcpkg-test/mockcmakevarsprovider.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <vcpkg-test/mockcmakevarprovider.h>
-
-namespace vcpkg::Test
-{
- Optional<const std::unordered_map<std::string, std::string>&> MockCMakeVarProvider::get_generic_triplet_vars(
- 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;
- }
-}
diff --git a/toolsrc/src/vcpkg-test/optional.cpp b/toolsrc/src/vcpkg-test/optional.cpp
deleted file mode 100644
index f18efb359..000000000
--- a/toolsrc/src/vcpkg-test/optional.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/lineinfo.h>
-#include <vcpkg/base/optional.h>
-#include <vcpkg/base/util.h>
-
-#include <vector>
-
-namespace
-{
- struct identity_projection
- {
- template<class T>
- const T& operator()(const T& val) noexcept
- {
- return val;
- }
- };
-}
-
-TEST_CASE ("equal", "[optional]")
-{
- using vcpkg::Optional;
-
- CHECK(Optional<int>{} == Optional<int>{});
- CHECK_FALSE(Optional<int>{} == Optional<int>{42});
- CHECK_FALSE(Optional<int>{42} == Optional<int>{});
- CHECK_FALSE(Optional<int>{1729} == Optional<int>{42});
- CHECK(Optional<int>{42} == Optional<int>{42});
-}
-
-TEST_CASE ("ref conversion", "[optional]")
-{
- using vcpkg::Optional;
-
- Optional<int> i_empty;
- Optional<int> i_1 = 1;
- const Optional<int> ci_1 = 1;
-
- Optional<int&> ref_empty = i_empty;
- Optional<const int&> cref_empty = i_empty;
-
- Optional<int&> ref_1 = i_1;
- Optional<const int&> cref_1 = ci_1;
-
- REQUIRE(ref_empty.has_value() == false);
- REQUIRE(cref_empty.has_value() == false);
-
- REQUIRE(ref_1.get() == i_1.get());
- REQUIRE(cref_1.get() == ci_1.get());
-
- ref_empty = i_1;
- cref_empty = ci_1;
- REQUIRE(ref_empty.get() == i_1.get());
- REQUIRE(cref_empty.get() == ci_1.get());
-
- const int x = 5;
- cref_1 = x;
- REQUIRE(cref_1.get() == &x);
-}
-
-TEST_CASE ("value conversion", "[optional]")
-{
- using vcpkg::Optional;
-
- Optional<long> j = 1;
- Optional<int> i = j;
- Optional<const char*> cstr = "hello, world!";
- Optional<std::string> cppstr = cstr;
-
- std::vector<int> v{1, 2, 3};
- Optional<std::vector<int>&> o_v(v);
- REQUIRE(o_v.has_value());
- REQUIRE(o_v.get()->size() == 3);
- Optional<std::vector<int>> o_w(std::move(o_v));
- REQUIRE(o_w.has_value());
- REQUIRE(o_w.get()->size() == 3);
- // Moving from Optional<&> should not move the underlying object
- REQUIRE(o_v.has_value());
- REQUIRE(o_v.get()->size() == 3);
-}
-
-TEST_CASE ("optional.map", "[optional]")
-{
- using vcpkg::NullOpt;
- using vcpkg::nullopt;
- using vcpkg::Optional;
-
- const Optional<std::unique_ptr<int>> move_only;
-
- Optional<int*> m = move_only.map([](auto&& p) { return p.get(); });
- Optional<Optional<int*>> n =
- move_only.map([](auto&& p) -> Optional<int*> { return p ? Optional<int*>{p.get()} : nullopt; });
- Optional<NullOpt> o = move_only.map([](auto&&) { return nullopt; });
-
- Optional<int> five = 5;
-
- struct MoveTest
- {
- int operator()(int&&) { return 1; }
- int operator()(const int&) { return -1; }
- } move_test;
-
- Optional<int> dst = std::move(five).map(move_test);
- REQUIRE(dst == 1);
- Optional<int> dst2 = five.map(move_test);
- REQUIRE(dst2 == -1);
-}
-
-TEST_CASE ("common_projection", "[optional]")
-{
- using vcpkg::Util::common_projection;
- std::vector<int> input;
- CHECK(!common_projection(input, identity_projection{}).has_value());
- input.push_back(42);
- CHECK(common_projection(input, identity_projection{}).value_or_exit(VCPKG_LINE_INFO) == 42);
- input.push_back(42);
- CHECK(common_projection(input, identity_projection{}).value_or_exit(VCPKG_LINE_INFO) == 42);
- input.push_back(1729);
- CHECK(!common_projection(input, identity_projection{}).has_value());
-}
diff --git a/toolsrc/src/vcpkg-test/paragraph.cpp b/toolsrc/src/vcpkg-test/paragraph.cpp
deleted file mode 100644
index cb3f8e620..000000000
--- a/toolsrc/src/vcpkg-test/paragraph.cpp
+++ /dev/null
@@ -1,516 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/strings.h>
-
-#include <vcpkg/paragraphs.h>
-
-#include <vcpkg-test/util.h>
-
-namespace Strings = vcpkg::Strings;
-using vcpkg::Parse::Paragraph;
-
-namespace
-{
- auto test_parse_control_file(const std::vector<std::unordered_map<std::string, std::string>>& v)
- {
- std::vector<Paragraph> pghs;
- for (auto&& p : v)
- {
- pghs.emplace_back();
- for (auto&& kv : p)
- pghs.back().emplace(kv.first, std::make_pair(kv.second, vcpkg::Parse::TextRowCol{}));
- }
- return vcpkg::SourceControlFile::parse_control_file("", std::move(pghs));
- }
-
- auto test_make_binary_paragraph(const std::unordered_map<std::string, std::string>& v)
- {
- Paragraph pgh;
- for (auto&& kv : v)
- pgh.emplace(kv.first, std::make_pair(kv.second, vcpkg::Parse::TextRowCol{}));
-
- return vcpkg::BinaryParagraph(std::move(pgh));
- }
-
-}
-
-TEST_CASE ("SourceParagraph construct minimum", "[paragraph]")
-{
- auto m_pgh = test_parse_control_file({{
- {"Source", "zlib"},
- {"Version", "1.2.8"},
- }});
-
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->name == "zlib");
- REQUIRE(pgh.core_paragraph->version == "1.2.8");
- REQUIRE(pgh.core_paragraph->maintainers.empty());
- REQUIRE(pgh.core_paragraph->description.empty());
- REQUIRE(pgh.core_paragraph->dependencies.size() == 0);
-}
-
-TEST_CASE ("SourceParagraph construct invalid", "[paragraph]")
-{
- auto m_pgh = test_parse_control_file({{
- {"Source", "zlib"},
- {"Version", "1.2.8"},
- {"Build-Depends", "1.2.8"},
- }});
-
- REQUIRE(!m_pgh.has_value());
- REQUIRE(m_pgh.error()->has_error());
-
- m_pgh = test_parse_control_file({{
- {"Source", "zlib"},
- {"Version", "1.2.8"},
- {"Default-Features", "1.2.8"},
- }});
-
- REQUIRE(!m_pgh.has_value());
- REQUIRE(m_pgh.error()->has_error());
-
- m_pgh = test_parse_control_file({
- {
- {"Source", "zlib"},
- {"Version", "1.2.8"},
- },
- {
- {"Feature", "a"},
- {"Build-Depends", "1.2.8"},
- },
- });
-
- REQUIRE(!m_pgh.has_value());
- REQUIRE(m_pgh.error()->has_error());
-
- // invalid field`s name
- m_pgh = test_parse_control_file({{
- {"Surce", "zlib"},
- {"Vursion", "1.2.8"},
- }});
-
- REQUIRE(!m_pgh.has_value());
- REQUIRE(m_pgh.error()->has_error());
-}
-
-TEST_CASE ("SourceParagraph construct maximum", "[paragraph]")
-{
- auto m_pgh = test_parse_control_file({{
- {"Source", "s"},
- {"Version", "v"},
- {"Maintainer", "m"},
- {"Description", "d"},
- {"Build-Depends", "bd"},
- {"Default-Features", "df"},
- }});
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->name == "s");
- REQUIRE(pgh.core_paragraph->version == "v");
- REQUIRE(pgh.core_paragraph->maintainers.size() == 1);
- REQUIRE(pgh.core_paragraph->maintainers[0] == "m");
- REQUIRE(pgh.core_paragraph->description.size() == 1);
- REQUIRE(pgh.core_paragraph->description[0] == "d");
- REQUIRE(pgh.core_paragraph->dependencies.size() == 1);
- REQUIRE(pgh.core_paragraph->dependencies[0].name == "bd");
- REQUIRE(pgh.core_paragraph->default_features.size() == 1);
- REQUIRE(pgh.core_paragraph->default_features[0] == "df");
-}
-
-TEST_CASE ("SourceParagraph construct feature", "[paragraph]")
-{
- auto m_pgh = test_parse_control_file({
- {
- {"Source", "s"},
- {"Version", "v"},
- },
- {{"Feature", "f"}, {"Description", "d2"}, {"Build-Depends", "bd2"}},
- });
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.feature_paragraphs.size() == 1);
- REQUIRE(pgh.feature_paragraphs[0]->name == "f");
- REQUIRE(pgh.feature_paragraphs[0]->description == std::vector<std::string>{"d2"});
- REQUIRE(pgh.feature_paragraphs[0]->dependencies.size() == 1);
-}
-
-TEST_CASE ("SourceParagraph two dependencies", "[paragraph]")
-{
- auto m_pgh = test_parse_control_file({{
- {"Source", "zlib"},
- {"Version", "1.2.8"},
- {"Build-Depends", "z, openssl"},
- }});
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->dependencies.size() == 2);
- // should be ordered
- REQUIRE(pgh.core_paragraph->dependencies[0].name == "openssl");
- REQUIRE(pgh.core_paragraph->dependencies[1].name == "z");
-}
-
-TEST_CASE ("SourceParagraph three dependencies", "[paragraph]")
-{
- auto m_pgh = test_parse_control_file({{
- {"Source", "zlib"},
- {"Version", "1.2.8"},
- {"Build-Depends", "z, openssl, xyz"},
- }});
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->dependencies.size() == 3);
- // should be ordered
- REQUIRE(pgh.core_paragraph->dependencies[0].name == "openssl");
- REQUIRE(pgh.core_paragraph->dependencies[1].name == "xyz");
- REQUIRE(pgh.core_paragraph->dependencies[2].name == "z");
-}
-
-TEST_CASE ("SourceParagraph construct qualified dependencies", "[paragraph]")
-{
- auto m_pgh = test_parse_control_file({{
- {"Source", "zlib"},
- {"Version", "1.2.8"},
- {"Build-Depends", "liba (windows), libb (uwp)"},
- }});
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->name == "zlib");
- REQUIRE(pgh.core_paragraph->version == "1.2.8");
- REQUIRE(pgh.core_paragraph->maintainers.empty());
- REQUIRE(pgh.core_paragraph->description.empty());
- REQUIRE(pgh.core_paragraph->dependencies.size() == 2);
- REQUIRE(pgh.core_paragraph->dependencies[0].name == "liba");
- REQUIRE(pgh.core_paragraph->dependencies[0].platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}}));
- REQUIRE(pgh.core_paragraph->dependencies[1].name == "libb");
- REQUIRE(pgh.core_paragraph->dependencies[1].platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "WindowsStore"}}));
-}
-
-TEST_CASE ("SourceParagraph default features", "[paragraph]")
-{
- auto m_pgh = test_parse_control_file({{
- {"Source", "a"},
- {"Version", "1.0"},
- {"Default-Features", "a1"},
- }});
- REQUIRE(m_pgh.has_value());
- auto& pgh = **m_pgh.get();
-
- REQUIRE(pgh.core_paragraph->default_features.size() == 1);
- REQUIRE(pgh.core_paragraph->default_features[0] == "a1");
-}
-
-TEST_CASE ("BinaryParagraph construct minimum", "[paragraph]")
-{
- auto pgh = test_make_binary_paragraph({
- {"Package", "zlib"},
- {"Version", "1.2.8"},
- {"Architecture", "x86-windows"},
- {"Multi-Arch", "same"},
- });
-
- REQUIRE(pgh.spec.name() == "zlib");
- REQUIRE(pgh.version == "1.2.8");
- REQUIRE(pgh.maintainers.empty());
- REQUIRE(pgh.description.empty());
- REQUIRE(pgh.spec.triplet().canonical_name() == "x86-windows");
- REQUIRE(pgh.dependencies.size() == 0);
-}
-
-TEST_CASE ("BinaryParagraph construct maximum", "[paragraph]")
-{
- auto pgh = test_make_binary_paragraph({
- {"Package", "s"},
- {"Version", "v"},
- {"Architecture", "x86-windows"},
- {"Multi-Arch", "same"},
- {"Maintainer", "m"},
- {"Description", "d"},
- {"Depends", "bd"},
- });
-
- REQUIRE(pgh.spec.name() == "s");
- REQUIRE(pgh.version == "v");
- REQUIRE(pgh.maintainers.size() == 1);
- REQUIRE(pgh.maintainers[0] == "m");
- REQUIRE(pgh.description.size() == 1);
- REQUIRE(pgh.description[0] == "d");
- REQUIRE(pgh.dependencies.size() == 1);
- REQUIRE(pgh.dependencies[0] == "bd");
-}
-
-TEST_CASE ("BinaryParagraph three dependencies", "[paragraph]")
-{
- auto pgh = test_make_binary_paragraph({
- {"Package", "zlib"},
- {"Version", "1.2.8"},
- {"Architecture", "x86-windows"},
- {"Multi-Arch", "same"},
- {"Depends", "a, b, c"},
- });
-
- REQUIRE(pgh.dependencies.size() == 3);
- REQUIRE(pgh.dependencies[0] == "a");
- REQUIRE(pgh.dependencies[1] == "b");
- REQUIRE(pgh.dependencies[2] == "c");
-}
-
-TEST_CASE ("BinaryParagraph abi", "[paragraph]")
-{
- auto pgh = test_make_binary_paragraph({
- {"Package", "zlib"},
- {"Version", "1.2.8"},
- {"Architecture", "x86-windows"},
- {"Multi-Arch", "same"},
- {"Abi", "abcd123"},
- });
-
- REQUIRE(pgh.dependencies.size() == 0);
- REQUIRE(pgh.abi == "abcd123");
-}
-
-TEST_CASE ("BinaryParagraph default features", "[paragraph]")
-{
- auto pgh = test_make_binary_paragraph({
- {"Package", "a"},
- {"Version", "1.0"},
- {"Architecture", "x86-windows"},
- {"Multi-Arch", "same"},
- {"Default-Features", "a1"},
- });
-
- REQUIRE(pgh.dependencies.size() == 0);
- REQUIRE(pgh.default_features.size() == 1);
- REQUIRE(pgh.default_features[0] == "a1");
-}
-
-TEST_CASE ("parse paragraphs empty", "[paragraph]")
-{
- const char* str = "";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str, "").value_or_exit(VCPKG_LINE_INFO);
- REQUIRE(pghs.empty());
-}
-
-TEST_CASE ("parse paragraphs one field", "[paragraph]")
-{
- const char* str = "f1: v1";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str, "").value_or_exit(VCPKG_LINE_INFO);
- REQUIRE(pghs.size() == 1);
- REQUIRE(pghs[0].size() == 1);
- REQUIRE(pghs[0]["f1"].first == "v1");
-}
-
-TEST_CASE ("parse paragraphs one pgh", "[paragraph]")
-{
- const char* str = "f1: v1\n"
- "f2: v2";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str, "").value_or_exit(VCPKG_LINE_INFO);
- REQUIRE(pghs.size() == 1);
- REQUIRE(pghs[0].size() == 2);
- REQUIRE(pghs[0]["f1"].first == "v1");
- REQUIRE(pghs[0]["f2"].first == "v2");
-}
-
-TEST_CASE ("parse paragraphs two pgh", "[paragraph]")
-{
- const char* str = "f1: v1\n"
- "f2: v2\n"
- "\n"
- "f3: v3\n"
- "f4: v4";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str, "").value_or_exit(VCPKG_LINE_INFO);
-
- REQUIRE(pghs.size() == 2);
- REQUIRE(pghs[0].size() == 2);
- REQUIRE(pghs[0]["f1"].first == "v1");
- REQUIRE(pghs[0]["f2"].first == "v2");
- REQUIRE(pghs[1].size() == 2);
- REQUIRE(pghs[1]["f3"].first == "v3");
- REQUIRE(pghs[1]["f4"].first == "v4");
-}
-
-TEST_CASE ("parse paragraphs field names", "[paragraph]")
-{
- const char* str = "1:\n"
- "f:\n"
- "F:\n"
- "0:\n"
- "F-2:\n";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str, "").value_or_exit(VCPKG_LINE_INFO);
-
- REQUIRE(pghs.size() == 1);
- REQUIRE(pghs[0].size() == 5);
-}
-
-TEST_CASE ("parse paragraphs multiple blank lines", "[paragraph]")
-{
- const char* str = "f1: v1\n"
- "f2: v2\n"
- "\n"
- "\n"
- "f3: v3\n"
- "f4: v4";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str, "").value_or_exit(VCPKG_LINE_INFO);
-
- REQUIRE(pghs.size() == 2);
-}
-
-TEST_CASE ("parse paragraphs empty fields", "[paragraph]")
-{
- const char* str = "f1:\n"
- "f2: ";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str, "").value_or_exit(VCPKG_LINE_INFO);
-
- REQUIRE(pghs.size() == 1);
- REQUIRE(pghs[0].size() == 2);
- REQUIRE(pghs[0]["f1"].first.empty());
- REQUIRE(pghs[0]["f2"].first.empty());
- REQUIRE(pghs[0].size() == 2);
-}
-
-TEST_CASE ("parse paragraphs multiline fields", "[paragraph]")
-{
- const char* str = "f1: simple\n"
- " f1\r\n"
- "f2:\r\n"
- " f2\r\n"
- " continue\r\n";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str, "").value_or_exit(VCPKG_LINE_INFO);
-
- REQUIRE(pghs.size() == 1);
- REQUIRE(pghs[0]["f1"].first == "simple\n f1");
- REQUIRE(pghs[0]["f2"].first == "\n f2\n continue");
-}
-
-TEST_CASE ("parse paragraphs crlfs", "[paragraph]")
-{
- const char* str = "f1: v1\r\n"
- "f2: v2\r\n"
- "\r\n"
- "f3: v3\r\n"
- "f4: v4";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str, "").value_or_exit(VCPKG_LINE_INFO);
-
- REQUIRE(pghs.size() == 2);
- REQUIRE(pghs[0].size() == 2);
- REQUIRE(pghs[0]["f1"].first == "v1");
- REQUIRE(pghs[0]["f2"].first == "v2");
- REQUIRE(pghs[1].size() == 2);
- REQUIRE(pghs[1]["f3"].first == "v3");
- REQUIRE(pghs[1]["f4"].first == "v4");
-}
-
-TEST_CASE ("parse paragraphs comment", "[paragraph]")
-{
- const char* str = "f1: v1\r\n"
- "#comment\r\n"
- "f2: v2\r\n"
- "#comment\r\n"
- "\r\n"
- "#comment\r\n"
- "f3: v3\r\n"
- "#comment\r\n"
- "f4: v4";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str, "").value_or_exit(VCPKG_LINE_INFO);
-
- REQUIRE(pghs.size() == 2);
- REQUIRE(pghs[0].size() == 2);
- REQUIRE(pghs[0]["f1"].first == "v1");
- REQUIRE(pghs[0]["f2"].first == "v2");
- REQUIRE(pghs[1].size());
- REQUIRE(pghs[1]["f3"].first == "v3");
- REQUIRE(pghs[1]["f4"].first == "v4");
-}
-
-TEST_CASE ("parse comment before single line feed", "[paragraph]")
-{
- const char* str = "f1: v1\r\n"
- "#comment\n";
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(str, "").value_or_exit(VCPKG_LINE_INFO);
- REQUIRE(pghs[0].size() == 1);
- REQUIRE(pghs[0]["f1"].first == "v1");
-}
-
-TEST_CASE ("BinaryParagraph serialize min", "[paragraph]")
-{
- auto pgh = test_make_binary_paragraph({
- {"Package", "zlib"},
- {"Version", "1.2.8"},
- {"Architecture", "x86-windows"},
- {"Multi-Arch", "same"},
- });
- std::string ss = Strings::serialize(pgh);
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss, "").value_or_exit(VCPKG_LINE_INFO);
-
- REQUIRE(pghs.size() == 1);
- REQUIRE(pghs[0].size() == 5);
- REQUIRE(pghs[0]["Package"].first == "zlib");
- REQUIRE(pghs[0]["Version"].first == "1.2.8");
- REQUIRE(pghs[0]["Architecture"].first == "x86-windows");
- REQUIRE(pghs[0]["Multi-Arch"].first == "same");
- REQUIRE(pghs[0]["Type"].first == "Port");
-}
-
-TEST_CASE ("BinaryParagraph serialize max", "[paragraph]")
-{
- auto pgh = test_make_binary_paragraph({
- {"Package", "zlib"},
- {"Version", "1.2.8"},
- {"Architecture", "x86-windows"},
- {"Description", "first line\n second line"},
- {"Maintainer", "abc <abc@abc.abc>"},
- {"Depends", "dep"},
- {"Multi-Arch", "same"},
- });
- std::string ss = Strings::serialize(pgh);
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss, "").value_or_exit(VCPKG_LINE_INFO);
-
- REQUIRE(pghs.size() == 1);
- REQUIRE(pghs[0].size() == 8);
- REQUIRE(pghs[0]["Package"].first == "zlib");
- REQUIRE(pghs[0]["Version"].first == "1.2.8");
- REQUIRE(pghs[0]["Architecture"].first == "x86-windows");
- REQUIRE(pghs[0]["Multi-Arch"].first == "same");
- REQUIRE(pghs[0]["Description"].first == "first line\n second line");
- REQUIRE(pghs[0]["Depends"].first == "dep");
- REQUIRE(pghs[0]["Type"].first == "Port");
-}
-
-TEST_CASE ("BinaryParagraph serialize multiple deps", "[paragraph]")
-{
- auto pgh = test_make_binary_paragraph({
- {"Package", "zlib"},
- {"Version", "1.2.8"},
- {"Architecture", "x86-windows"},
- {"Multi-Arch", "same"},
- {"Depends", "a, b, c"},
- });
- std::string ss = Strings::serialize(pgh);
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss, "").value_or_exit(VCPKG_LINE_INFO);
-
- REQUIRE(pghs.size() == 1);
- REQUIRE(pghs[0]["Depends"].first == "a, b, c");
-}
-
-TEST_CASE ("BinaryParagraph serialize abi", "[paragraph]")
-{
- auto pgh = test_make_binary_paragraph({
- {"Package", "zlib"},
- {"Version", "1.2.8"},
- {"Architecture", "x86-windows"},
- {"Multi-Arch", "same"},
- {"Depends", "a, b, c"},
- {"Abi", "123abc"},
- });
- std::string ss = Strings::serialize(pgh);
- auto pghs = vcpkg::Paragraphs::parse_paragraphs(ss, "").value_or_exit(VCPKG_LINE_INFO);
-
- REQUIRE(pghs.size() == 1);
- REQUIRE(pghs[0]["Abi"].first == "123abc");
-}
diff --git a/toolsrc/src/vcpkg-test/plan.cpp b/toolsrc/src/vcpkg-test/plan.cpp
deleted file mode 100644
index 363a2d9b4..000000000
--- a/toolsrc/src/vcpkg-test/plan.cpp
+++ /dev/null
@@ -1,1297 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/graphs.h>
-
-#include <vcpkg/dependencies.h>
-#include <vcpkg/portfileprovider.h>
-#include <vcpkg/sourceparagraph.h>
-#include <vcpkg/triplet.h>
-
-#include <memory>
-#include <unordered_map>
-#include <vector>
-
-#include <vcpkg-test/mockcmakevarprovider.h>
-#include <vcpkg-test/util.h>
-
-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;
-
-/// <summary>
-/// Assert that the given action an install of given features from given package.
-/// </summary>
-static void features_check(Dependencies::InstallPlanAction& plan,
- std::string pkg_name,
- std::vector<std::string> expected_features,
- Triplet triplet = Test::X86_WINDOWS)
-{
- 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());
-
- for (auto&& feature_name : expected_features)
- {
- // TODO: see if this can be simplified
- if (feature_name == "core" || feature_name.empty())
- {
- REQUIRE((Util::find(feature_list, "core") != feature_list.end() ||
- Util::find(feature_list, "") != feature_list.end()));
- continue;
- }
- REQUIRE(Util::find(feature_list, feature_name) != feature_list.end());
- }
-}
-
-/// <summary>
-/// Assert that the given action is a remove of given package.
-/// </summary>
-static void remove_plan_check(Dependencies::RemovePlanAction& plan,
- std::string pkg_name,
- Triplet triplet = Test::X86_WINDOWS)
-{
- REQUIRE(plan.spec.triplet().to_string() == triplet.to_string());
- REQUIRE(pkg_name == plan.spec.name());
-}
-
-TEST_CASE ("basic install scheme", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- PackageSpecMap spec_map;
- auto spec_a = spec_map.emplace("a", "b");
- auto spec_b = spec_map.emplace("b", "c");
- auto spec_c = spec_map.emplace("c");
-
- PortFileProvider::MapPortFileProvider map_port(spec_map.map);
- MockCMakeVarProvider var_provider;
-
- auto install_plan = Dependencies::create_feature_install_plan(
- map_port, var_provider, {FullPackageSpec{spec_a, {}}}, StatusParagraphs(std::move(status_paragraphs)));
-
- REQUIRE(install_plan.size() == 3);
- 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]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- PackageSpecMap spec_map;
- auto spec_a = spec_map.emplace("a", "d");
- auto spec_b = spec_map.emplace("b", "d, e");
- auto spec_c = spec_map.emplace("c", "e, h");
- auto spec_d = spec_map.emplace("d", "f, g, h");
- auto spec_e = spec_map.emplace("e", "g");
- auto spec_f = spec_map.emplace("f");
- auto spec_g = spec_map.emplace("g");
- auto spec_h = spec_map.emplace("h");
-
- PortFileProvider::MapPortFileProvider map_port(spec_map.map);
- MockCMakeVarProvider var_provider;
-
- auto install_plan = Dependencies::create_feature_install_plan(
- map_port,
- 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.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);
- const auto b_pos = iterator_pos(spec_b);
- const auto c_pos = iterator_pos(spec_c);
- const auto d_pos = iterator_pos(spec_d);
- const auto e_pos = iterator_pos(spec_e);
- const auto f_pos = iterator_pos(spec_f);
- const auto g_pos = iterator_pos(spec_g);
- const auto h_pos = iterator_pos(spec_h);
-
- REQUIRE(a_pos > d_pos);
- REQUIRE(b_pos > e_pos);
- REQUIRE(b_pos > d_pos);
- REQUIRE(c_pos > e_pos);
- REQUIRE(c_pos > h_pos);
- REQUIRE(d_pos > f_pos);
- REQUIRE(d_pos > g_pos);
- REQUIRE(d_pos > h_pos);
- REQUIRE(e_pos > g_pos);
-}
-
-TEST_CASE ("existing package scheme", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(vcpkg::Test::make_status_pgh("a"));
-
- 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(
- map_port, var_provider, {spec_a}, StatusParagraphs(std::move(status_paragraphs)));
-
- REQUIRE(install_plan.size() == 1);
- 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);
-}
-
-TEST_CASE ("user requested package scheme", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- PackageSpecMap spec_map;
- 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(
- map_port, var_provider, {spec_a}, StatusParagraphs(std::move(status_paragraphs)));
-
- REQUIRE(install_plan.size() == 2);
- 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.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);
-}
-
-TEST_CASE ("long install scheme", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(make_status_pgh("j", "k"));
- status_paragraphs.push_back(make_status_pgh("k"));
-
- PackageSpecMap spec_map;
-
- auto spec_a = spec_map.emplace("a", "b, c, d, e, f, g, h, j, k");
- auto spec_b = spec_map.emplace("b", "c, d, e, f, g, h, j, k");
- auto spec_c = spec_map.emplace("c", "d, e, f, g, h, j, k");
- auto spec_d = spec_map.emplace("d", "e, f, g, h, j, k");
- auto spec_e = spec_map.emplace("e", "f, g, h, j, k");
- auto spec_f = spec_map.emplace("f", "g, h, j, k");
- auto spec_g = spec_map.emplace("g", "h, j, k");
- auto spec_h = spec_map.emplace("h", "j, k");
- auto spec_j = spec_map.emplace("j", "k");
- auto spec_k = spec_map.emplace("k");
-
- 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");
-}
-
-TEST_CASE ("basic feature test 1", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(make_status_pgh("a", "b, b[b1]"));
- status_paragraphs.push_back(make_status_pgh("b"));
- status_paragraphs.push_back(make_status_feature_pgh("b", "b1"));
-
- PackageSpecMap spec_map;
- 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", ""}})};
-
- 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)));
-
- 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]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- PackageSpecMap spec_map;
-
- 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", ""}})};
-
- 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"});
-}
-
-TEST_CASE ("basic feature test 3", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(make_status_pgh("a"));
-
- PackageSpecMap spec_map;
-
- auto spec_a = FullPackageSpec{spec_map.emplace("a", "b", {{"a1", ""}}), {"core"}};
- 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 plan = Dependencies::create_feature_install_plan(
- map_port, var_provider, {spec_c, spec_a}, StatusParagraphs(std::move(status_paragraphs)));
-
- 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]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(make_status_pgh("a"));
- status_paragraphs.push_back(make_status_feature_pgh("a", "a1", ""));
-
- PackageSpecMap spec_map;
-
- auto spec_a = FullPackageSpec{spec_map.emplace("a", "b", {{"a1", ""}})};
- 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(
- map_port, var_provider, {spec_c}, StatusParagraphs(std::move(status_paragraphs)));
-
- REQUIRE(install_plan.size() == 1);
- features_check(install_plan.install_actions.at(0), "c", {"core"});
-}
-
-TEST_CASE ("basic feature test 5", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- PackageSpecMap spec_map;
-
- auto spec_a =
- 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(
- map_port, var_provider, {spec_a}, StatusParagraphs(std::move(status_paragraphs)));
-
- REQUIRE(install_plan.size() == 2);
- 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]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(make_status_pgh("b"));
-
- PackageSpecMap spec_map;
- auto spec_a = FullPackageSpec{spec_map.emplace("a", "b[core]"), {"core"}};
- auto spec_b = FullPackageSpec{spec_map.emplace("b", "", {{"b1", ""}}), {"b1"}};
-
- PortFileProvider::MapPortFileProvider map_port{spec_map.map};
- MockCMakeVarProvider var_provider;
-
- 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]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(make_status_pgh("x", "b"));
- status_paragraphs.push_back(make_status_pgh("b"));
-
- PackageSpecMap spec_map;
-
- auto spec_a = FullPackageSpec{spec_map.emplace("a")};
- auto spec_x = FullPackageSpec{spec_map.emplace("x", "a"), {"core"}};
- auto spec_b = FullPackageSpec{spec_map.emplace("b", "", {{"b1", ""}}), {"b1"}};
-
- 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(plan.size() == 5);
- remove_plan_check(plan.remove_actions.at(0), "x");
- remove_plan_check(plan.remove_actions.at(1), "b");
-
- features_check(plan.install_actions.at(0), "a", {"core"});
- features_check(plan.install_actions.at(1), "b", {"core", "b1"});
- features_check(plan.install_actions.at(2), "x", {"core"});
-}
-
-TEST_CASE ("basic feature test 8", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(make_status_pgh("a"));
- status_paragraphs.push_back(make_status_pgh("a"));
- status_paragraphs.back()->package.spec = PackageSpec("a", Test::X64_WINDOWS);
-
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- auto spec_a_64 = FullPackageSpec{spec_map.emplace("a", "b", {{"a1", ""}}), {"core"}};
- auto spec_b_64 = FullPackageSpec{spec_map.emplace("b")};
- auto spec_c_64 = FullPackageSpec{spec_map.emplace("c", "a[a1]"), {"core"}};
-
- spec_map.triplet = Test::X86_WINDOWS;
- auto spec_a_86 = FullPackageSpec{PackageSpec{"a", Test::X86_WINDOWS}};
- auto spec_b_86 = FullPackageSpec{PackageSpec{"b", Test::X86_WINDOWS}};
- auto spec_c_86 = FullPackageSpec{PackageSpec{"c", Test::X86_WINDOWS}};
-
- 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(plan.remove_actions.at(0), "a", Test::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"}, Test::X64_WINDOWS);
- features_check(install_plan.at(1), "a", {"a1", "core"}, Test::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"}, Test::X64_WINDOWS);
- features_check(install_plan.at(5), "c", {"core"});
-}
-
-TEST_CASE ("install all features test", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- auto spec_a_64 = FullPackageSpec{spec_map.emplace("a", "", {{"0", ""}, {"1", ""}}), {"core"}};
-
- auto install_specs = FullPackageSpec::from_string("a[*]", Test::X64_WINDOWS);
- REQUIRE(install_specs.has_value());
- if (!install_specs.has_value()) return;
-
- 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.install_actions.at(0), "a", {"0", "1", "core"}, Test::X64_WINDOWS);
-}
-
-TEST_CASE ("install default features test 1", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- // Add a port "a" with default features "1" and features "0" and "1".
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- spec_map.emplace("a", "", {{"0", ""}, {"1", ""}}, {"1"});
-
- // Install "a" (without explicit feature specification)
- auto install_specs = FullPackageSpec::from_string("a", Test::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 the default feature "1" to be installed, but not "0"
- REQUIRE(install_plan.size() == 1);
- features_check(install_plan.install_actions.at(0), "a", {"1", "core"}, Test::X64_WINDOWS);
-}
-
-TEST_CASE ("install default features test 2", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(make_status_pgh("a"));
- status_paragraphs.back()->package.spec = PackageSpec("a", Test::X64_WINDOWS);
-
- // Add a port "a" of which "core" is already installed, but we will
- // install the default features "explicitly"
- // "a" has two features, of which "a1" is default.
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- spec_map.emplace("a", "", {{"a0", ""}, {"a1", ""}}, {"a1"});
-
- // Install "a" (without explicit feature specification)
- auto install_specs = FullPackageSpec::from_string("a", Test::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 removed for rebuild and then installed with default
- // features.
- REQUIRE(install_plan.size() == 2);
- remove_plan_check(install_plan.remove_actions.at(0), "a", Test::X64_WINDOWS);
- features_check(install_plan.install_actions.at(0), "a", {"a1", "core"}, Test::X64_WINDOWS);
-}
-
-TEST_CASE ("install default features test 3", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- // "a" has two features, of which "a1" is default.
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- spec_map.emplace("a", "", {{"a0", ""}, {"a1", ""}}, {"a1"});
-
- // Explicitly install "a" without default features
- auto install_specs = FullPackageSpec::from_string("a[core]", Test::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 the default feature not to get installed.
- REQUIRE(install_plan.size() == 1);
- features_check(install_plan.install_actions.at(0), "a", {"core"}, Test::X64_WINDOWS);
-}
-
-TEST_CASE ("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(Test::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 install_specs = FullPackageSpec::from_string("a", Test::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"}, Test::X64_WINDOWS);
- features_check(install_plan.install_actions.at(1), "a", {"core"}, Test::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(Test::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", Test::X64_WINDOWS);
- auto spec_b = FullPackageSpec::from_string("b[core]", Test::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,
- // 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", {"core"}, Test::X64_WINDOWS);
- features_check(install_plan.install_actions.at(1), "a", {"core"}, Test::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(Test::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", Test::X64_WINDOWS);
- auto spec_b = FullPackageSpec::from_string("b[core]", Test::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"}, Test::X64_WINDOWS);
- features_check(install_plan.install_actions.at(1), "a", {"core"}, Test::X64_WINDOWS);
-}
-
-TEST_CASE ("do not install default features of existing dependency", "[plan]")
-{
- // Add a port "a" which depends on the core of "b"
- PackageSpecMap spec_map(Test::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<std::unique_ptr<StatusParagraph>> status_paragraphs;
- // "b[core]" is already installed
- status_paragraphs.push_back(make_status_pgh("b"));
- status_paragraphs.back()->package.spec = PackageSpec("b", Test::X64_WINDOWS);
-
- // Install "a" (without explicit feature specification)
- auto install_specs = FullPackageSpec::from_string("a", Test::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, but not require rebuilding "b"
- REQUIRE(install_plan.size() == 1);
- features_check(install_plan.install_actions.at(0), "a", {"core"}, Test::X64_WINDOWS);
-}
-
-TEST_CASE ("install default features of existing dependency", "[plan]")
-{
- // Add a port "a" which depends on the default features of "b"
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- spec_map.emplace("a", "b");
- // "b" has a default feature
- spec_map.emplace("b", "", {{"b1", ""}}, {"b1"});
-
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- // "b[core]" is already installed
- status_paragraphs.push_back(make_status_pgh("b", "", "b1"));
- status_paragraphs.back()->package.spec = PackageSpec("b", Test::X64_WINDOWS);
-
- // Install "a" (without explicit feature specification)
- auto install_specs = FullPackageSpec::from_string("a", Test::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 "b" to be rebuilt
- REQUIRE(install_plan.install_actions.size() == 2);
- features_check(install_plan.install_actions.at(0), "b", {"core", "b1"}, Test::X64_WINDOWS);
-}
-
-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"));
- status_paragraphs.back()->package.spec = PackageSpec("b", Test::X64_WINDOWS);
-
- // Add a port "a" which depends on the core of "b", which was already
- // installed explicitly
- PackageSpecMap spec_map(Test::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 install_specs = FullPackageSpec::from_string("a", Test::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, 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.install_actions.at(0), "a", {"core"}, Test::X64_WINDOWS);
-}
-
-TEST_CASE ("install plan action dependencies", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- // Add a port "a" which depends on the core of "b", which was already
- // installed explicitly
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- auto spec_c = spec_map.emplace("c");
- auto spec_b = spec_map.emplace("b", "c");
- spec_map.emplace("a", "b");
-
- // Install "a" (without explicit feature specification)
- auto install_specs = FullPackageSpec::from_string("a", Test::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)));
-
- REQUIRE(install_plan.size() == 3);
- features_check(install_plan.install_actions.at(0), "c", {"core"}, Test::X64_WINDOWS);
-
- // TODO: Figure out what to do with these tests
- features_check(install_plan.install_actions.at(1), "b", {"core"}, Test::X64_WINDOWS);
- // REQUIRE(install_plan.at(1).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_c});
-
- features_check(install_plan.install_actions.at(2), "a", {"core"}, Test::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]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- // Add a port "a" which depends on the core of "b", which was already
- // installed explicitly
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- auto spec_c = spec_map.emplace("c");
- auto spec_b = spec_map.emplace("b", "c");
- spec_map.emplace("a", "c, b");
-
- // Install "a" (without explicit feature specification)
- auto install_specs = FullPackageSpec::from_string("a", Test::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)));
-
- REQUIRE(install_plan.size() == 3);
- features_check(install_plan.install_actions.at(0), "c", {"core"}, Test::X64_WINDOWS);
-
- features_check(install_plan.install_actions.at(1), "b", {"core"}, Test::X64_WINDOWS);
- // REQUIRE(install_plan.at(1).install_action.get()->computed_dependencies == std::vector<PackageSpec>{spec_c});
-
- features_check(install_plan.install_actions.at(2), "a", {"core"}, Test::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]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- // Add a port "a" which depends on the core of "b", which was already
- // installed explicitly
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- spec_map.emplace("a", "", {{"0", ""}, {"1", "a[0]"}}, {"1"});
-
- // Install "a" (without explicit feature specification)
- auto install_specs = FullPackageSpec::from_string("a", Test::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)));
-
- REQUIRE(install_plan.size() == 1);
- features_check(install_plan.install_actions.at(0), "a", {"1", "0", "core"}, Test::X64_WINDOWS);
- // REQUIRE(install_plan.at(0).install_action.get()->computed_dependencies == std::vector<PackageSpec>{});
-}
-
-TEST_CASE ("install with default features", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- pghs.push_back(make_status_pgh("a", ""));
- StatusParagraphs status_db(std::move(pghs));
-
- PackageSpecMap spec_map;
- auto b_spec = spec_map.emplace("b", "", {{"0", ""}}, {"0"});
- auto a_spec = spec_map.emplace("a", "b[core]", {{"0", ""}});
-
- 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.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]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- pghs.push_back(make_status_pgh("a", "", "1"));
- pghs.push_back(make_status_feature_pgh("a", "0"));
- StatusParagraphs status_db(std::move(pghs));
-
- // Add a port "a" of which "core" and "0" are already installed.
- PackageSpecMap spec_map;
- auto spec_a = spec_map.emplace("a", "", {{"0", ""}, {"1", ""}}, {"1"});
-
- 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);
-
- 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]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- // B is currently installed _without_ default feature b0
- pghs.push_back(make_status_pgh("b", "", "b0", "x64-windows"));
- pghs.push_back(make_status_pgh("a", "b[core]", "", "x64-windows"));
-
- StatusParagraphs status_db(std::move(pghs));
-
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- auto spec_a = spec_map.emplace("a", "b[core]");
- auto spec_b = spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b0", "b1"});
-
- 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.remove_actions.at(0), "a", Test::X64_WINDOWS);
- remove_plan_check(plan.remove_actions.at(1), "b", Test::X64_WINDOWS);
- features_check(plan.install_actions.at(0), "b", {"core", "b1"}, Test::X64_WINDOWS);
- features_check(plan.install_actions.at(1), "a", {"core"}, Test::X64_WINDOWS);
-}
-
-TEST_CASE ("upgrade with default features 3", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- // note: unrelated package due to x86 triplet
- pghs.push_back(make_status_pgh("b", "", "", "x86-windows"));
- pghs.push_back(make_status_pgh("a", "", "", "x64-windows"));
-
- StatusParagraphs status_db(std::move(pghs));
-
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- auto spec_a = spec_map.emplace("a", "b[core]");
- spec_map.emplace("b", "", {{"b0", ""}, {"b1", ""}}, {"b0"});
-
- 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.remove_actions.at(0), "a", Test::X64_WINDOWS);
- features_check(plan.install_actions.at(0), "b", {"b0", "core"}, Test::X64_WINDOWS);
- features_check(plan.install_actions.at(1), "a", {"core"}, Test::X64_WINDOWS);
-}
-
-TEST_CASE ("upgrade with new default feature", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- pghs.push_back(make_status_pgh("a", "", "0", "x86-windows"));
-
- StatusParagraphs status_db(std::move(pghs));
-
- PackageSpecMap spec_map;
- auto spec_a = spec_map.emplace("a", "", {{"0", ""}, {"1", ""}, {"2", ""}}, {"0", "1"});
-
- 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.remove_actions.at(0), "a", Test::X86_WINDOWS);
- features_check(plan.install_actions.at(0), "a", {"core", "1"}, Test::X86_WINDOWS);
-}
-
-TEST_CASE ("transitive features test", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- auto spec_a_64 = FullPackageSpec{spec_map.emplace("a", "b", {{"0", "b[0]"}}), {"core"}};
- auto spec_b_64 = FullPackageSpec{spec_map.emplace("b", "c", {{"0", "c[0]"}}), {"core"}};
- auto spec_c_64 = FullPackageSpec{spec_map.emplace("c", "", {{"0", ""}}), {"core"}};
-
- auto install_specs = FullPackageSpec::from_string("a[*]", Test::X64_WINDOWS);
- REQUIRE(install_specs.has_value());
- if (!install_specs.has_value()) return;
-
- 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.install_actions.at(0), "c", {"0", "core"}, Test::X64_WINDOWS);
- features_check(install_plan.install_actions.at(1), "b", {"0", "core"}, Test::X64_WINDOWS);
- features_check(install_plan.install_actions.at(2), "a", {"0", "core"}, Test::X64_WINDOWS);
-}
-
-TEST_CASE ("no transitive features test", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- auto spec_a_64 = FullPackageSpec{spec_map.emplace("a", "b", {{"0", ""}}), {"core"}};
- auto spec_b_64 = FullPackageSpec{spec_map.emplace("b", "c", {{"0", ""}}), {"core"}};
- auto spec_c_64 = FullPackageSpec{spec_map.emplace("c", "", {{"0", ""}}), {"core"}};
-
- auto install_specs = FullPackageSpec::from_string("a[*]", Test::X64_WINDOWS);
- REQUIRE(install_specs.has_value());
- if (!install_specs.has_value()) return;
- 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.install_actions.at(0), "c", {"core"}, Test::X64_WINDOWS);
- features_check(install_plan.install_actions.at(1), "b", {"core"}, Test::X64_WINDOWS);
- features_check(install_plan.install_actions.at(2), "a", {"0", "core"}, Test::X64_WINDOWS);
-}
-
-TEST_CASE ("only transitive features test", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
-
- PackageSpecMap spec_map(Test::X64_WINDOWS);
- auto spec_a_64 = FullPackageSpec{spec_map.emplace("a", "", {{"0", "b[0]"}}), {"core"}};
- auto spec_b_64 = FullPackageSpec{spec_map.emplace("b", "", {{"0", "c[0]"}}), {"core"}};
- auto spec_c_64 = FullPackageSpec{spec_map.emplace("c", "", {{"0", ""}}), {"core"}};
-
- auto install_specs = FullPackageSpec::from_string("a[*]", Test::X64_WINDOWS);
- REQUIRE(install_specs.has_value());
- if (!install_specs.has_value()) return;
- 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.install_actions.at(0), "c", {"0", "core"}, Test::X64_WINDOWS);
- features_check(install_plan.install_actions.at(1), "b", {"0", "core"}, Test::X64_WINDOWS);
- features_check(install_plan.install_actions.at(2), "a", {"0", "core"}, Test::X64_WINDOWS);
-}
-
-TEST_CASE ("basic remove scheme", "[plan]")
-{
- 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({{"a", Test::X86_WINDOWS}}, status_db);
-
- REQUIRE(remove_plan.size() == 1);
- REQUIRE(remove_plan.at(0).spec.name() == "a");
-}
-
-TEST_CASE ("recurse remove scheme", "[plan]")
-{
- 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({{"a", Test::X86_WINDOWS}}, status_db);
-
- REQUIRE(remove_plan.size() == 2);
- REQUIRE(remove_plan.at(0).spec.name() == "b");
- REQUIRE(remove_plan.at(1).spec.name() == "a");
-}
-
-TEST_CASE ("features depend remove scheme", "[plan]")
-{
- 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({{"a", Test::X86_WINDOWS}}, status_db);
-
- REQUIRE(remove_plan.size() == 2);
- REQUIRE(remove_plan.at(0).spec.name() == "b");
- REQUIRE(remove_plan.at(1).spec.name() == "a");
-}
-
-TEST_CASE ("features depend remove scheme once removed", "[plan]")
-{
- 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({{"expat", Test::X86_WINDOWS}}, status_db);
-
- REQUIRE(remove_plan.size() == 3);
- REQUIRE(remove_plan.at(0).spec.name() == "opencv");
- REQUIRE(remove_plan.at(1).spec.name() == "vtk");
- REQUIRE(remove_plan.at(2).spec.name() == "expat");
-}
-
-TEST_CASE ("features depend remove scheme once removed x64", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- pghs.push_back(make_status_pgh("expat", "", "", "x64"));
- pghs.push_back(make_status_pgh("vtk", "expat", "", "x64"));
- pghs.push_back(make_status_pgh("opencv", "", "", "x64"));
- pghs.push_back(make_status_feature_pgh("opencv", "vtk", "vtk", "x64"));
- StatusParagraphs status_db(std::move(pghs));
-
- auto remove_plan = Dependencies::create_remove_plan({{"expat", Triplet::from_canonical_name("x64")}}, status_db);
-
- REQUIRE(remove_plan.size() == 3);
- REQUIRE(remove_plan.at(0).spec.name() == "opencv");
- REQUIRE(remove_plan.at(1).spec.name() == "vtk");
- REQUIRE(remove_plan.at(2).spec.name() == "expat");
-}
-
-TEST_CASE ("features depend core remove scheme", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- pghs.push_back(make_status_pgh("curl", "", "", "x64"));
- pghs.push_back(make_status_pgh("cpr", "curl[core]", "", "x64"));
- StatusParagraphs status_db(std::move(pghs));
-
- auto remove_plan = Dependencies::create_remove_plan({{"curl", Triplet::from_canonical_name("x64")}}, status_db);
-
- REQUIRE(remove_plan.size() == 2);
- REQUIRE(remove_plan.at(0).spec.name() == "cpr");
- REQUIRE(remove_plan.at(1).spec.name() == "curl");
-}
-
-TEST_CASE ("features depend core remove scheme 2", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- pghs.push_back(make_status_pgh("curl", "", "", "x64"));
- pghs.push_back(make_status_feature_pgh("curl", "a", "", "x64"));
- pghs.push_back(make_status_feature_pgh("curl", "b", "curl[a]", "x64"));
- StatusParagraphs status_db(std::move(pghs));
-
- auto remove_plan = Dependencies::create_remove_plan({{"curl", Triplet::from_canonical_name("x64")}}, status_db);
-
- REQUIRE(remove_plan.size() == 1);
- REQUIRE(remove_plan.at(0).spec.name() == "curl");
-}
-
-TEST_CASE ("basic upgrade scheme", "[plan]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- pghs.push_back(make_status_pgh("a"));
- StatusParagraphs status_db(std::move(pghs));
-
- PackageSpecMap spec_map;
- auto spec_a = spec_map.emplace("a");
-
- 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);
- 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]")
-{
- 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;
- auto spec_a = spec_map.emplace("a");
- spec_map.emplace("b", "a");
-
- 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);
- 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]")
-{
- 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;
- auto spec_a = spec_map.emplace("a");
- spec_map.emplace("b", "a");
-
- 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);
- 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]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- pghs.push_back(make_status_pgh("a"));
- StatusParagraphs status_db(std::move(pghs));
-
- PackageSpecMap spec_map;
- auto spec_a = spec_map.emplace("a", "b");
- spec_map.emplace("b");
-
- 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);
- 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]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- pghs.push_back(make_status_pgh("a"));
- pghs.push_back(make_status_feature_pgh("a", "a1"));
- StatusParagraphs status_db(std::move(pghs));
-
- PackageSpecMap spec_map;
- auto spec_a = spec_map.emplace("a", "", {{"a1", ""}});
-
- 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);
- 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]")
-{
- // only core of package "a" is installed
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- pghs.push_back(make_status_pgh("a"));
- StatusParagraphs status_db(std::move(pghs));
-
- // a1 was added as a default feature and should be installed in upgrade
- PackageSpecMap spec_map;
- auto spec_a = spec_map.emplace("a", "", {{"a1", ""}}, {"a1"});
-
- 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);
- 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]")
-{
- 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;
- auto spec_a = spec_map.emplace("a", "", {{"a1", ""}, {"a2", "a[a1]"}});
-
- 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);
- 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]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> pghs;
- pghs.push_back(make_status_pgh("a"));
- StatusParagraphs status_db(std::move(pghs));
-
- PackageSpecMap spec_map;
- auto spec_a = spec_map.emplace("a");
-
- auto plan = Dependencies::create_export_plan({spec_a}, status_db);
-
- REQUIRE(plan.size() == 1);
- REQUIRE(plan.at(0).spec.name() == "a");
- REQUIRE(plan.at(0).plan_type == Dependencies::ExportPlanType::ALREADY_BUILT);
-}
-
-TEST_CASE ("basic export scheme with recurse", "[plan]")
-{
- 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;
- 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);
-
- REQUIRE(plan.size() == 2);
- REQUIRE(plan.at(0).spec.name() == "a");
- REQUIRE(plan.at(0).plan_type == Dependencies::ExportPlanType::ALREADY_BUILT);
-
- REQUIRE(plan.at(1).spec.name() == "b");
- REQUIRE(plan.at(1).plan_type == Dependencies::ExportPlanType::ALREADY_BUILT);
-}
-
-TEST_CASE ("basic export scheme with bystander", "[plan]")
-{
- 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;
- 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);
-
- REQUIRE(plan.size() == 1);
- REQUIRE(plan.at(0).spec.name() == "a");
- REQUIRE(plan.at(0).plan_type == Dependencies::ExportPlanType::ALREADY_BUILT);
-}
-
-TEST_CASE ("basic export scheme with missing", "[plan]")
-{
- StatusParagraphs status_db;
-
- PackageSpecMap spec_map;
- auto spec_a = spec_map.emplace("a");
-
- auto plan = Dependencies::create_export_plan({spec_a}, status_db);
-
- REQUIRE(plan.size() == 1);
- REQUIRE(plan.at(0).spec.name() == "a");
- REQUIRE(plan.at(0).plan_type == Dependencies::ExportPlanType::NOT_BUILT);
-}
-
-TEST_CASE ("basic export scheme with features", "[plan]")
-{
- 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;
- auto spec_a = spec_map.emplace("a", "", {{"a1", ""}});
-
- auto plan = Dependencies::create_export_plan({spec_a}, status_db);
-
- REQUIRE(plan.size() == 2);
-
- REQUIRE(plan.at(0).spec.name() == "b");
- REQUIRE(plan.at(0).plan_type == Dependencies::ExportPlanType::ALREADY_BUILT);
-
- REQUIRE(plan.at(1).spec.name() == "a");
- REQUIRE(plan.at(1).plan_type == Dependencies::ExportPlanType::ALREADY_BUILT);
-}
diff --git a/toolsrc/src/vcpkg-test/platform-expression.cpp b/toolsrc/src/vcpkg-test/platform-expression.cpp
deleted file mode 100644
index aef999230..000000000
--- a/toolsrc/src/vcpkg-test/platform-expression.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/platform-expression.h>
-
-using vcpkg::StringView;
-using namespace vcpkg::PlatformExpression;
-
-static vcpkg::ExpectedS<Expr> parse_expr(StringView s)
-{
- return parse_platform_expression(s, MultipleBinaryOperators::Deny);
-}
-
-TEST_CASE ("platform-expression-identifier", "[platform-expression]")
-{
- auto m_expr = parse_expr("windows");
- REQUIRE(m_expr);
- auto& expr = *m_expr.get();
-
- CHECK(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}}));
- CHECK(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "WindowsStore"}}));
- CHECK_FALSE(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}}));
- CHECK_FALSE(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Darwin"}}));
-}
-
-TEST_CASE ("platform-expression-not", "[platform-expression]")
-{
- auto m_expr = parse_expr("!windows");
- REQUIRE(m_expr);
- auto& expr = *m_expr.get();
-
- CHECK_FALSE(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}}));
- CHECK_FALSE(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "WindowsStore"}}));
- CHECK(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}}));
- CHECK(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Darwin"}}));
-}
-
-TEST_CASE ("platform-expression-and", "[platform-expression]")
-{
- auto m_expr = parse_expr("!windows & !arm");
- REQUIRE(m_expr);
- auto& expr = *m_expr.get();
-
- CHECK_FALSE(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}}));
- CHECK_FALSE(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "WindowsStore"}}));
- CHECK(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}}));
- CHECK_FALSE(expr.evaluate({
- {"VCPKG_CMAKE_SYSTEM_NAME", "Linux"},
- {"VCPKG_TARGET_ARCHITECTURE", "arm"},
- }));
-}
-
-TEST_CASE ("platform-expression-or", "[platform-expression]")
-{
- auto m_expr = parse_expr("!windows | arm");
- REQUIRE(m_expr);
- auto& expr = *m_expr.get();
-
- CHECK_FALSE(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}}));
- CHECK(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}, {"VCPKG_TARGET_ARCHITECTURE", "arm"}}));
- CHECK(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}}));
-}
-
-TEST_CASE ("weird platform-expressions whitespace", "[platform-expression]")
-{
- auto m_expr = parse_expr(" ! \t windows \n| arm \r");
- REQUIRE(m_expr);
- auto& expr = *m_expr.get();
-
- CHECK_FALSE(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}}));
- CHECK(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}, {"VCPKG_TARGET_ARCHITECTURE", "arm"}}));
- CHECK(expr.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}}));
-}
-
-TEST_CASE ("no mixing &, | in platform expressions", "[platform-expression]")
-{
- auto m_expr = parse_expr("windows & arm | linux");
- CHECK_FALSE(m_expr);
- m_expr = parse_expr("windows | !arm & linux");
- CHECK_FALSE(m_expr);
-}
diff --git a/toolsrc/src/vcpkg-test/registries.cpp b/toolsrc/src/vcpkg-test/registries.cpp
deleted file mode 100644
index 1c839409d..000000000
--- a/toolsrc/src/vcpkg-test/registries.cpp
+++ /dev/null
@@ -1,132 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/jsonreader.h>
-
-#include <vcpkg/registries.h>
-
-using namespace vcpkg;
-
-namespace
-{
- struct TestRegistryImplementation final : RegistryImplementation
- {
- std::unique_ptr<RegistryEntry> get_port_entry(const VcpkgPaths&, StringView) const override { return nullptr; }
-
- void get_all_port_names(std::vector<std::string>&, const VcpkgPaths&) const override { }
-
- Optional<VersionT> get_baseline_version(const VcpkgPaths&, StringView) const override { return nullopt; }
-
- int number;
-
- TestRegistryImplementation(int n) : number(n) { }
- };
-
- Registry make_registry(int n, std::vector<std::string>&& port_names)
- {
- return {std::move(port_names), std::make_unique<TestRegistryImplementation>(n)};
- }
-
- int get_tri_num(const RegistryImplementation& r)
- {
- if (auto tri = dynamic_cast<const TestRegistryImplementation*>(&r))
- {
- return tri->number;
- }
- else
- {
- return -1;
- }
- }
-
- // test functions which parse string literals, so no concerns about failure
- Json::Value parse_json(StringView sv) { return Json::parse(sv).value_or_exit(VCPKG_LINE_INFO).first; }
-}
-
-TEST_CASE ("registry_set_selects_registry", "[registries]")
-{
- RegistrySet set;
- set.set_default_registry(std::make_unique<TestRegistryImplementation>(0));
-
- set.add_registry(make_registry(1, {"p1", "q1", "r1"}));
- set.add_registry(make_registry(2, {"p2", "q2", "r2"}));
-
- auto reg = set.registry_for_port("p1");
- REQUIRE(reg);
- CHECK(get_tri_num(*reg) == 1);
- reg = set.registry_for_port("r2");
- REQUIRE(reg);
- CHECK(get_tri_num(*reg) == 2);
- reg = set.registry_for_port("a");
- REQUIRE(reg);
- CHECK(get_tri_num(*reg) == 0);
-
- set.set_default_registry(nullptr);
-
- reg = set.registry_for_port("q1");
- REQUIRE(reg);
- CHECK(get_tri_num(*reg) == 1);
- reg = set.registry_for_port("p2");
- REQUIRE(reg);
- CHECK(get_tri_num(*reg) == 2);
- reg = set.registry_for_port("a");
- CHECK_FALSE(reg);
-}
-
-TEST_CASE ("registry_parsing", "[registries]")
-{
- Json::Reader r;
- auto registry_impl_des = get_registry_implementation_deserializer({});
-
- auto test_json = parse_json(R"json(
-{
- "kind": "builtin"
-}
- )json");
- auto registry_impl = r.visit(test_json, *registry_impl_des);
- REQUIRE(registry_impl);
- CHECK(*registry_impl.get());
- CHECK(r.errors().empty());
-
- test_json = parse_json(R"json(
-{
- "kind": "builtin",
- "baseline": "hi"
-}
- )json");
- registry_impl = r.visit(test_json, *registry_impl_des);
- REQUIRE(registry_impl);
- CHECK(*registry_impl.get());
- CHECK(r.errors().empty());
-
- test_json = parse_json(R"json(
-{
- "kind": "builtin",
- "path": "a/b"
-}
- )json");
- registry_impl = r.visit(test_json, *registry_impl_des);
- CHECK_FALSE(r.errors().empty());
- r.errors().clear();
-
- test_json = parse_json(R"json(
-{
- "kind": "filesystem",
- "path": "a/b/c"
-}
- )json");
- registry_impl = r.visit(test_json, *registry_impl_des);
- REQUIRE(registry_impl);
- CHECK(*registry_impl.get());
- CHECK(r.errors().empty());
-
- test_json = parse_json(R"json(
-{
- "kind": "filesystem",
- "path": "/a/b/c"
-}
- )json");
- registry_impl = r.visit(test_json, *registry_impl_des);
- REQUIRE(registry_impl);
- CHECK(*registry_impl.get());
- CHECK(r.errors().empty());
-}
diff --git a/toolsrc/src/vcpkg-test/specifier.cpp b/toolsrc/src/vcpkg-test/specifier.cpp
deleted file mode 100644
index f750f4144..000000000
--- a/toolsrc/src/vcpkg-test/specifier.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/system.print.h>
-#include <vcpkg/base/util.h>
-
-#include <vcpkg/packagespec.h>
-
-#include <vcpkg-test/util.h>
-
-using namespace vcpkg;
-
-TEST_CASE ("specifier conversion", "[specifier]")
-{
- SECTION ("full package spec to feature specs")
- {
- constexpr std::size_t SPEC_SIZE = 6;
-
- PackageSpec a_spec("a", Test::X64_WINDOWS);
- PackageSpec b_spec("b", Test::X64_WINDOWS);
-
- 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", "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)
- {
- REQUIRE(features.at(i) == fspecs.at(i).feature());
- REQUIRE(*specs.at(i) == fspecs.at(i).spec());
- }
- }
-}
-
-TEST_CASE ("specifier parsing", "[specifier]")
-{
- SECTION ("parsed specifier from string")
- {
- auto maybe_spec = vcpkg::parse_qualified_specifier("zlib");
- REQUIRE(maybe_spec.has_value());
-
- auto& spec = *maybe_spec.get();
- REQUIRE(spec.name == "zlib");
- REQUIRE(!spec.features);
- REQUIRE(!spec.triplet);
- }
-
- SECTION ("parsed specifier from string with triplet")
- {
- auto maybe_spec = vcpkg::parse_qualified_specifier("zlib:x64-uwp");
- REQUIRE(maybe_spec);
-
- auto& spec = *maybe_spec.get();
- REQUIRE(spec.name == "zlib");
- REQUIRE(spec.triplet.value_or("") == "x64-uwp");
- }
-
- SECTION ("parsed specifier from string with colons")
- {
- auto s = vcpkg::parse_qualified_specifier("zlib:x86-uwp:");
- REQUIRE(!s);
- }
-
- SECTION ("parsed specifier from string with feature")
- {
- auto maybe_spec = vcpkg::parse_qualified_specifier("zlib[feature]:x64-uwp");
- REQUIRE(maybe_spec);
-
- auto& spec = *maybe_spec.get();
- REQUIRE(spec.name == "zlib");
- REQUIRE(spec.features.value_or(std::vector<std::string>{}) == std::vector<std::string>{"feature"});
- REQUIRE(spec.triplet.value_or("") == "x64-uwp");
- }
-
- SECTION ("parsed specifier from string with many features")
- {
- auto maybe_spec = vcpkg::parse_qualified_specifier("zlib[0, 1,2]");
- REQUIRE(maybe_spec);
-
- auto& spec = *maybe_spec.get();
- REQUIRE(spec.features.value_or(std::vector<std::string>{}) == std::vector<std::string>{"0", "1", "2"});
- }
-
- SECTION ("parsed specifier wildcard feature")
- {
- auto maybe_spec = vcpkg::parse_qualified_specifier("zlib[*]");
- System::print2(maybe_spec.error());
- REQUIRE(maybe_spec);
-
- auto& spec = *maybe_spec.get();
- REQUIRE(spec.features.value_or(std::vector<std::string>{}) == std::vector<std::string>{"*"});
- }
-
- SECTION ("expand wildcards")
- {
- auto zlib = vcpkg::FullPackageSpec::from_string("zlib[0,1]", Test::X86_UWP).value_or_exit(VCPKG_LINE_INFO);
- auto openssl = vcpkg::FullPackageSpec::from_string("openssl[*]", Test::X86_UWP).value_or_exit(VCPKG_LINE_INFO);
- auto specs = zlib.to_feature_specs({}, {});
- auto specs2 = openssl.to_feature_specs({}, {});
- Util::Vectors::append(&specs, specs2);
- Util::sort(specs);
-
- std::vector<FeatureSpec> spectargets{
- {{"openssl", Test::X86_UWP}, "core"},
- {{"zlib", Test::X86_UWP}, "core"},
- {{"zlib", Test::X86_UWP}, "0"},
- {{"zlib", Test::X86_UWP}, "1"},
- };
- Util::sort(spectargets);
- REQUIRE(specs.size() == spectargets.size());
- REQUIRE(specs == spectargets);
- }
-
-#if defined(_WIN32)
- SECTION ("ASCII to utf16")
- {
- auto str = vcpkg::Strings::to_utf16("abc");
- REQUIRE(str == L"abc");
- }
-
- SECTION ("ASCII to utf16 with whitespace")
- {
- auto str = vcpkg::Strings::to_utf16("abc -x86-windows");
- REQUIRE(str == L"abc -x86-windows");
- }
-#endif
-}
diff --git a/toolsrc/src/vcpkg-test/statusparagraphs.cpp b/toolsrc/src/vcpkg-test/statusparagraphs.cpp
deleted file mode 100644
index f647484e6..000000000
--- a/toolsrc/src/vcpkg-test/statusparagraphs.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/util.h>
-
-#include <vcpkg/paragraphs.h>
-#include <vcpkg/statusparagraphs.h>
-
-#include <vcpkg-test/util.h>
-
-using namespace vcpkg;
-using namespace vcpkg::Paragraphs;
-using namespace vcpkg::Test;
-
-TEST_CASE ("find installed", "[statusparagraphs]")
-{
- auto pghs = parse_paragraphs(R"(
-Package: ffmpeg
-Version: 3.3.3
-Architecture: x64-windows
-Multi-Arch: same
-Description:
-Status: install ok installed
-)",
- "");
-
- REQUIRE(pghs);
-
- StatusParagraphs status_db(
- Util::fmap(*pghs.get(), [](Paragraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
-
- auto it = status_db.find_installed({"ffmpeg", Test::X64_WINDOWS});
- REQUIRE(it != status_db.end());
-}
-
-TEST_CASE ("find not installed", "[statusparagraphs]")
-{
- auto pghs = parse_paragraphs(R"(
-Package: ffmpeg
-Version: 3.3.3
-Architecture: x64-windows
-Multi-Arch: same
-Description:
-Status: purge ok not-installed
-)",
- "");
-
- REQUIRE(pghs);
-
- StatusParagraphs status_db(
- Util::fmap(*pghs.get(), [](Paragraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
-
- auto it = status_db.find_installed({"ffmpeg", Test::X64_WINDOWS});
- REQUIRE(it == status_db.end());
-}
-
-TEST_CASE ("find with feature packages", "[statusparagraphs]")
-{
- auto pghs = parse_paragraphs(R"(
-Package: ffmpeg
-Version: 3.3.3
-Architecture: x64-windows
-Multi-Arch: same
-Description:
-Status: install ok installed
-
-Package: ffmpeg
-Feature: openssl
-Depends: openssl
-Architecture: x64-windows
-Multi-Arch: same
-Description:
-Status: purge ok not-installed
-)",
- "");
-
- REQUIRE(pghs);
-
- StatusParagraphs status_db(
- Util::fmap(*pghs.get(), [](Paragraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
-
- auto it = status_db.find_installed({"ffmpeg", Test::X64_WINDOWS});
- REQUIRE(it != status_db.end());
-
- // Feature "openssl" is not installed and should not be found
- auto it1 = status_db.find_installed({{"ffmpeg", Test::X64_WINDOWS}, "openssl"});
- REQUIRE(it1 == status_db.end());
-}
-
-TEST_CASE ("find for feature packages", "[statusparagraphs]")
-{
- auto pghs = parse_paragraphs(R"(
-Package: ffmpeg
-Version: 3.3.3
-Architecture: x64-windows
-Multi-Arch: same
-Description:
-Status: install ok installed
-
-Package: ffmpeg
-Feature: openssl
-Depends: openssl
-Architecture: x64-windows
-Multi-Arch: same
-Description:
-Status: install ok installed
-)",
- "");
- REQUIRE(pghs);
-
- StatusParagraphs status_db(
- Util::fmap(*pghs.get(), [](Paragraph& rpgh) { return std::make_unique<StatusParagraph>(std::move(rpgh)); }));
-
- // Feature "openssl" is installed and should therefore be found
- auto it = status_db.find_installed({{"ffmpeg", Test::X64_WINDOWS}, "openssl"});
- REQUIRE(it != status_db.end());
-}
diff --git a/toolsrc/src/vcpkg-test/strings.cpp b/toolsrc/src/vcpkg-test/strings.cpp
deleted file mode 100644
index 32fe5b3af..000000000
--- a/toolsrc/src/vcpkg-test/strings.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/strings.h>
-
-#include <stdint.h>
-
-#include <string>
-#include <utility>
-#include <vector>
-
-#if defined(_MSC_VER)
-#pragma warning(disable : 6237)
-#endif
-
-TEST_CASE ("b32 encoding", "[strings]")
-{
- using u64 = uint64_t;
-
- std::vector<std::pair<u64, std::string>> map;
-
- map.emplace_back(0, "AAAAAAAAAAAAA");
- map.emplace_back(1, "BAAAAAAAAAAAA");
-
- map.emplace_back(u64(1) << 32, "AAAAAAEAAAAAA");
- map.emplace_back((u64(1) << 32) + 1, "BAAAAAEAAAAAA");
-
- map.emplace_back(0xE4D0'1065'D11E'0229, "JRA4RIXMQAUJO");
- map.emplace_back(0xA626'FE45'B135'07FF, "77BKTYWI6XJMK");
- map.emplace_back(0xEE36'D228'0C31'D405, "FAVDDGAFSWN4O");
- map.emplace_back(0x1405'64E7'FE7E'A88C, "MEK5H774ELBIB");
- map.emplace_back(0xFFFF'FFFF'FFFF'FFFF, "777777777777P");
-
- for (const auto& pr : map)
- {
- REQUIRE(vcpkg::Strings::b32_encode(pr.first) == pr.second);
- }
-}
-
-TEST_CASE ("split by char", "[strings]")
-{
- using vcpkg::Strings::split;
- using result_t = std::vector<std::string>;
- REQUIRE(split(",,,,,,", ',').empty());
- REQUIRE(split(",,a,,b,,", ',') == result_t{"a", "b"});
- REQUIRE(split("hello world", ' ') == result_t{"hello", "world"});
- REQUIRE(split(" hello world ", ' ') == result_t{"hello", "world"});
- REQUIRE(split("no delimiters", ',') == result_t{"no delimiters"});
-}
-
-TEST_CASE ("find_first_of", "[strings]")
-{
- using vcpkg::Strings::find_first_of;
- REQUIRE(find_first_of("abcdefg", "hij") == std::string());
- REQUIRE(find_first_of("abcdefg", "a") == std::string("abcdefg"));
- REQUIRE(find_first_of("abcdefg", "g") == std::string("g"));
- REQUIRE(find_first_of("abcdefg", "bg") == std::string("bcdefg"));
- REQUIRE(find_first_of("abcdefg", "gb") == std::string("bcdefg"));
-}
-
-TEST_CASE ("edit distance", "[strings]")
-{
- using vcpkg::Strings::byte_edit_distance;
- REQUIRE(byte_edit_distance("", "") == 0);
- REQUIRE(byte_edit_distance("a", "a") == 0);
- REQUIRE(byte_edit_distance("abcd", "abcd") == 0);
- REQUIRE(byte_edit_distance("aaa", "aa") == 1);
- REQUIRE(byte_edit_distance("aa", "aaa") == 1);
- REQUIRE(byte_edit_distance("abcdef", "bcdefa") == 2);
- REQUIRE(byte_edit_distance("hello", "world") == 4);
- REQUIRE(byte_edit_distance("CAPITAL", "capital") == 7);
- REQUIRE(byte_edit_distance("", "hello") == 5);
- REQUIRE(byte_edit_distance("world", "") == 5);
-}
-
-TEST_CASE ("replace_all", "[strings]")
-{
- REQUIRE(vcpkg::Strings::replace_all("literal", "ter", "x") == "lixal");
-}
-
-TEST_CASE ("inplace_replace_all", "[strings]")
-{
- using vcpkg::Strings::inplace_replace_all;
- std::string target;
- inplace_replace_all(target, "", "content");
- REQUIRE(target.empty());
- target = "aa";
- inplace_replace_all(target, "a", "content");
- REQUIRE(target == "contentcontent");
- inplace_replace_all(target, "content", "");
- REQUIRE(target.empty());
- target = "ababababa";
- inplace_replace_all(target, "aba", "X");
- REQUIRE(target == "XbXba");
- target = "ababababa";
- inplace_replace_all(target, "aba", "aba");
- REQUIRE(target == "ababababa");
-}
-
-TEST_CASE ("inplace_replace_all(char)", "[strings]")
-{
- using vcpkg::Strings::inplace_replace_all;
- static_assert(noexcept(inplace_replace_all(std::declval<std::string&>(), 'a', 'a')));
-
- std::string target;
- inplace_replace_all(target, ' ', '?');
- REQUIRE(target.empty());
- target = "hello";
- inplace_replace_all(target, 'l', 'w');
- REQUIRE(target == "hewwo");
- inplace_replace_all(target, 'w', 'w');
- REQUIRE(target == "hewwo");
- inplace_replace_all(target, 'x', '?');
- REQUIRE(target == "hewwo");
-}
diff --git a/toolsrc/src/vcpkg-test/stringview.cpp b/toolsrc/src/vcpkg-test/stringview.cpp
deleted file mode 100644
index 953a7de99..000000000
--- a/toolsrc/src/vcpkg-test/stringview.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/stringview.h>
-
-template<std::size_t N>
-static vcpkg::StringView sv(const char (&cstr)[N])
-{
- return cstr;
-}
-
-TEST_CASE ("string view operator==", "[stringview]")
-{
- // these are due to a bug in operator==
- // see commit 782723959399a1a0725ac49
- REQUIRE(sv("hey") != sv("heys"));
- REQUIRE(sv("heys") != sv("hey"));
- REQUIRE(sv("hey") == sv("hey"));
- REQUIRE(sv("hey") != sv("hex"));
-}
diff --git a/toolsrc/src/vcpkg-test/system.cpp b/toolsrc/src/vcpkg-test/system.cpp
deleted file mode 100644
index 4c8b533bc..000000000
--- a/toolsrc/src/vcpkg-test/system.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-#include <vcpkg/base/system_headers.h>
-
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/optional.h>
-#include <vcpkg/base/strings.h>
-#include <vcpkg/base/stringview.h>
-#include <vcpkg/base/system.h>
-#include <vcpkg/base/system.process.h>
-#include <vcpkg/base/zstringview.h>
-
-#include <string>
-
-#if defined(_MSC_VER)
-#pragma warning(disable : 6237)
-#endif
-
-using vcpkg::nullopt;
-using vcpkg::Optional;
-using vcpkg::StringView;
-using vcpkg::ZStringView;
-using vcpkg::Checks::check_exit;
-using vcpkg::System::CPUArchitecture;
-using vcpkg::System::get_environment_variable;
-using vcpkg::System::guess_visual_studio_prompt_target_architecture;
-using vcpkg::System::set_environment_variable;
-using vcpkg::System::to_cpu_architecture;
-
-namespace
-{
- struct environment_variable_resetter
- {
- explicit environment_variable_resetter(ZStringView varname_)
- : varname(varname_), old_value(get_environment_variable(varname))
- {
- }
-
- ~environment_variable_resetter() { set_environment_variable(varname, old_value); }
-
- environment_variable_resetter(const environment_variable_resetter&) = delete;
- environment_variable_resetter& operator=(const environment_variable_resetter&) = delete;
-
- private:
- ZStringView varname;
- Optional<std::string> old_value;
- };
-}
-
-TEST_CASE ("[to_cpu_architecture]", "system")
-{
- struct test_case
- {
- Optional<CPUArchitecture> expected;
- StringView input;
- };
-
- const test_case test_cases[] = {
- {CPUArchitecture::X86, "x86"},
- {CPUArchitecture::X86, "X86"},
- {CPUArchitecture::X64, "x64"},
- {CPUArchitecture::X64, "X64"},
- {CPUArchitecture::X64, "AmD64"},
- {CPUArchitecture::ARM, "ARM"},
- {CPUArchitecture::ARM64, "ARM64"},
- {nullopt, "ARM6"},
- {nullopt, "AR"},
- {nullopt, "Intel"},
- };
-
- for (auto&& instance : test_cases)
- {
- CHECK(to_cpu_architecture(instance.input) == instance.expected);
- }
-}
-
-TEST_CASE ("from_cpu_architecture", "[system]")
-{
- struct test_case
- {
- CPUArchitecture input;
- ZStringView expected;
- };
-
- const test_case test_cases[] = {
- {CPUArchitecture::X86, "x86"},
- {CPUArchitecture::X64, "x64"},
- {CPUArchitecture::ARM, "arm"},
- {CPUArchitecture::ARM64, "arm64"},
- };
-
- for (auto&& instance : test_cases)
- {
- CHECK(to_zstring_view(instance.input) == instance.expected);
- }
-}
-
-TEST_CASE ("guess_visual_studio_prompt", "[system]")
-{
- environment_variable_resetter reset_VSCMD_ARG_TGT_ARCH{"VSCMD_ARG_TGT_ARCH"};
- environment_variable_resetter reset_VCINSTALLDIR{"VCINSTALLDIR"};
- environment_variable_resetter reset_Platform{"Platform"};
-
- set_environment_variable("Platform", "x86"); // ignored if VCINSTALLDIR unset
- set_environment_variable("VCINSTALLDIR", nullopt);
- set_environment_variable("VSCMD_ARG_TGT_ARCH", nullopt);
- CHECK(!guess_visual_studio_prompt_target_architecture().has_value());
- set_environment_variable("VSCMD_ARG_TGT_ARCH", "x86");
- CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X86);
- set_environment_variable("VSCMD_ARG_TGT_ARCH", "x64");
- CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X64);
- set_environment_variable("VSCMD_ARG_TGT_ARCH", "arm");
- CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::ARM);
- set_environment_variable("VSCMD_ARG_TGT_ARCH", "arm64");
- CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::ARM64);
-
- // check that apparent "nested" prompts defer to "vsdevcmd"
- set_environment_variable("VCINSTALLDIR", "anything");
- CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::ARM64);
- set_environment_variable("VSCMD_ARG_TGT_ARCH", nullopt);
- set_environment_variable("Platform", nullopt);
- CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X86);
- set_environment_variable("Platform", "x86");
- CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X86);
- set_environment_variable("Platform", "x64");
- CHECK(guess_visual_studio_prompt_target_architecture().value_or_exit(VCPKG_LINE_INFO) == CPUArchitecture::X64);
-}
-
-TEST_CASE ("cmdlinebuilder", "[system]")
-{
- using vcpkg::System::Command;
-
- Command cmd;
- cmd.path_arg(fs::u8path("relative/path.exe"));
- cmd.string_arg("abc");
- cmd.string_arg("hello world!");
- cmd.string_arg("|");
- cmd.string_arg(";");
- REQUIRE(cmd.command_line() == "relative/path.exe abc \"hello world!\" \"|\" \";\"");
-
- cmd.clear();
-
- cmd.path_arg(fs::u8path("trailing\\slash\\"));
- cmd.string_arg("inner\"quotes");
-#ifdef _WIN32
- REQUIRE(cmd.command_line() == "\"trailing\\slash\\\\\" \"inner\\\"quotes\"");
-#else
- REQUIRE(cmd.command_line() == "\"trailing\\\\slash\\\\\" \"inner\\\"quotes\"");
-#endif
-}
diff --git a/toolsrc/src/vcpkg-test/uint128.cpp b/toolsrc/src/vcpkg-test/uint128.cpp
deleted file mode 100644
index a13b25e4f..000000000
--- a/toolsrc/src/vcpkg-test/uint128.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/uint128.h>
-
-TEST_CASE ("uint128 constructor and assign", "[uint128]")
-{
- vcpkg::UInt128 x = 120;
- REQUIRE(x.bottom_64_bits() == 120);
- REQUIRE(x.top_64_bits() == 0);
-
- x = 3201;
- REQUIRE(x.bottom_64_bits() == 3201);
- REQUIRE(x.top_64_bits() == 0);
-
- x = 0xFFFF'FFFF'FFFF'FFFF;
- REQUIRE(x.bottom_64_bits() == 0xFFFF'FFFF'FFFF'FFFF);
- REQUIRE(x.top_64_bits() == 0);
-}
-
-TEST_CASE ("uint128 add-assign", "[uint128]")
-{
- vcpkg::UInt128 x = 0xFFFF'FFFF'FFFF'FFFF;
- x += 1;
- REQUIRE(x.bottom_64_bits() == 0);
- REQUIRE(x.top_64_bits() == 1);
-}
-
-TEST_CASE ("uint128 shl-assign", "[uint128]")
-{
- vcpkg::UInt128 x = 0xFFFF'FFFF'FFFF'FFFF;
- x <<= 32;
- REQUIRE(x.bottom_64_bits() == 0xFFFF'FFFF'0000'0000);
- REQUIRE(x.top_64_bits() == 0x0000'0000'FFFF'FFFF);
-
- x <<= 60;
- REQUIRE(x.bottom_64_bits() == 0);
- REQUIRE(x.top_64_bits() == 0xFFFF'FFFF'F000'0000);
-
- x = 1;
- x <<= 96;
- REQUIRE(x.bottom_64_bits() == 0);
- REQUIRE(x.top_64_bits() == (uint64_t(1) << 32));
-}
-
-TEST_CASE ("uint128 shr-assign", "[uint128]")
-{
- vcpkg::UInt128 x = 0xFFFF'FFFF'FFFF'FFFF;
- x <<= 64;
- REQUIRE(x.bottom_64_bits() == 0x0000'0000'0000'0000);
- REQUIRE(x.top_64_bits() == 0xFFFF'FFFF'FFFF'FFFF);
-
- x >>= 32;
- REQUIRE(x.bottom_64_bits() == 0xFFFF'FFFF'0000'0000);
- REQUIRE(x.top_64_bits() == 0x0000'0000'FFFF'FFFF);
-
- x >>= 60;
- REQUIRE(x.bottom_64_bits() == 0x0000'000F'FFFF'FFFF);
- REQUIRE(x.top_64_bits() == 0x0000'0000'0000'0000);
-
- x = 0x8000'0000'0000'0000;
- x <<= 64;
- REQUIRE(x.bottom_64_bits() == 0);
- REQUIRE(x.top_64_bits() == 0x8000'0000'0000'0000);
-
- x >>= 96;
- REQUIRE(x.bottom_64_bits() == (uint64_t(1) << 31));
- REQUIRE(x.top_64_bits() == 0);
-}
diff --git a/toolsrc/src/vcpkg-test/update.cpp b/toolsrc/src/vcpkg-test/update.cpp
deleted file mode 100644
index bce663d28..000000000
--- a/toolsrc/src/vcpkg-test/update.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/sortedvector.h>
-
-#include <vcpkg/portfileprovider.h>
-#include <vcpkg/statusparagraphs.h>
-#include <vcpkg/update.h>
-
-#include <vcpkg-test/util.h>
-
-using namespace vcpkg;
-using namespace vcpkg::Update;
-using namespace vcpkg::Test;
-
-using Pgh = std::vector<std::unordered_map<std::string, std::string>>;
-
-TEST_CASE ("find outdated packages basic", "[update]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(make_status_pgh("a"));
- status_paragraphs.back()->package.version = "2";
-
- StatusParagraphs status_db(std::move(status_paragraphs));
-
- std::unordered_map<std::string, SourceControlFileLocation> map;
- auto scf = unwrap(test_parse_control_file({{{"Source", "a"}, {"Version", "0"}}}));
- map.emplace("a", SourceControlFileLocation{std::move(scf), ""});
- PortFileProvider::MapPortFileProvider provider(map);
-
- auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
- &OutdatedPackage::compare_by_name);
-
- REQUIRE(pkgs.size() == 1);
- REQUIRE(pkgs[0].version_diff.left.to_string() == "2");
- REQUIRE(pkgs[0].version_diff.right.to_string() == "0");
-}
-
-TEST_CASE ("find outdated packages features", "[update]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(make_status_pgh("a"));
- status_paragraphs.back()->package.version = "2";
-
- status_paragraphs.push_back(make_status_feature_pgh("a", "b"));
- status_paragraphs.back()->package.version = "2";
-
- StatusParagraphs status_db(std::move(status_paragraphs));
-
- std::unordered_map<std::string, SourceControlFileLocation> map;
- auto scf = unwrap(test_parse_control_file({{{"Source", "a"}, {"Version", "0"}}}));
- map.emplace("a", SourceControlFileLocation{std::move(scf), ""});
- PortFileProvider::MapPortFileProvider provider(map);
-
- auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
- &OutdatedPackage::compare_by_name);
-
- REQUIRE(pkgs.size() == 1);
- REQUIRE(pkgs[0].version_diff.left.to_string() == "2");
- REQUIRE(pkgs[0].version_diff.right.to_string() == "0");
-}
-
-TEST_CASE ("find outdated packages features 2", "[update]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(make_status_pgh("a"));
- status_paragraphs.back()->package.version = "2";
-
- status_paragraphs.push_back(make_status_feature_pgh("a", "b"));
- status_paragraphs.back()->package.version = "0";
- status_paragraphs.back()->state = InstallState::NOT_INSTALLED;
- status_paragraphs.back()->want = Want::PURGE;
-
- StatusParagraphs status_db(std::move(status_paragraphs));
-
- std::unordered_map<std::string, SourceControlFileLocation> map;
- auto scf = unwrap(test_parse_control_file({{{"Source", "a"}, {"Version", "0"}}}));
- map.emplace("a", SourceControlFileLocation{std::move(scf), ""});
- PortFileProvider::MapPortFileProvider provider(map);
-
- auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
- &OutdatedPackage::compare_by_name);
-
- REQUIRE(pkgs.size() == 1);
- REQUIRE(pkgs[0].version_diff.left.to_string() == "2");
- REQUIRE(pkgs[0].version_diff.right.to_string() == "0");
-}
-
-TEST_CASE ("find outdated packages none", "[update]")
-{
- std::vector<std::unique_ptr<StatusParagraph>> status_paragraphs;
- status_paragraphs.push_back(make_status_pgh("a"));
- status_paragraphs.back()->package.version = "2";
-
- StatusParagraphs status_db(std::move(status_paragraphs));
-
- std::unordered_map<std::string, SourceControlFileLocation> map;
- auto scf = unwrap(test_parse_control_file({{{"Source", "a"}, {"Version", "2"}}}));
- map.emplace("a", SourceControlFileLocation{std::move(scf), ""});
- PortFileProvider::MapPortFileProvider provider(map);
-
- auto pkgs = SortedVector<OutdatedPackage>(Update::find_outdated_packages(provider, status_db),
- &OutdatedPackage::compare_by_name);
-
- REQUIRE(pkgs.size() == 0);
-}
diff --git a/toolsrc/src/vcpkg-test/util.cpp b/toolsrc/src/vcpkg-test/util.cpp
deleted file mode 100644
index 73ff9db5c..000000000
--- a/toolsrc/src/vcpkg-test/util.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-#include <vcpkg/base/system_headers.h>
-
-#include <catch2/catch.hpp>
-
-#include <vcpkg/base/checks.h>
-#include <vcpkg/base/files.h>
-#include <vcpkg/base/util.h>
-
-#include <vcpkg/statusparagraph.h>
-
-#include <vcpkg-test/util.h>
-
-// used to get the implementation specific compiler flags (i.e., __cpp_lib_filesystem)
-#include <ciso646>
-#include <iostream>
-#include <memory>
-
-#if defined(_WIN32)
-#include <windows.h>
-#endif
-
-#define FILESYSTEM_SYMLINK_STD 0
-#define FILESYSTEM_SYMLINK_UNIX 1
-#define FILESYSTEM_SYMLINK_NONE 2
-
-#if VCPKG_USE_STD_FILESYSTEM
-
-#define FILESYSTEM_SYMLINK FILESYSTEM_SYMLINK_STD
-
-#elif !defined(_MSC_VER)
-
-#define FILESYSTEM_SYMLINK FILESYSTEM_SYMLINK_UNIX
-
-#else
-
-#define FILESYSTEM_SYMLINK FILESYSTEM_SYMLINK_NONE
-
-#endif
-
-namespace vcpkg::Test
-{
- const Triplet X86_WINDOWS = Triplet::from_canonical_name("x86-windows");
- const Triplet X64_WINDOWS = Triplet::from_canonical_name("x64-windows");
- const Triplet X86_UWP = Triplet::from_canonical_name("x86-uwp");
- const Triplet ARM_UWP = Triplet::from_canonical_name("arm-uwp");
- const Triplet X64_ANDROID = Triplet::from_canonical_name("x64-android");
-
- 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 = test_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,
- const char* triplet)
- {
- return std::make_unique<StatusParagraph>(Parse::Paragraph{{"Package", {name, {}}},
- {"Version", {"1", {}}},
- {"Architecture", {triplet, {}}},
- {"Multi-Arch", {"same", {}}},
- {"Depends", {depends, {}}},
- {"Default-Features", {default_features, {}}},
- {"Status", {"install ok installed", {}}}});
- }
-
- std::unique_ptr<StatusParagraph> make_status_feature_pgh(const char* name,
- const char* feature,
- const char* depends,
- const char* triplet)
- {
- return std::make_unique<StatusParagraph>(Parse::Paragraph{{"Package", {name, {}}},
- {"Feature", {feature, {}}},
- {"Architecture", {triplet, {}}},
- {"Multi-Arch", {"same", {}}},
- {"Depends", {depends, {}}},
- {"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)
- {
- const auto& name = scfl.source_control_file->core_paragraph->name;
- REQUIRE(map.find(name) == map.end());
- map.emplace(name, std::move(scfl));
- return {name, triplet};
- }
-
- static AllowSymlinks internal_can_create_symlinks() noexcept
- {
-#if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_NONE
- return AllowSymlinks::No;
-#elif FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_UNIX
- return AllowSymlinks::Yes;
-#elif !defined(_WIN32) // FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_STD
- return AllowSymlinks::Yes;
-#else
- constexpr static const wchar_t regkey[] = LR"(SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock)";
- constexpr static const wchar_t regkey_member[] = LR"(AllowDevelopmentWithoutDevLicense)";
-
- DWORD data;
- DWORD dataSize = sizeof(data);
- const auto status =
- RegGetValueW(HKEY_LOCAL_MACHINE, regkey, regkey_member, RRF_RT_DWORD, nullptr, &data, &dataSize);
-
- if (status == ERROR_SUCCESS && data == 1)
- {
- return AllowSymlinks::Yes;
- }
- else
- {
- std::cout << "Symlinks are not allowed on this system\n";
- return AllowSymlinks::No;
- }
-#endif
- }
- const static AllowSymlinks CAN_CREATE_SYMLINKS = internal_can_create_symlinks();
-
- AllowSymlinks can_create_symlinks() noexcept { return CAN_CREATE_SYMLINKS; }
-
- static fs::path internal_base_temporary_directory()
- {
-#if defined(_WIN32)
- wchar_t* tmp = static_cast<wchar_t*>(std::calloc(32'767, 2));
-
- if (!GetEnvironmentVariableW(L"TEMP", tmp, 32'767))
- {
- std::cerr << "No temporary directory found.\n";
- std::abort();
- }
-
- fs::path result = tmp;
- std::free(tmp);
-
- return result / L"vcpkg-test";
-#else
- return "/tmp/vcpkg-test";
-#endif
- }
-
- const fs::path& base_temporary_directory() noexcept
- {
- const static fs::path BASE_TEMPORARY_DIRECTORY = internal_base_temporary_directory();
- return BASE_TEMPORARY_DIRECTORY;
- }
-
-#if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_NONE
- constexpr char no_filesystem_message[] =
- "<filesystem> doesn't exist; on windows, we don't attempt to use the win32 calls to create symlinks";
-#endif
-
- void create_symlink(const fs::path& target, const fs::path& file, std::error_code& ec)
- {
-#if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_STD
- if (can_create_symlinks())
- {
- fs::path targetp = target.native();
- fs::path filep = file.native();
-
- fs::stdfs::create_symlink(targetp, filep, ec);
- }
- else
- {
- vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, "Symlinks are not allowed on this system");
- }
-#elif FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_UNIX
- if (symlink(target.c_str(), file.c_str()) != 0)
- {
- ec.assign(errno, std::system_category());
- }
-#else
- (void)target;
- (void)file;
- (void)ec;
- vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message);
-#endif
- }
-
- void create_directory_symlink(const fs::path& target, const fs::path& file, std::error_code& ec)
- {
-#if FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_STD
- if (can_create_symlinks())
- {
- std::filesystem::path targetp = target.native();
- std::filesystem::path filep = file.native();
-
- std::filesystem::create_directory_symlink(targetp, filep, ec);
- }
- else
- {
- vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, "Symlinks are not allowed on this system");
- }
-#elif FILESYSTEM_SYMLINK == FILESYSTEM_SYMLINK_UNIX
- ::vcpkg::Test::create_symlink(target, file, ec);
-#else
- (void)target;
- (void)file;
- (void)ec;
- vcpkg::Checks::exit_with_message(VCPKG_LINE_INFO, no_filesystem_message);
-#endif
- }
-}
diff --git a/toolsrc/src/vcpkg-test/versionplan.cpp b/toolsrc/src/vcpkg-test/versionplan.cpp
deleted file mode 100644
index 2f82d21b4..000000000
--- a/toolsrc/src/vcpkg-test/versionplan.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-#include <catch2/catch.hpp>
-
-#include <vcpkg/dependencies.h>
-#include <vcpkg/paragraphparser.h>
-#include <vcpkg/portfileprovider.h>
-#include <vcpkg/sourceparagraph.h>
-
-#include <vcpkg-test/mockcmakevarprovider.h>
-#include <vcpkg-test/util.h>
-
-using namespace vcpkg;
-using namespace vcpkg::Parse;
-
-TEST_CASE ("parse depends", "[dependencies]")
-{
- auto w = parse_dependencies_list("liba (windows)");
- REQUIRE(w);
- auto& v = *w.get();
- REQUIRE(v.size() == 1);
- REQUIRE(v.at(0).name == "liba");
- REQUIRE(v.at(0).platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}}));
- REQUIRE(v.at(0).platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "WindowsStore"}}));
- REQUIRE(!v.at(0).platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Darwin"}}));
-}
-
-TEST_CASE ("filter depends", "[dependencies]")
-{
- 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_ = parse_dependencies_list("liba (!uwp), libb, libc (uwp)");
- REQUIRE(deps_);
- auto& deps = *deps_.get();
- auto v = filter_dependencies(deps, Test::X64_WINDOWS, x64_win_cmake_vars);
- REQUIRE(v.size() == 2);
- REQUIRE(v.at(0).package_spec.name() == "liba");
- REQUIRE(v.at(1).package_spec.name() == "libb");
-
- auto v2 = filter_dependencies(deps, Test::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_dependencies_list("libwebp[anim, gif2webp, img2webp, info, mux, nearlossless, "
- "simd, cwebp, dwebp], libwebp[vwebp-sdl, extras] (!osx)");
- REQUIRE(u_);
- auto& v = *u_.get();
- REQUIRE(v.size() == 2);
- auto&& a0 = v.at(0);
- REQUIRE(a0.name == "libwebp");
- REQUIRE(a0.features.size() == 9);
- REQUIRE(a0.platform.is_empty());
-
- auto&& a1 = v.at(1);
- REQUIRE(a1.name == "libwebp");
- REQUIRE(a1.features.size() == 2);
- REQUIRE(!a1.platform.is_empty());
- REQUIRE(a1.platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", ""}}));
- REQUIRE(a1.platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}}));
- REQUIRE_FALSE(a1.platform.evaluate({{"VCPKG_CMAKE_SYSTEM_NAME", "Darwin"}}));
-}
-
-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{{"a", Triplet::from_canonical_name("x64-linux")}, {}};
- 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"});
-}
-
-TEST_CASE ("resolve_deps_as_top_level", "[dependencies]")
-{
- using namespace Test;
- PackageSpecMap spec_map;
- FullPackageSpec spec_a{spec_map.emplace("a", "b, b[b1] (linux)"), {}};
- FullPackageSpec spec_b{spec_map.emplace("b", "", {{"b1", ""}}), {}};
- FullPackageSpec spec_c{spec_map.emplace("c", "b", {{"c1", "b[b1]"}, {"c2", "c[c1], a"}}, {"c1"}), {"core"}};
- FullPackageSpec spec_d{spec_map.emplace("d", "c[core]"), {}};
-
- PortFileProvider::MapPortFileProvider map_port{spec_map.map};
- MockCMakeVarProvider var_provider;
- Triplet t_linux = Triplet::from_canonical_name("x64-linux");
- var_provider.dep_info_vars[{"a", t_linux}].emplace("VCPKG_CMAKE_SYSTEM_NAME", "Linux");
- {
- auto deps = vcpkg::Dependencies::resolve_deps_as_top_level(
- *spec_map.map.at("a").source_control_file, Test::X86_WINDOWS, {}, var_provider);
- REQUIRE(deps.size() == 1);
- REQUIRE(deps.at(0) == spec_b);
- }
- {
- auto deps = vcpkg::Dependencies::resolve_deps_as_top_level(
- *spec_map.map.at("a").source_control_file, t_linux, {}, var_provider);
- REQUIRE(deps.size() == 1);
- REQUIRE(deps.at(0) == FullPackageSpec({"b", t_linux}, {"b1"}));
- }
- {
- // without defaults
- auto deps = vcpkg::Dependencies::resolve_deps_as_top_level(
- *spec_map.map.at("c").source_control_file, Test::X86_WINDOWS, {}, var_provider);
- REQUIRE(deps.size() == 1);
- REQUIRE(deps.at(0) == spec_b);
- }
- FullPackageSpec spec_b_with_b1{spec_b.package_spec, {"b1"}};
- {
- // with defaults of c (c1)
- auto deps = vcpkg::Dependencies::resolve_deps_as_top_level(
- *spec_map.map.at("c").source_control_file, Test::X86_WINDOWS, {"default"}, var_provider);
- REQUIRE(deps.size() == 1);
- REQUIRE(deps.at(0) == spec_b_with_b1);
- }
- {
- // with c1
- auto deps = vcpkg::Dependencies::resolve_deps_as_top_level(
- *spec_map.map.at("c").source_control_file, Test::X86_WINDOWS, {"c1"}, var_provider);
- REQUIRE(deps.size() == 1);
- REQUIRE(deps.at(0) == spec_b_with_b1);
- }
- {
- // with c2 implying c1
- auto deps = vcpkg::Dependencies::resolve_deps_as_top_level(
- *spec_map.map.at("c").source_control_file, Test::X86_WINDOWS, {"c2"}, var_provider);
- REQUIRE(deps.size() == 2);
- REQUIRE(deps.at(0) == spec_a);
- REQUIRE(deps.at(1) == spec_b_with_b1);
- }
- {
- // d -> c[core]
- auto deps = vcpkg::Dependencies::resolve_deps_as_top_level(
- *spec_map.map.at("d").source_control_file, Test::X86_WINDOWS, {}, var_provider);
- REQUIRE(deps.size() == 1);
- REQUIRE(deps.at(0) == spec_c);
- }
-}