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 ++++-- tests/manifest/testscript | 63 +++++++++++++++++++++++++++++++++++++---------- 3 files changed, 72 insertions(+), 26 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 - // ` [] []` 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 diff --git a/tests/manifest/testscript b/tests/manifest/testscript index 3179005..4f6433b 100644 --- a/tests/manifest/testscript +++ b/tests/manifest/testscript @@ -4023,6 +4023,17 @@ tests: bar config.bar.test = foo EOF + : enable + : + $* <>EOF + : 1 + name: foo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + tests: bar == 1.0.0 ? ($windows) config.bar.test = foo + EOF + : invalid-variable : $* <>EOE != 0 @@ -4037,6 +4048,45 @@ EOE } + : enable + : + { + : after-version-constraint + : + $* <>EOF + : 1 + name: foo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + tests: bar == 1.0.0 ? ($windows) + EOF + + : no-version-constraint + : + $* <>EOF + : 1 + name: foo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + tests: bar ? ($windows) + EOF + + : unterminated + : + $* <>EOE != 0 + : 1 + name: foo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + tests: bar ? ($windows + EOI + stdin:6:8: error: unterminated evaluation context + EOE + } + : newline : $* <>EOE != 0 @@ -4091,19 +4141,6 @@ EOI stdin:6:8: error: only single package allowed EOE - - : enable - : - $* <>EOE != 0 - : 1 - name: foo - version: 2.0.0 - summary: Modern C++ parser - license: LGPLv2 - tests: bar ? (windows) - EOI - stdin:6:8: error: unexpected enable clause - EOE } : buildfile -- cgit v1.1