From c3158b221ef94b4f2c0d2a67aebcce22acf50993 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 31 Jan 2024 18:17:59 +0300 Subject: Add support for enable clause in tests package manifest value --- libbpkg/manifest.cxx | 28 +++++++++++++++++----------- libbpkg/manifest.hxx | 7 +++++-- 2 files changed, 22 insertions(+), 13 deletions(-) (limited to 'libbpkg') 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 - // ` [] []` 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. + // ` [] ['?' ] []` + // 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 (*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 enable; butl::optional reflect; test_dependency () = default; @@ -1090,15 +1091,17 @@ namespace bpkg test_dependency_type t, bool b, butl::optional c, + butl::optional e, butl::optional 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 - // `[*] [] []` form. Throw - // std::invalid_argument if the value is invalid. + // `[*] [] ['?' ] []` + // 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 -- cgit v1.1