aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/vcpkg-test/manifests.cpp
diff options
context:
space:
mode:
authorras0219 <533828+ras0219@users.noreply.github.com>2020-10-21 14:46:48 -0700
committerGitHub <noreply@github.com>2020-10-21 14:46:48 -0700
commit291df751258928bc021a5251585c8733328edf25 (patch)
treee6ff3a8819d9d65ba5faa2bfb76108ade17926fb /toolsrc/src/vcpkg-test/manifests.cpp
parent998f86a82946591b1e80ade99a52699967dc66af (diff)
downloadvcpkg-291df751258928bc021a5251585c8733328edf25.tar.gz
vcpkg-291df751258928bc021a5251585c8733328edf25.zip
[vcpkg] Add `versions` feature flag and version field manifest parsing (#14079)
* [vcpkg] Add `versions` feature flag and version field manifest parsing * Introduce FeatureFlagSettings struct to more easily access feature flags throughout the program * To avoid users accidentally starting to write "version" instead of "version-string" in their manifests, vcpkg explicitly detects and prevents usage of ports with schemes other than "String" * Drive-by fix of copiable SourceControlFileLocation and an exposed use-after-move bug This code is largely extracted from PR #13777 Co-authored-by: Victor Romero <romerosanchezv@gmail.com> * [vcpkg] Address CR Comments. Fix test crash on Linux. Co-authored-by: Robert Schumacher <roschuma@microsoft.com> Co-authored-by: Victor Romero <romerosanchezv@gmail.com>
Diffstat (limited to 'toolsrc/src/vcpkg-test/manifests.cpp')
-rw-r--r--toolsrc/src/vcpkg-test/manifests.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg-test/manifests.cpp b/toolsrc/src/vcpkg-test/manifests.cpp
index 77f4eb440..be087584e 100644
--- a/toolsrc/src/vcpkg-test/manifests.cpp
+++ b/toolsrc/src/vcpkg-test/manifests.cpp
@@ -39,6 +39,7 @@ static Parse::ParseExpected<SourceControlFile> test_parse_manifest(StringView sv
{
print_error_message(res.error());
}
+ REQUIRE(res.has_value() == !expect_fail);
return res;
}
@@ -59,6 +60,57 @@ TEST_CASE ("manifest construct minimum", "[manifests]")
REQUIRE(pgh.core_paragraph->dependencies.empty());
}
+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_CASE ("manifest construct maximum", "[manifests]")
{
auto m_pgh = test_parse_manifest(R"json({