Skip to content

Allow license expressions in features #1096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

autoantwort
Copy link
Contributor

Copy link
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see an added test for what happens when it's bogus SPDX.

@autoantwort
Copy link
Contributor Author

I would like to see an added test for what happens when it's bogus SPDX.

You mean like

TEST_CASE ("license error messages", "[manifests][license]")
{
ParseMessages messages;
parse_spdx_license_expression("", messages);
REQUIRE(messages.error);
CHECK(messages.error->to_string() == R"(<license string>:1:1: error: SPDX license expression was empty.
on expression:
^)");
parse_spdx_license_expression("MIT ()", messages);
REQUIRE(messages.error);
CHECK(messages.error->to_string() ==
R"(<license string>:1:5: error: Expected a compound or the end of the string, found a parenthesis.
on expression: MIT ()
^)");
parse_spdx_license_expression("MIT +", messages);
REQUIRE(messages.error);
CHECK(
messages.error->to_string() ==
R"(<license string>:1:5: error: SPDX license expression contains an extra '+'. These are only allowed directly after a license identifier.
on expression: MIT +
^)");
parse_spdx_license_expression("MIT AND", messages);
REQUIRE(messages.error);
CHECK(messages.error->to_string() ==
R"(<license string>:1:8: error: Expected a license name, found the end of the string.
on expression: MIT AND
^)");
parse_spdx_license_expression("MIT AND unknownlicense", messages);
CHECK(!messages.error);
REQUIRE(messages.warnings.size() == 1);
CHECK(
test_format_parse_warning(messages.warnings[0]) ==
R"(<license string>:1:9: warning: Unknown license identifier 'unknownlicense'. Known values are listed at https://spdx.org/licenses/
on expression: MIT AND unknownlicense
^)");
}

I haven't duplicated the tests because the same deserializer was used

@BillyONeal
Copy link
Member

I mean showing that parse_spdx_license_expression is correctly hooked up with any example, not the full blown mess that is every edge case there.

But this has waited long enough, thanks!

@BillyONeal BillyONeal merged commit 5c1c6b0 into microsoft:main Jun 21, 2023
@autoantwort autoantwort deleted the feature/features-with-licenses branch June 22, 2023 00:56
@vicroms
Copy link
Member

vicroms commented Jun 23, 2023

We need to update the manifests reference documentation.

@autoantwort
Copy link
Contributor Author

I have created MicrosoftDocs/vcpkg-docs#93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants