aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test/binarycaching.cpp
diff options
context:
space:
mode:
authorras0219 <robertallenschumacher@gmail.com>2020-07-01 11:36:09 -0700
committerGitHub <noreply@github.com>2020-07-01 11:36:09 -0700
commit135f91de1eef9e906eb7a5bcf323f6eff9a2b5da (patch)
tree71dfb029d57d3a205a8685bd357586148480d09c /toolsrc/src/vcpkg-test/binarycaching.cpp
parent42f70a42766ff3da9c0464dd78f1eed0e8ac3789 (diff)
downloadvcpkg-135f91de1eef9e906eb7a5bcf323f6eff9a2b5da.tar.gz
vcpkg-135f91de1eef9e906eb7a5bcf323f6eff9a2b5da.zip
[vcpkg] Implement --x-write-nuget-packages-config= setting for `install` and `x-set-installed` (#12138)
* [vcpkg] Implement --x-write-nuget-packages-config= setting for `install` and `x-set-installed`. * [vcpkg] Add end-to-end testing suite for install, remove, and binary caching * [vcpkg] Define `$TestingRoot in end-to-end-tests.ps1 * [vcpkg] Address CR comments Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'toolsrc/src/vcpkg-test/binarycaching.cpp')
-rw-r--r--toolsrc/src/vcpkg-test/binarycaching.cpp88
1 files changed, 81 insertions, 7 deletions
diff --git a/toolsrc/src/vcpkg-test/binarycaching.cpp b/toolsrc/src/vcpkg-test/binarycaching.cpp
index 817b85e03..b220b5ccb 100644
--- a/toolsrc/src/vcpkg-test/binarycaching.cpp
+++ b/toolsrc/src/vcpkg-test/binarycaching.cpp
@@ -1,10 +1,11 @@
#include <catch2/catch.hpp>
#include <vcpkg/binarycaching.private.h>
+#include <vcpkg/binarycaching.h>
#include <vcpkg/base/files.h>
+#include <vcpkg/dependencies.h>
#include <vcpkg/vcpkgcmdarguments.h>
#include <vcpkg/sourceparagraph.h>
#include <vcpkg/paragraphs.h>
-#include <vcpkg/dependencies.h>
#include <string>
using namespace vcpkg;
@@ -96,9 +97,9 @@ Features: a, b
Dependencies:
</description>
<packageTypes><packageType name="vcpkg"/></packageTypes>
- </metadata>
+ </metadata>
<files><file src=")" PKGPATH R"(" target=""/></files>
- </package>
+</package>
)";
auto expected_lines = Strings::split(expected, '\n');
auto nuspec_lines = Strings::split(nuspec, '\n');
@@ -123,8 +124,14 @@ TEST_CASE ("XmlSerializer", "[XmlSerializer]")
xml = XmlSerializer();
xml.emit_declaration();
- xml.start_complex_open_tag("a").text_attr("b", "<").text_attr("c", " ").finish_self_closing_complex_tag();
- REQUIRE(xml.buf == R"(<?xml version="1.0" encoding="utf-8"?><a b="&lt;" c=" "/>)");
+ 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();
@@ -134,5 +141,72 @@ TEST_CASE ("XmlSerializer", "[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");
-} \ No newline at end of file
+ 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::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", Triplet::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-packageabi"/>
+</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::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", Triplet::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-packageabi"/>
+ <package id="zlib2_x64-android" version="1.52.0-packageabi2"/>
+</packages>
+)");
+}