diff --git a/include/vcpkg-test/util.h b/include/vcpkg-test/util.h index 8d336cffd7..1b98ad1042 100644 --- a/include/vcpkg-test/util.h +++ b/include/vcpkg-test/util.h @@ -134,19 +134,6 @@ namespace vcpkg::Test PackageSpec emplace(vcpkg::SourceControlFileAndLocation&& scfl); }; - template - T&& unwrap(vcpkg::ExpectedT&& p) - { - return std::move(p).value_or_exit(VCPKG_LINE_INFO); - } - - template - T&& unwrap(vcpkg::Optional&& opt) - { - REQUIRE(opt.has_value()); - return std::move(*opt.get()); - } - inline std::vector parse_test_fspecs(StringView sv, Triplet t = X86_WINDOWS) { std::vector ret; @@ -155,7 +142,7 @@ namespace vcpkg::Test { auto opt = parse_qualified_specifier(parser); REQUIRE(opt.has_value()); - ret.push_back(unwrap(opt.get()->to_full_spec(t, ImplicitDefault::YES))); + ret.push_back(opt.get()->to_full_spec(t, ImplicitDefault::YES).value_or_exit(VCPKG_LINE_INFO)); } return ret; } diff --git a/include/vcpkg/base/expected.h b/include/vcpkg/base/expected.h index e72d4e005f..7407876bb5 100644 --- a/include/vcpkg/base/expected.h +++ b/include/vcpkg/base/expected.h @@ -14,6 +14,11 @@ namespace vcpkg { + struct Unit + { + // A meaningless type intended to be used with Expected when there is no meaningful value. + }; + struct ExpectedLeftTag { }; diff --git a/include/vcpkg/base/fwd/expected.h b/include/vcpkg/base/fwd/expected.h index ae7a30ac40..23152f36ed 100644 --- a/include/vcpkg/base/fwd/expected.h +++ b/include/vcpkg/base/fwd/expected.h @@ -4,6 +4,7 @@ namespace vcpkg { + struct Unit; struct ExpectedLeftTag; struct ExpectedRightTag; diff --git a/include/vcpkg/vcpkgpaths.h b/include/vcpkg/vcpkgpaths.h index 94f53ffa5d..b650235238 100644 --- a/include/vcpkg/vcpkgpaths.h +++ b/include/vcpkg/vcpkgpaths.h @@ -150,7 +150,7 @@ namespace vcpkg // Use {treeish} of "HEAD" for the default branch ExpectedS git_fetch_from_remote_registry(StringView uri, StringView treeish) const; // runs `git fetch {uri} {treeish}` - Optional git_fetch(StringView uri, StringView treeish) const; + ExpectedS git_fetch(StringView uri, StringView treeish) const; ExpectedS git_show_from_remote_registry(StringView hash, const Path& relative_path_to_file) const; ExpectedS git_find_object_id_for_remote_registry_path(StringView hash, const Path& relative_path_to_file) const; diff --git a/src/vcpkg-test/configparser.cpp b/src/vcpkg-test/configparser.cpp index ac8c91d617..7f5157f778 100644 --- a/src/vcpkg-test/configparser.cpp +++ b/src/vcpkg-test/configparser.cpp @@ -428,40 +428,46 @@ TEST_CASE ("AssetConfigParser azurl provider", "[assetconfigparser]") CHECK(empty.m_read_headers.empty()); } { - DownloadManagerConfig dm = Test::unwrap(parse_download_configuration("x-azurl,https://abc/123,foo")); + DownloadManagerConfig dm = + parse_download_configuration("x-azurl,https://abc/123,foo").value_or_exit(VCPKG_LINE_INFO); CHECK(dm.m_read_url_template == "https://abc/123/?foo"); CHECK(dm.m_read_headers.empty()); CHECK(dm.m_write_url_template == nullopt); } { - DownloadManagerConfig dm = Test::unwrap(parse_download_configuration("x-azurl,https://abc/123/,foo")); + DownloadManagerConfig dm = + parse_download_configuration("x-azurl,https://abc/123/,foo").value_or_exit(VCPKG_LINE_INFO); CHECK(dm.m_read_url_template == "https://abc/123/?foo"); CHECK(dm.m_read_headers.empty()); CHECK(dm.m_write_url_template == nullopt); CHECK(dm.m_secrets == std::vector{"foo"}); } { - DownloadManagerConfig dm = Test::unwrap(parse_download_configuration("x-azurl,https://abc/123,?foo")); + DownloadManagerConfig dm = + parse_download_configuration("x-azurl,https://abc/123,?foo").value_or_exit(VCPKG_LINE_INFO); CHECK(dm.m_read_url_template == "https://abc/123/?foo"); CHECK(dm.m_read_headers.empty()); CHECK(dm.m_write_url_template == nullopt); CHECK(dm.m_secrets == std::vector{"?foo"}); } { - DownloadManagerConfig dm = Test::unwrap(parse_download_configuration("x-azurl,https://abc/123")); + DownloadManagerConfig dm = + parse_download_configuration("x-azurl,https://abc/123").value_or_exit(VCPKG_LINE_INFO); CHECK(dm.m_read_url_template == "https://abc/123/"); CHECK(dm.m_read_headers.empty()); CHECK(dm.m_write_url_template == nullopt); } { - DownloadManagerConfig dm = Test::unwrap(parse_download_configuration("x-azurl,https://abc/123,,readwrite")); + DownloadManagerConfig dm = + parse_download_configuration("x-azurl,https://abc/123,,readwrite").value_or_exit(VCPKG_LINE_INFO); CHECK(dm.m_read_url_template == "https://abc/123/"); CHECK(dm.m_read_headers.empty()); CHECK(dm.m_write_url_template == "https://abc/123/"); Test::check_ranges(dm.m_write_headers, azure_blob_headers()); } { - DownloadManagerConfig dm = Test::unwrap(parse_download_configuration("x-azurl,https://abc/123,foo,readwrite")); + DownloadManagerConfig dm = + parse_download_configuration("x-azurl,https://abc/123,foo,readwrite").value_or_exit(VCPKG_LINE_INFO); CHECK(dm.m_read_url_template == "https://abc/123/?foo"); CHECK(dm.m_read_headers.empty()); CHECK(dm.m_write_url_template == "https://abc/123/?foo"); diff --git a/src/vcpkg-test/dependencies.cpp b/src/vcpkg-test/dependencies.cpp index c13132f81a..e4813b0114 100644 --- a/src/vcpkg-test/dependencies.cpp +++ b/src/vcpkg-test/dependencies.cpp @@ -92,17 +92,6 @@ struct MockVersionedPortfileProvider : PortFileProvider::IVersionedPortfileProvi } }; -template -T unwrap(ExpectedT e) -{ - if (!e.has_value()) - { - INFO(e.error()); - REQUIRE(false); - } - return std::move(*e.get()); -} - static void check_name_and_features(const Dependencies::InstallPlanAction& ipa, StringLiteral name, std::initializer_list features) @@ -143,7 +132,7 @@ static void check_semver_version(const ExpectedL& maybe_version, uint64_t patch, const std::vector& identifiers) { - auto actual_version = unwrap(maybe_version); + auto actual_version = maybe_version.value_or_exit(VCPKG_LINE_INFO); CHECK(actual_version.version_string == version_string); CHECK(actual_version.prerelease_string == prerelease_string); REQUIRE(actual_version.version.size() == 3); @@ -157,7 +146,7 @@ static void check_relaxed_version(const ExpectedL& maybe_version, const std::vector& version, const std::vector& identifiers = {}) { - auto actual_version = unwrap(maybe_version); + auto actual_version = maybe_version.value_or_exit(VCPKG_LINE_INFO); CHECK(actual_version.version == version); CHECK(actual_version.identifiers == identifiers); } @@ -166,7 +155,7 @@ static void check_date_version(const ExpectedL& maybe_version, const std::string& version_string, const std::vector& identifiers) { - auto actual_version = unwrap(maybe_version); + auto actual_version = maybe_version.value_or_exit(VCPKG_LINE_INFO); CHECK(actual_version.version_string == version_string); CHECK(actual_version.identifiers == identifiers); } @@ -275,7 +264,8 @@ TEST_CASE ("basic version install single", "[versionplan]") MockCMakeVarProvider var_provider; - auto install_plan = unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); REQUIRE(install_plan.install_actions.at(0).spec.name() == "a"); @@ -316,7 +306,8 @@ TEST_CASE ("basic version install scheme", "[versionplan]") MockCMakeVarProvider var_provider; - auto install_plan = unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); CHECK(install_plan.size() == 2); @@ -351,7 +342,8 @@ TEST_CASE ("basic version install scheme diamond", "[versionplan]") MockCMakeVarProvider var_provider; - auto install_plan = unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); CHECK(install_plan.size() == 4); @@ -388,14 +380,15 @@ TEST_CASE ("basic version install scheme baseline missing success", "[versionpla MockCMakeVarProvider var_provider; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2"}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2"}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"2", 0}); @@ -413,7 +406,8 @@ TEST_CASE ("basic version install scheme baseline", "[versionplan]") MockCMakeVarProvider var_provider; - auto install_plan = unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"a"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"2", 0}); @@ -475,14 +469,15 @@ TEST_CASE ("version install string port version", "[versionplan]") MockCMakeVarProvider var_provider; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2", 1}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2", 1}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"2", 1}); @@ -501,14 +496,15 @@ TEST_CASE ("version install string port version 2", "[versionplan]") MockCMakeVarProvider var_provider; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2", 0}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2", 0}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"2", 1}); @@ -533,14 +529,15 @@ TEST_CASE ("version install transitive string", "[versionplan]") MockCMakeVarProvider var_provider; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2", 1}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2", 1}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "b", {"2", 0}); @@ -561,14 +558,15 @@ TEST_CASE ("version install simple relaxed", "[versionplan]") MockCMakeVarProvider var_provider; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "3", 0}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "3", 0}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"3", 0}); @@ -591,14 +589,15 @@ TEST_CASE ("version install transitive relaxed", "[versionplan]") MockCMakeVarProvider var_provider; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "3", 0}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "3", 0}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "b", {"3", 0}); @@ -627,15 +626,16 @@ TEST_CASE ("version install diamond relaxed", "[versionplan]") MockCMakeVarProvider var_provider; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "3", 0}}, - Dependency{"b", {}, {}, {VersionConstraintKind::Minimum, "2", 1}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "3", 0}}, + Dependency{"b", {}, {}, {VersionConstraintKind::Minimum, "2", 1}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 3); check_name_and_version(install_plan.install_actions[0], "c", {"9", 2}); @@ -711,22 +711,22 @@ TEST_CASE ("version parse date", "[versionplan]") TEST_CASE ("version sort semver", "[versionplan]") { std::vector versions{ - unwrap(DotVersion::try_parse_semver("1.0.0")), - unwrap(DotVersion::try_parse_semver("0.0.0")), - unwrap(DotVersion::try_parse_semver("1.1.0")), - unwrap(DotVersion::try_parse_semver("2.0.0")), - unwrap(DotVersion::try_parse_semver("1.1.1")), - unwrap(DotVersion::try_parse_semver("1.0.1")), - unwrap(DotVersion::try_parse_semver("1.0.0-alpha.1")), - unwrap(DotVersion::try_parse_semver("1.0.0-beta")), - unwrap(DotVersion::try_parse_semver("1.0.0-alpha")), - unwrap(DotVersion::try_parse_semver("1.0.0-alpha.beta")), - unwrap(DotVersion::try_parse_semver("1.0.0-rc")), - unwrap(DotVersion::try_parse_semver("1.0.0-beta.2")), - unwrap(DotVersion::try_parse_semver("1.0.0-beta.20")), - unwrap(DotVersion::try_parse_semver("1.0.0-beta.3")), - unwrap(DotVersion::try_parse_semver("1.0.0-1")), - unwrap(DotVersion::try_parse_semver("1.0.0-0alpha")), + DotVersion::try_parse_semver("1.0.0").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("0.0.0").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.1.0").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("2.0.0").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.1.1").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.0.1").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.0.0-alpha.1").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.0.0-beta").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.0.0-alpha").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.0.0-alpha.beta").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.0.0-rc").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.0.0-beta.2").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.0.0-beta.20").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.0.0-beta.3").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.0.0-1").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_semver("1.0.0-0alpha").value_or_exit(VCPKG_LINE_INFO), }; std::sort(std::begin(versions), std::end(versions)); @@ -752,22 +752,22 @@ TEST_CASE ("version sort semver", "[versionplan]") TEST_CASE ("version sort relaxed", "[versionplan]") { std::vector versions{ - unwrap(DotVersion::try_parse_relaxed("2.1-alpha.alpha")), - unwrap(DotVersion::try_parse_relaxed("1.0.0")), - unwrap(DotVersion::try_parse_relaxed("2.0-1")), - unwrap(DotVersion::try_parse_relaxed("1.0")), - unwrap(DotVersion::try_parse_relaxed("1")), - unwrap(DotVersion::try_parse_relaxed("2.1-alpha")), - unwrap(DotVersion::try_parse_relaxed("2")), - unwrap(DotVersion::try_parse_relaxed("1.1")), - unwrap(DotVersion::try_parse_relaxed("1.10.1")), - unwrap(DotVersion::try_parse_relaxed("2.0-0")), - unwrap(DotVersion::try_parse_relaxed("1.0.1")), - unwrap(DotVersion::try_parse_relaxed("2.1-beta")), - unwrap(DotVersion::try_parse_relaxed("1.0.0.1")), - unwrap(DotVersion::try_parse_relaxed("1.0.0.2")), - unwrap(DotVersion::try_parse_relaxed("2.0")), - unwrap(DotVersion::try_parse_relaxed("2.0-rc")), + DotVersion::try_parse_relaxed("2.1-alpha.alpha").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("1.0.0").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("2.0-1").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("1.0").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("1").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("2.1-alpha").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("2").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("1.1").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("1.10.1").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("2.0-0").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("1.0.1").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("2.1-beta").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("1.0.0.1").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("1.0.0.2").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("2.0").value_or_exit(VCPKG_LINE_INFO), + DotVersion::try_parse_relaxed("2.0-rc").value_or_exit(VCPKG_LINE_INFO), }; std::sort(std::begin(versions), std::end(versions)); @@ -793,15 +793,15 @@ TEST_CASE ("version sort relaxed", "[versionplan]") TEST_CASE ("version sort date", "[versionplan]") { std::vector versions{ - unwrap(DateVersion::try_parse("2021-01-01.2")), - unwrap(DateVersion::try_parse("2021-01-01.1")), - unwrap(DateVersion::try_parse("2021-01-01.1.1")), - unwrap(DateVersion::try_parse("2021-01-01.1.0")), - unwrap(DateVersion::try_parse("2021-01-01")), - unwrap(DateVersion::try_parse("2021-01-01")), - unwrap(DateVersion::try_parse("2020-12-25")), - unwrap(DateVersion::try_parse("2020-12-31")), - unwrap(DateVersion::try_parse("2021-01-01.10")), + DateVersion::try_parse("2021-01-01.2").value_or_exit(VCPKG_LINE_INFO), + DateVersion::try_parse("2021-01-01.1").value_or_exit(VCPKG_LINE_INFO), + DateVersion::try_parse("2021-01-01.1.1").value_or_exit(VCPKG_LINE_INFO), + DateVersion::try_parse("2021-01-01.1.0").value_or_exit(VCPKG_LINE_INFO), + DateVersion::try_parse("2021-01-01").value_or_exit(VCPKG_LINE_INFO), + DateVersion::try_parse("2021-01-01").value_or_exit(VCPKG_LINE_INFO), + DateVersion::try_parse("2020-12-25").value_or_exit(VCPKG_LINE_INFO), + DateVersion::try_parse("2020-12-31").value_or_exit(VCPKG_LINE_INFO), + DateVersion::try_parse("2021-01-01.10").value_or_exit(VCPKG_LINE_INFO), }; std::sort(std::begin(versions), std::end(versions)); @@ -868,14 +868,15 @@ TEST_CASE ("version install simple semver", "[versionplan]") MockCMakeVarProvider var_provider; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "3.0.0", 0}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "3.0.0", 0}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"3.0.0", 0}); @@ -898,14 +899,15 @@ TEST_CASE ("version install transitive semver", "[versionplan]") MockCMakeVarProvider var_provider; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "3.0.0", 0}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "3.0.0", 0}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "b", {"3.0.0", 0}); @@ -934,15 +936,16 @@ TEST_CASE ("version install diamond semver", "[versionplan]") MockCMakeVarProvider var_provider; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "3.0.0", 0}}, - Dependency{"b", {}, {}, {VersionConstraintKind::Minimum, "2.0.0", 1}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "3.0.0", 0}}, + Dependency{"b", {}, {}, {VersionConstraintKind::Minimum, "2.0.0", 1}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 3); check_name_and_version(install_plan.install_actions[0], "c", {"9.0.0", 2}); @@ -961,7 +964,7 @@ TEST_CASE ("version install simple date", "[versionplan]") MockCMakeVarProvider var_provider; - auto install_plan = unwrap( + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, @@ -969,7 +972,8 @@ TEST_CASE ("version install simple date", "[versionplan]") Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2020-03-01", 0}}, }, {}, - toplevel_spec())); + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"2020-03-01", 0}); @@ -991,7 +995,7 @@ TEST_CASE ("version install transitive date", "[versionplan]") MockCMakeVarProvider var_provider; - auto install_plan = unwrap( + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, @@ -999,7 +1003,8 @@ TEST_CASE ("version install transitive date", "[versionplan]") Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2020-01-01.3", 0}}, }, {}, - toplevel_spec())); + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "b", {"2020-01-01.3", 0}); @@ -1027,7 +1032,7 @@ TEST_CASE ("version install diamond date", "[versionplan]") MockCMakeVarProvider var_provider; - auto install_plan = unwrap( + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, @@ -1036,7 +1041,8 @@ TEST_CASE ("version install diamond date", "[versionplan]") Dependency{"b", {}, {}, {VersionConstraintKind::Minimum, "2020-01-02", 1}}, }, {}, - toplevel_spec())); + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 3); check_name_and_version(install_plan.install_actions[0], "c", {"2020-01-09", 2}); @@ -1141,13 +1147,14 @@ TEST_CASE ("version install relaxed cross with semver success", "[versionplan]") MockBaselineProvider bp; bp.v["a"] = {"1.0.0", 0}; - auto install_plan = unwrap( + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "1.0.1", 0}}}, {}, - toplevel_spec())); + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); check_name_and_version(install_plan.install_actions[0], "a", {"1.0.1", 0}); } @@ -1156,13 +1163,14 @@ TEST_CASE ("version install relaxed cross with semver success", "[versionplan]") MockBaselineProvider bp; bp.v["a"] = {"1.0.2", 0}; - auto install_plan = unwrap( + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "1.0.1", 0}}}, {}, - toplevel_spec())); + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); check_name_and_version(install_plan.install_actions[0], "a", {"1.0.2", 0}); } @@ -1188,14 +1196,15 @@ TEST_CASE ("version install scheme change in port version", "[versionplan]") bp.v["a"] = {"2", 0}; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2", 1}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2", 1}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "b", {"1", 1}); @@ -1207,14 +1216,15 @@ TEST_CASE ("version install scheme change in port version", "[versionplan]") bp.v["a"] = {"2", 1}; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2", 0}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "2", 0}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "b", {"1", 1}); @@ -1255,42 +1265,45 @@ TEST_CASE ("version install simple feature", "[versionplan]") SECTION ("relaxed") { - auto install_plan = unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"a", {"x"}}, - }, - {}, - toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {"x"}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x"}); } SECTION ("semver") { - auto install_plan = unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"semver", {"x"}}, - }, - {}, - toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"semver", {"x"}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "semver", {"1.0.0", 0}, {"x"}); } SECTION ("date") { - auto install_plan = unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"date", {"x"}}, - }, - {}, - toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"date", {"x"}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "date", {"2020-01-01", 0}, {"x"}); @@ -1301,7 +1314,7 @@ TEST_CASE ("version install simple feature", "[versionplan]") { MockBaselineProvider bp; - auto install_plan = unwrap( + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, @@ -1309,7 +1322,8 @@ TEST_CASE ("version install simple feature", "[versionplan]") Dependency{"a", {"x"}, {}, {VersionConstraintKind::Minimum, "1", 0}}, }, {}, - toplevel_spec())); + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x"}); @@ -1340,14 +1354,15 @@ TEST_CASE ("version install transitive features", "[versionplan]") 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())); + auto install_plan = create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {"x"}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "b", {"1", 0}, {"y"}); @@ -1382,14 +1397,15 @@ TEST_CASE ("version install transitive feature versioned", "[versionplan]") 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())); + auto install_plan = create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"a", {"x"}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 3); check_name_and_version(install_plan.install_actions[0], "c", {"1", 0}); @@ -1424,14 +1440,15 @@ TEST_CASE ("version install constraint-reduction", "[versionplan]") bp.v["c"] = {"1", 0}; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"b", {}, {}, {VersionConstraintKind::Minimum, "1"}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"b", {}, {}, {VersionConstraintKind::Minimum, "1"}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "c", {"1", 0}); @@ -1458,14 +1475,15 @@ TEST_CASE ("version install constraint-reduction", "[versionplan]") bp.v["c"] = {"1", 0}; auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - { - Dependency{"b", {}, {}, {VersionConstraintKind::Minimum, "2"}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + var_provider, + { + Dependency{"b", {}, {}, {VersionConstraintKind::Minimum, "2"}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "c", {"1", 0}); @@ -1490,13 +1508,13 @@ TEST_CASE ("version install overrides", "[versionplan]") SECTION ("string") { - auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - {Dependency{"c"}}, - {DependencyOverride{"b", "1"}, DependencyOverride{"c", "1"}}, - toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, + bp, + var_provider, + {Dependency{"c"}}, + {DependencyOverride{"b", "1"}, DependencyOverride{"c", "1"}}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "c", {"1", 0}); @@ -1504,13 +1522,13 @@ TEST_CASE ("version install overrides", "[versionplan]") SECTION ("relaxed") { - auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - var_provider, - {Dependency{"b"}}, - {DependencyOverride{"b", "1"}, DependencyOverride{"c", "1"}}, - toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, + bp, + var_provider, + {Dependency{"b"}}, + {DependencyOverride{"b", "1"}, DependencyOverride{"c", "1"}}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "b", {"1", 0}); @@ -1534,13 +1552,13 @@ TEST_CASE ("version install transitive overrides", "[versionplan]") 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())); + auto install_plan = create_versioned_install_plan(vp, + bp, + var_provider, + {Dependency{"b"}}, + {DependencyOverride{"b", "1"}, DependencyOverride{"c", "1"}}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "c", {"1", 0}); @@ -1561,8 +1579,8 @@ TEST_CASE ("version install default features", "[versionplan]") MockBaselineProvider bp; bp.v["a"] = {"1", 0}; - auto install_plan = - unwrap(create_versioned_install_plan(vp, bp, var_provider, {Dependency{"a"}}, {}, toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {Dependency{"a"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x"}); @@ -1583,7 +1601,8 @@ TEST_CASE ("version dont install default features", "[versionplan]") bp.v["a"] = {"1", 0}; auto install_plan = - unwrap(create_versioned_install_plan(vp, bp, var_provider, {Dependency{"a", {"core"}}}, {}, toplevel_spec())); + create_versioned_install_plan(vp, bp, var_provider, {Dependency{"a", {"core"}}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}); @@ -1611,15 +1630,16 @@ TEST_CASE ("version install transitive default features", "[versionplan]") bp.v["b"] = {"1", 0}; bp.v["c"] = {"1", 0}; - auto install_plan = - unwrap(create_versioned_install_plan(vp, bp, var_provider, {Dependency{"b"}}, {}, toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {Dependency{"b"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); 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}); - install_plan = unwrap(create_versioned_install_plan( - vp, bp, var_provider, {Dependency{"a", {"core"}}, Dependency{"c"}}, {}, toplevel_spec())); + install_plan = create_versioned_install_plan( + vp, bp, var_provider, {Dependency{"a", {"core"}}, Dependency{"c"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x"}); @@ -1628,7 +1648,8 @@ TEST_CASE ("version install transitive default features", "[versionplan]") static PlatformExpression::Expr parse_platform(StringView l) { - return unwrap(PlatformExpression::parse_platform_expression(l, PlatformExpression::MultipleBinaryOperators::Deny)); + return PlatformExpression::parse_platform_expression(l, PlatformExpression::MultipleBinaryOperators::Deny) + .value_or_exit(VCPKG_LINE_INFO); } TEST_CASE ("version install qualified dependencies", "[versionplan]") @@ -1647,13 +1668,14 @@ TEST_CASE ("version install qualified dependencies", "[versionplan]") MockCMakeVarProvider var_provider; var_provider.dep_info_vars[toplevel_spec()] = {{"VCPKG_CMAKE_SYSTEM_NAME", "Windows"}}; - auto install_plan = unwrap( + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"b", {}, parse_platform("!linux")}, {"c", {}, parse_platform("linux")}}, {}, - toplevel_spec())); + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "b", {"1", 0}); @@ -1664,13 +1686,14 @@ TEST_CASE ("version install qualified dependencies", "[versionplan]") MockCMakeVarProvider var_provider; var_provider.dep_info_vars[toplevel_spec()] = {{"VCPKG_CMAKE_SYSTEM_NAME", "Linux"}}; - auto install_plan = unwrap( + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"b", {}, parse_platform("!linux")}, {"c", {}, parse_platform("linux")}}, {}, - toplevel_spec())); + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "c", {"1", 0}); @@ -1694,13 +1717,14 @@ TEST_CASE ("version install qualified default suppression", "[versionplan]") bp.v["a"] = {"1", 0}; bp.v["b"] = {"1", 0}; - auto install_plan = unwrap( + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"b", {}, parse_platform("!linux")}, {"a", {"core"}, parse_platform("linux")}}, {}, - toplevel_spec())); + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x"}); @@ -1725,7 +1749,8 @@ TEST_CASE ("version install qualified transitive", "[versionplan]") 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())); + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"b"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}); @@ -1752,7 +1777,8 @@ TEST_CASE ("version install different vars", "[versionplan]") 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())); + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"b"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 3); check_name_and_version(install_plan.install_actions[0], "c", {"1", 0}); @@ -1790,7 +1816,8 @@ TEST_CASE ("version install qualified features", "[versionplan]") 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())); + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"b"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 3); check_name_and_version(install_plan.install_actions[0], "c", {"1", 0}, {"z"}); @@ -1812,8 +1839,8 @@ TEST_CASE ("version install self features", "[versionplan]") MockCMakeVarProvider var_provider; - auto install_plan = - unwrap(create_versioned_install_plan(vp, bp, var_provider, {{"a", {"x"}}}, {}, toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, bp, var_provider, {{"a", {"x"}}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}, {"x", "y"}); @@ -1893,14 +1920,15 @@ TEST_CASE ("version remove features during upgrade", "[versionplan]") vp.emplace("c", {"1", 1}); auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "1"}}, - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "1", 1}}, - Dependency{"b", {}, {}, {VersionConstraintKind::Minimum, "1", 1}}, - Dependency{"c"}, - })); + create_versioned_install_plan(vp, + bp, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "1"}}, + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "1", 1}}, + Dependency{"b", {}, {}, {VersionConstraintKind::Minimum, "1", 1}}, + Dependency{"c"}, + }) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 3); check_name_and_version(install_plan.install_actions[0], "c", {"1", 1}); @@ -1929,7 +1957,7 @@ TEST_CASE ("version install host tool", "[versionplan]") { Dependency dep_c{"c"}; - auto install_plan = unwrap(create_versioned_install_plan(vp, bp, {dep_c})); + auto install_plan = create_versioned_install_plan(vp, bp, {dep_c}).value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}); @@ -1942,7 +1970,7 @@ TEST_CASE ("version install host tool", "[versionplan]") Dependency dep_a{"a"}; dep_a.host = true; - auto install_plan = unwrap(create_versioned_install_plan(vp, bp, {dep_a})); + auto install_plan = create_versioned_install_plan(vp, bp, {dep_a}).value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}); @@ -1950,7 +1978,7 @@ TEST_CASE ("version install host tool", "[versionplan]") } SECTION ("transitive 1") { - auto install_plan = unwrap(create_versioned_install_plan(vp, bp, {{"b"}})); + auto install_plan = create_versioned_install_plan(vp, bp, {{"b"}}).value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}); @@ -1965,7 +1993,7 @@ TEST_CASE ("version install host tool", "[versionplan]") Dependency dep_c{"c"}; dep_c.host = true; - auto install_plan = unwrap(create_versioned_install_plan(vp, bp, {dep_c})); + auto install_plan = create_versioned_install_plan(vp, bp, {dep_c}).value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "a", {"1", 0}); @@ -1977,7 +2005,7 @@ TEST_CASE ("version install host tool", "[versionplan]") } SECTION ("self-reference") { - auto install_plan = unwrap(create_versioned_install_plan(vp, bp, {{"d"}})); + auto install_plan = create_versioned_install_plan(vp, bp, {{"d"}}).value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "d", {"1", 0}); @@ -2014,7 +2042,8 @@ TEST_CASE ("version overlay ports", "[versionplan]") const MockBaselineProvider empty_bp; auto install_plan = - unwrap(create_versioned_install_plan(vp, empty_bp, oprovider, var_provider, {{"a"}}, {}, toplevel_spec())); + create_versioned_install_plan(vp, empty_bp, oprovider, var_provider, {{"a"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0}); @@ -2022,8 +2051,8 @@ TEST_CASE ("version overlay ports", "[versionplan]") SECTION ("transitive") { - auto install_plan = - unwrap(create_versioned_install_plan(vp, bp, oprovider, var_provider, {{"b"}}, {}, toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, bp, oprovider, var_provider, {{"b"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0}); @@ -2032,8 +2061,8 @@ TEST_CASE ("version overlay ports", "[versionplan]") SECTION ("transitive constraint") { - auto install_plan = - unwrap(create_versioned_install_plan(vp, bp, oprovider, var_provider, {{"c"}}, {}, toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, bp, oprovider, var_provider, {{"c"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 2); check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0}); @@ -2042,8 +2071,8 @@ TEST_CASE ("version overlay ports", "[versionplan]") SECTION ("none") { - auto install_plan = - unwrap(create_versioned_install_plan(vp, bp, oprovider, var_provider, {{"a"}}, {}, toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, bp, oprovider, var_provider, {{"a"}}, {}, toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0}); @@ -2051,15 +2080,16 @@ TEST_CASE ("version overlay ports", "[versionplan]") SECTION ("constraint") { auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - oprovider, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "1", 1}}, - }, - {}, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + oprovider, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "1", 1}}, + }, + {}, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0}); @@ -2067,34 +2097,36 @@ TEST_CASE ("version overlay ports", "[versionplan]") SECTION ("constraint+override") { auto install_plan = - unwrap(create_versioned_install_plan(vp, - bp, - oprovider, - var_provider, - { - Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "1", 1}}, - }, - { - DependencyOverride{"a", "2", 0}, - }, - toplevel_spec())); + create_versioned_install_plan(vp, + bp, + oprovider, + var_provider, + { + Dependency{"a", {}, {}, {VersionConstraintKind::Minimum, "1", 1}}, + }, + { + DependencyOverride{"a", "2", 0}, + }, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0}); } SECTION ("override") { - auto install_plan = unwrap(create_versioned_install_plan(vp, - bp, - oprovider, - var_provider, - { - Dependency{"a"}, - }, - { - DependencyOverride{"a", "2", 0}, - }, - toplevel_spec())); + auto install_plan = create_versioned_install_plan(vp, + bp, + oprovider, + var_provider, + { + Dependency{"a"}, + }, + { + DependencyOverride{"a", "2", 0}, + }, + toplevel_spec()) + .value_or_exit(VCPKG_LINE_INFO); REQUIRE(install_plan.size() == 1); check_name_and_version(install_plan.install_actions[0], "a", {"overlay", 0}); diff --git a/src/vcpkg-test/platform-expression.cpp b/src/vcpkg-test/platform-expression.cpp index dba19048b3..558107f36e 100644 --- a/src/vcpkg-test/platform-expression.cpp +++ b/src/vcpkg-test/platform-expression.cpp @@ -447,11 +447,8 @@ TEST_CASE ("operator keywords in identifiers", "[platform-expression]") { // Operator keywords ("and","not") require a break to separate them from identifiers // In these cases, strings containing an operator keyword parse as an identifier, not as a unary/binary expression - auto m_expr1 = parse_expr("!windowsandandroid"); - CHECK(m_expr1); - - auto m_expr2 = parse_expr("notwindows"); - CHECK(m_expr2); + CHECK(parse_expr("!windowsandandroid")); + CHECK(parse_expr("notwindows")); } TEST_CASE ("operator keywords without whitepace", "[platform-expression]") @@ -503,169 +500,73 @@ TEST_CASE ("operator keywords without whitepace", "[platform-expression]") TEST_CASE ("invalid logic expression, unexpected character", "[platform-expression]") { - auto m_expr = parse_expr("windows arm"); - CHECK_FALSE(m_expr); + CHECK_FALSE(parse_expr("windows arm")); } TEST_CASE ("invalid logic expression, use '|' instead of 'or'", "[platform-expression]") { - auto m_expr = parse_expr("windows or arm"); - CHECK_FALSE(m_expr); + CHECK_FALSE(parse_expr("windows or arm")); } TEST_CASE ("unexpected character or identifier in logic expression", "[platform-expression]") { CHECK_FALSE(parse_expr("windows aND arm")); - - { - auto m_expr = parse_expr("windows a&d arm"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("windows oR arm"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("windows o|r arm"); - CHECK_FALSE(m_expr); - } + CHECK_FALSE(parse_expr("windows a&d arm")); + CHECK_FALSE(parse_expr("windows oR arm")); + CHECK_FALSE(parse_expr("windows o|r arm")); } TEST_CASE ("unexpected identifier in logic expression", "[platform-expression]") { - { - auto m_expr = parse_expr("windows amd arm"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("windows andsynonym arm"); - CHECK_FALSE(m_expr); - } + CHECK_FALSE(parse_expr("windows amd arm")); + CHECK_FALSE(parse_expr("windows andsynonym arm")); } TEST_CASE ("missing closing )", "[platform-expression]") { - { - auto m_expr = parse_expr("(windows & arm | linux"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("( (windows & arm) | (osx & arm64) | linux"); - CHECK_FALSE(m_expr); - } + CHECK_FALSE(parse_expr("(windows & arm | linux")); + CHECK_FALSE(parse_expr("( (windows & arm) | (osx & arm64) | linux")); } TEST_CASE ("missing or invalid identifier", "[platform-expression]") { - { - auto m_expr = parse_expr("!"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("w!ndows"); - CHECK_FALSE(m_expr); - } + CHECK_FALSE(parse_expr("!")); + CHECK_FALSE(parse_expr("w!ndows")); } TEST_CASE ("mixing & and | is not allowed", "[platform-expression]") { - { - auto m_expr = parse_expr("windows & arm | linux"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("windows | !arm & linux"); - CHECK_FALSE(m_expr); - } + CHECK_FALSE(parse_expr("windows & arm | linux")); + CHECK_FALSE(parse_expr("windows | !arm & linux")); } TEST_CASE ("invalid expression, no binary operator", "[platform-expression]") { - { - auto m_expr = parse_expr("windows linux"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("windows x64"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("!windows x86"); - CHECK_FALSE(m_expr); - } + CHECK_FALSE(parse_expr("windows linux")); + CHECK_FALSE(parse_expr("windows x64")); + CHECK_FALSE(parse_expr("!windows x86")); } TEST_CASE ("invalid expression, missing binary operand", "[platform-expression]") { - { - auto m_expr = parse_expr("windows & "); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr(" | arm"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("windows & !arm & "); - CHECK_FALSE(m_expr); - } + CHECK_FALSE(parse_expr("windows & ")); + CHECK_FALSE(parse_expr(" | arm")); + CHECK_FALSE(parse_expr("windows & !arm & ")); } TEST_CASE ("invalid identifier", "[platform-expression]") { - auto m_expr = parse_expr("windows & x^$"); - CHECK_FALSE(m_expr); + CHECK_FALSE(parse_expr("windows & x^$")); } TEST_CASE ("invalid alternate expressions", "[platform-expression]") { - { - auto m_expr = parse_expr("windows an%d arm"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("windows aNd arm"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("windows andMORE arm"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("windows and+ arm"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("windows and& arm"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("notANY windows"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("not! windows"); - CHECK_FALSE(m_expr); - } - - { - auto m_expr = parse_expr("notx64 windows"); - CHECK_FALSE(m_expr); - } + CHECK_FALSE(parse_expr("windows an%d arm")); + CHECK_FALSE(parse_expr("windows aNd arm")); + CHECK_FALSE(parse_expr("windows andMORE arm")); + CHECK_FALSE(parse_expr("windows and+ arm")); + CHECK_FALSE(parse_expr("windows and& arm")); + CHECK_FALSE(parse_expr("notANY windows")); + CHECK_FALSE(parse_expr("not! windows")); + CHECK_FALSE(parse_expr("notx64 windows")); } diff --git a/src/vcpkg-test/spdx.cpp b/src/vcpkg-test/spdx.cpp index 1b8cac7e5b..caedd79c8b 100644 --- a/src/vcpkg-test/spdx.cpp +++ b/src/vcpkg-test/spdx.cpp @@ -3,7 +3,6 @@ #include using namespace vcpkg; -using Test::unwrap; TEST_CASE ("spdx maximum serialization", "[spdx]") { @@ -35,7 +34,7 @@ TEST_CASE ("spdx maximum serialization", "[spdx]") "https://test-document-namespace", {}); - auto expected = unwrap(Json::parse(R"json( + auto expected = Json::parse(R"json( { "$schema": "https://raw.githubusercontent.com/spdx/spdx-spec/v2.2.1/schemas/spdx-schema.json", "spdxVersion": "SPDX-2.2", @@ -159,9 +158,10 @@ TEST_CASE ("spdx maximum serialization", "[spdx]") "copyrightText": "NOASSERTION" } ] -})json")); +})json") + .value_or_exit(VCPKG_LINE_INFO); - auto doc = unwrap(Json::parse(sbom)); + auto doc = Json::parse(sbom).value_or_exit(VCPKG_LINE_INFO); Test::check_json_eq(expected.first, doc.first); } @@ -189,7 +189,7 @@ TEST_CASE ("spdx minimum serialization", "[spdx]") "https://test-document-namespace-2", {}); - auto expected = unwrap(Json::parse(R"json( + auto expected = Json::parse(R"json( { "$schema": "https://raw.githubusercontent.com/spdx/spdx-spec/v2.2.1/schemas/spdx-schema.json", "spdxVersion": "SPDX-2.2", @@ -288,9 +288,10 @@ TEST_CASE ("spdx minimum serialization", "[spdx]") "copyrightText": "NOASSERTION" } ] -})json")); +})json") + .value_or_exit(VCPKG_LINE_INFO); - auto doc = unwrap(Json::parse(sbom)); + auto doc = Json::parse(sbom).value_or_exit(VCPKG_LINE_INFO); Test::check_json_eq(expected.first, doc.first); } @@ -328,7 +329,7 @@ TEST_CASE ("spdx concat resources", "[spdx]") const auto sbom = create_spdx_sbom(ipa, {}, {}, "now+1", "ns", {std::move(doc1), std::move(doc2)}); - auto expected = unwrap(Json::parse(R"json( + auto expected = Json::parse(R"json( { "$schema": "https://raw.githubusercontent.com/spdx/spdx-spec/v2.2.1/schemas/spdx-schema.json", "spdxVersion": "SPDX-2.2", @@ -389,8 +390,9 @@ TEST_CASE ("spdx concat resources", "[spdx]") "f4", "f5" ] -})json")); +})json") + .value_or_exit(VCPKG_LINE_INFO); - auto doc = unwrap(Json::parse(sbom)); + auto doc = Json::parse(sbom).value_or_exit(VCPKG_LINE_INFO); Test::check_json_eq(expected.first, doc.first); } diff --git a/src/vcpkg-test/specifier.cpp b/src/vcpkg-test/specifier.cpp index 7958b08308..8a86449856 100644 --- a/src/vcpkg-test/specifier.cpp +++ b/src/vcpkg-test/specifier.cpp @@ -85,7 +85,7 @@ TEST_CASE ("specifier parsing", "[specifier]") SECTION ("parsed specifier wildcard feature") { - auto spec = Test::unwrap(vcpkg::parse_qualified_specifier("zlib[*]")); + auto spec = vcpkg::parse_qualified_specifier("zlib[*]").value_or_exit(VCPKG_LINE_INFO); REQUIRE(spec.features.value_or(std::vector{}) == std::vector{"*"}); } diff --git a/src/vcpkg-test/update.cpp b/src/vcpkg-test/update.cpp index c3561b6bb5..fbaf0d27c7 100644 --- a/src/vcpkg-test/update.cpp +++ b/src/vcpkg-test/update.cpp @@ -23,7 +23,7 @@ TEST_CASE ("find outdated packages basic", "[update]") StatusParagraphs status_db(std::move(status_paragraphs)); std::unordered_map map; - auto scf = unwrap(test_parse_control_file({{{"Source", "a"}, {"Version", "0"}}})); + auto scf = test_parse_control_file({{{"Source", "a"}, {"Version", "0"}}}).value_or_exit(VCPKG_LINE_INFO); map.emplace("a", SourceControlFileAndLocation{std::move(scf), ""}); PortFileProvider::MapPortFileProvider provider(map); @@ -47,7 +47,7 @@ TEST_CASE ("find outdated packages features", "[update]") StatusParagraphs status_db(std::move(status_paragraphs)); std::unordered_map map; - auto scf = unwrap(test_parse_control_file({{{"Source", "a"}, {"Version", "0"}}})); + auto scf = test_parse_control_file({{{"Source", "a"}, {"Version", "0"}}}).value_or_exit(VCPKG_LINE_INFO); map.emplace("a", SourceControlFileAndLocation{std::move(scf), ""}); PortFileProvider::MapPortFileProvider provider(map); @@ -73,7 +73,7 @@ TEST_CASE ("find outdated packages features 2", "[update]") StatusParagraphs status_db(std::move(status_paragraphs)); std::unordered_map map; - auto scf = unwrap(test_parse_control_file({{{"Source", "a"}, {"Version", "0"}}})); + auto scf = test_parse_control_file({{{"Source", "a"}, {"Version", "0"}}}).value_or_exit(VCPKG_LINE_INFO); map.emplace("a", SourceControlFileAndLocation{std::move(scf), ""}); PortFileProvider::MapPortFileProvider provider(map); @@ -94,7 +94,7 @@ TEST_CASE ("find outdated packages none", "[update]") StatusParagraphs status_db(std::move(status_paragraphs)); std::unordered_map map; - auto scf = unwrap(test_parse_control_file({{{"Source", "a"}, {"Version", "2"}}})); + auto scf = test_parse_control_file({{{"Source", "a"}, {"Version", "2"}}}).value_or_exit(VCPKG_LINE_INFO); map.emplace("a", SourceControlFileAndLocation{std::move(scf), ""}); PortFileProvider::MapPortFileProvider provider(map); diff --git a/src/vcpkg/registries.cpp b/src/vcpkg/registries.cpp index d2384a9872..3ef5c242f2 100644 --- a/src/vcpkg/registries.cpp +++ b/src/vcpkg/registries.cpp @@ -674,7 +674,8 @@ namespace if (!maybe_contents.has_value()) { print2("Fetching baseline information from ", m_repo, "...\n"); - if (auto err = m_paths.git_fetch(m_repo, m_baseline_identifier)) + auto maybe_err = m_paths.git_fetch(m_repo, m_baseline_identifier); + if (!maybe_err.has_value()) { LockGuardPtr(g_metrics)->track_property("registries-error-could-not-find-baseline", "defined"); @@ -685,8 +686,9 @@ namespace m_repo, maybe_contents.error(), m_repo, - *err.get()); + maybe_err.error()); } + maybe_contents = m_paths.git_show_from_remote_registry(m_baseline_identifier, path_to_baseline); } diff --git a/src/vcpkg/vcpkgpaths.cpp b/src/vcpkg/vcpkgpaths.cpp index fa7f3f4573..8faca04641 100644 --- a/src/vcpkg/vcpkgpaths.cpp +++ b/src/vcpkg/vcpkgpaths.cpp @@ -1176,7 +1176,7 @@ namespace vcpkg return {Strings::trim(fetch_head_output.output).to_string(), expected_left_tag}; } - Optional VcpkgPaths::git_fetch(StringView repo, StringView treeish) const + ExpectedS VcpkgPaths::git_fetch(StringView repo, StringView treeish) const { auto& fs = get_filesystem(); @@ -1209,7 +1209,8 @@ namespace vcpkg return Strings::format( "Error: Failed to fetch ref %s from repository %s.\n%s\n", treeish, repo, fetch_output.output); } - return nullopt; + + return {Unit{}}; } // returns an error if there was an unexpected error; returns nullopt if the file doesn't exist at the specified