aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-01-31 18:17:59 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-02-02 10:28:10 +0300
commitc3158b221ef94b4f2c0d2a67aebcce22acf50993 (patch)
tree5f7e2da546e2e4df4c83c15360c36e4e20361198
parentb836f4966224424649de3e1dde1bca39888d9ed9 (diff)
Add support for enable clause in tests package manifest value
-rw-r--r--libbpkg/manifest.cxx28
-rw-r--r--libbpkg/manifest.hxx7
-rw-r--r--tests/manifest/testscript63
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
- // `<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
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 >>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
:
$* <<EOI 2>>EOE != 0
@@ -4037,6 +4048,45 @@
EOE
}
+ : enable
+ :
+ {
+ : after-version-constraint
+ :
+ $* <<EOF >>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 >>EOF
+ : 1
+ name: foo
+ version: 2.0.0
+ summary: Modern C++ parser
+ license: LGPLv2
+ tests: bar ? ($windows)
+ EOF
+
+ : unterminated
+ :
+ $* <<EOI 2>>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
:
$* <<EOI 2>>EOE != 0
@@ -4091,19 +4141,6 @@
EOI
stdin:6:8: error: only single package allowed
EOE
-
- : enable
- :
- $* <<EOI 2>>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