Skip to content

Commit

Permalink
Fix the unit tests for "hypens" 😅
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyONeal committed Sep 25, 2024
1 parent a7b45df commit 0b1bbd0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
21 changes: 14 additions & 7 deletions src/vcpkg-test/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ TEST_CASE ("parse_package_spec forbid illegal characters", "[input][parse_packag
{
REQUIRE(
maybe_parsed.error() ==
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hypens.
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hyphens.
on expression: zlib#notaport
^)");
}
Expand Down Expand Up @@ -111,10 +111,17 @@ TEST_CASE ("check_triplet rejects malformed triplet", "[input][check_triplet]")
db.available_triplets.push_back(TripletFile{"invalid.triplet_name", "invalid.triplet_name.cmake"});
auto maybe_check = check_triplet("invalid.triplet_name", db);
REQUIRE(!maybe_check.has_value());
static constexpr StringLiteral expected_error{
"error: expected the end of input parsing a package spec; this usually means the indicated character is not "
"allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hypens."};
REQUIRE(maybe_check.error() == expected_error);
REQUIRE(!maybe_check.has_value());
REQUIRE(maybe_check.error().data() ==
R"(error: Invalid triplet name. Triplet names are all lowercase alphanumeric+hyphens.
on expression: invalid.triplet_name
^
Built-in Triplets:
Community Triplets:
Overlay Triplets from "invalid.triplet_name.cmake":
invalid.triplet_name
See https://learn.microsoft.com/vcpkg/users/triplets?WT.mc_id=vcpkg_inproduct_cli for more information.
)");
}

TEST_CASE ("check_and_get_package_spec validates the triplet", "[input][check_and_get_package_spec]")
Expand Down Expand Up @@ -153,7 +160,7 @@ TEST_CASE ("check_and_get_package_spec forbids malformed", "[input][check_and_ge
REQUIRE(
maybe_spec.error() ==
LocalizedString::from_raw(
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hypens.
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hyphens.
on expression: zlib:x86-windows#
^)"));
}
Expand Down Expand Up @@ -222,7 +229,7 @@ TEST_CASE ("check_and_get_full_package_spec forbids malformed", "[input][check_a
REQUIRE(
maybe_spec.error() ==
LocalizedString::from_raw(
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hypens.
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hyphens.
on expression: zlib[core]:x86-windows#
^)"));
}
Expand Down
12 changes: 6 additions & 6 deletions src/vcpkg-test/manifests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ TEST_CASE ("default-feature-empty errors", "[manifests]")
REQUIRE(!m_pgh.has_value());
REQUIRE(m_pgh.error().data() ==
"<test manifest>: error: $.default-features[0] (a feature name): \"\" is not a valid feature name. Feature "
"names must be lowercase alphanumeric+hypens and not reserved (see " +
"names must be lowercase alphanumeric+hyphens and not reserved (see " +
docs::manifests_url + " for more information).");
}

Expand All @@ -1432,7 +1432,7 @@ TEST_CASE ("default-feature-empty-object errors", "[manifests]")
REQUIRE(!m_pgh.has_value());
REQUIRE(m_pgh.error().data() ==
"<test manifest>: error: $.default-features[0].name (a feature name): \"\" is not a valid feature name. "
"Feature names must be lowercase alphanumeric+hypens and not reserved (see " +
"Feature names must be lowercase alphanumeric+hyphens and not reserved (see " +
docs::manifests_url + " for more information).");
}

Expand All @@ -1445,7 +1445,7 @@ TEST_CASE ("dependency-name-empty errors", "[manifests]")
REQUIRE(!m_pgh.has_value());
REQUIRE(m_pgh.error().data() ==
"<test manifest>: error: $.dependencies[0] (a package name): \"\" is not a valid package name. Package "
"names must be lowercase alphanumeric+hypens and not reserved (see " +
"names must be lowercase alphanumeric+hyphens and not reserved (see " +
docs::manifests_url + " for more information).");
}

Expand All @@ -1458,7 +1458,7 @@ TEST_CASE ("dependency-name-empty-object errors", "[manifests]")
REQUIRE(!m_pgh.has_value());
REQUIRE(m_pgh.error().data() ==
"<test manifest>: error: $.dependencies[0].name (a package name): \"\" is not a valid package name. "
"Package names must be lowercase alphanumeric+hypens and not reserved (see " +
"Package names must be lowercase alphanumeric+hyphens and not reserved (see " +
docs::manifests_url + " for more information).");
}

Expand Down Expand Up @@ -1545,7 +1545,7 @@ TEST_CASE ("dependency-feature-name-empty errors", "[manifests]")
REQUIRE(!m_pgh.has_value());
REQUIRE(m_pgh.error().data() ==
"<test manifest>: error: $.dependencies[0].features[0] (a feature name): \"\" is not a valid feature name. "
"Feature names must be lowercase alphanumeric+hypens and not reserved (see " +
"Feature names must be lowercase alphanumeric+hyphens and not reserved (see " +
docs::manifests_url + " for more information).");
}

Expand All @@ -1563,6 +1563,6 @@ TEST_CASE ("dependency-feature-name-empty-object errors", "[manifests]")
REQUIRE(!m_pgh.has_value());
REQUIRE(m_pgh.error().data() ==
"<test manifest>: error: $.dependencies[0].features[0].name (a feature name): \"\" is not a valid feature "
"name. Feature names must be lowercase alphanumeric+hypens and not reserved (see " +
"name. Feature names must be lowercase alphanumeric+hyphens and not reserved (see " +
docs::manifests_url + " for more information).");
}
16 changes: 8 additions & 8 deletions src/vcpkg-test/specifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ TEST_CASE ("specifier parsing", "[specifier]")
REQUIRE(
s.error() ==
LocalizedString::from_raw(
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hypens.
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hyphens.
on expression: zlib:x86-uwp:
^)"));
}
Expand All @@ -119,7 +119,7 @@ TEST_CASE ("specifier parsing", "[specifier]")
REQUIRE(
s.error() ==
LocalizedString::from_raw(
R"(error: expected the end of input parsing a package name; this usually means the indicated character is not allowed to be in a port name. Port names are all lowercase alphanumeric+hypens and not reserved (see )" +
R"(error: expected the end of input parsing a package name; this usually means the indicated character is not allowed to be in a port name. Port names are all lowercase alphanumeric+hyphens and not reserved (see )" +
docs::vcpkg_json_ref_name + R"( for more information).
on expression: zlib#
^)"));
Expand All @@ -139,7 +139,7 @@ TEST_CASE ("specifier parsing", "[specifier]")
REQUIRE(
s.error() ==
LocalizedString::from_raw(
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hypens.
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hyphens.
on expression: zlib#
^)"));
}
Expand All @@ -158,7 +158,7 @@ TEST_CASE ("specifier parsing", "[specifier]")
REQUIRE(
s.error() ==
LocalizedString::from_raw(
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hypens.
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hyphens.
on expression: zlib:x86-uwp:
^)"));
}
Expand Down Expand Up @@ -196,7 +196,7 @@ TEST_CASE ("specifier parsing", "[specifier]")
REQUIRE(
s.error() ==
LocalizedString::from_raw(
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hypens.
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hyphens.
on expression: zlib(windows)[co, re]
^)"));
}
Expand All @@ -215,7 +215,7 @@ TEST_CASE ("specifier parsing", "[specifier]")
REQUIRE(
s.error() ==
LocalizedString::from_raw(
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hypens.
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hyphens.
on expression: zlib:x86-uwp (windows)[co, re]
^)"));
}
Expand All @@ -238,7 +238,7 @@ TEST_CASE ("specifier parsing", "[specifier]")
REQUIRE(
s.error() ==
LocalizedString::from_raw(
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hypens.
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hyphens.
on expression: zlib:x64-windows[no-ending-square-bracket
^)"));
}
Expand All @@ -257,7 +257,7 @@ TEST_CASE ("specifier parsing", "[specifier]")
REQUIRE(
s.error() ==
LocalizedString::from_raw(
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hypens.
R"(error: expected the end of input parsing a package spec; this usually means the indicated character is not allowed to be in a package spec. Port, triplet, and feature names are all lowercase alphanumeric+hyphens.
on expression: zlib:x64-windows[feature]suffix
^)"));
}
Expand Down

0 comments on commit 0b1bbd0

Please sign in to comment.