diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-01-31 18:17:59 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-02-02 10:28:10 +0300 |
commit | c3158b221ef94b4f2c0d2a67aebcce22acf50993 (patch) | |
tree | 5f7e2da546e2e4df4c83c15360c36e4e20361198 /libbpkg | |
parent | b836f4966224424649de3e1dde1bca39888d9ed9 (diff) |
Add support for enable clause in tests package manifest value
Diffstat (limited to 'libbpkg')
-rw-r--r-- | libbpkg/manifest.cxx | 28 | ||||
-rw-r--r-- | libbpkg/manifest.hxx | 7 |
2 files changed, 22 insertions, 13 deletions
diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx index 559e1c3..923b113 100644 --- a/libbpkg/manifest.cxx +++ b/libbpkg/manifest.cxx @@ -3104,11 +3104,12 @@ namespace bpkg using std::string; // We will use the dependency alternatives parser to parse the - // `<name> [<version-constraint>] [<reflect-config>]` representation into - // a temporary dependency alternatives object. Then we will verify that - // the result has no multiple alternatives/dependency packages and - // unexpected clauses and will move the required information (dependency, - // reflection, etc) into the being created test dependency object. + // `<name> [<version-constraint>] ['?' <enable-condition>] [<reflect-config>]` + // representation into a temporary dependency alternatives object. Then we + // will verify that the result has no multiple alternatives/dependency + // packages and unexpected clauses and will move the required information + // (dependency, reflection, etc) into the being created test dependency + // object. // Verify that there is no newline characters to forbid the multi-line // dependency alternatives representation. @@ -3187,16 +3188,14 @@ namespace bpkg // // Note that the require, prefer, and accept clauses can only be present // in the multi-line representation and we have already verified that this - // is not the case. - // - if (da.enable) - throw invalid_argument ("unexpected enable clause"); + // is not the case. So there is nothing to verify here. - // Move the dependency and the reflect clause into the being created test - // dependency object. + // Move the dependency and the enable and reflect clauses into the being + // created test dependency object. // static_cast<dependency&> (*this) = move (da[0]); + enable = move (da.enable); reflect = move (da.reflect); } @@ -3207,6 +3206,13 @@ namespace bpkg ? "* " + dependency::string () : dependency::string ()); + if (enable) + { + r += " ? ("; + r += *enable; + r += ')'; + } + if (reflect) { r += ' '; diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index 8439cdf..834b681 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -1083,6 +1083,7 @@ namespace bpkg { test_dependency_type type; bool buildtime; + butl::optional<std::string> enable; butl::optional<std::string> reflect; test_dependency () = default; @@ -1090,15 +1091,17 @@ namespace bpkg test_dependency_type t, bool b, butl::optional<version_constraint> c, + butl::optional<std::string> e, butl::optional<std::string> r) : dependency {std::move (n), std::move (c)}, type (t), buildtime (b), + enable (std::move (e)), reflect (std::move (r)) {} // Parse the test dependency string representation in the - // `[*] <name> [<version-constraint>] [<reflect-config>]` form. Throw - // std::invalid_argument if the value is invalid. + // `[*] <name> [<version-constraint>] ['?' <enable-condition>] [<reflect-config>]` + // form. Throw std::invalid_argument if the value is invalid. // // Verify that the reflect clause, if present, refers to the test // dependency package configuration variable. Note that such variable |