From 724b68d96bb69685b0b878916e4cb89b3368705b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 19 Aug 2021 21:21:32 +0300 Subject: Add support for build-time mark (*) in tests, examples, and benchmarks package manifest values --- libbpkg/manifest.cxx | 16 +++++++++++++--- libbpkg/manifest.hxx | 12 +++++++++++- tests/manifest/testscript | 22 ++++++++++++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx index d4c3f9d..8631d18 100644 --- a/libbpkg/manifest.cxx +++ b/libbpkg/manifest.cxx @@ -2340,17 +2340,27 @@ namespace bpkg // Parse the test dependencies. // - for (name_value& v: tests) + for (name_value& t: tests) { - nv = move (v); // Restore as bad_value() uses its line/column. + nv = move (t); // Restore as bad_value() uses its line/column. - dependency d (parse_dependency (move (nv.value), nv.name.c_str ())); + string& v (nv.value); + + bool b (v[0] == '*'); + size_t p (v.find_first_not_of (spaces, b ? 1 : 0)); + + if (p == string::npos) + bad_value ("no " + nv.name + " package name specified"); + + dependency d (parse_dependency (p == 0 ? move (v) : string (v, p), + nv.name.c_str ())); try { m.tests.emplace_back ( move (d.name), to_test_dependency_type (nv.name), + b, move (d.constraint)); } catch (const invalid_argument&) diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index bdb7a9b..1b62512 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -694,12 +694,22 @@ namespace bpkg struct test_dependency: dependency { test_dependency_type type; + bool buildtime; test_dependency () = default; test_dependency (package_name n, test_dependency_type t, + bool b, butl::optional c) - : dependency {std::move (n), std::move (c)}, type (t) {} + : dependency {std::move (n), std::move (c)}, type (t), buildtime (b) {} + + inline std::string + string () const + { + return buildtime + ? "* " + dependency::string () + : dependency::string (); + } }; class LIBBPKG_EXPORT package_manifest diff --git a/tests/manifest/testscript b/tests/manifest/testscript index 3d6b060..4770e96 100644 --- a/tests/manifest/testscript +++ b/tests/manifest/testscript @@ -710,6 +710,28 @@ tests: bar == 2.0.0- EOI + : no-name + : + $* <'stdin:6:8: error: no tests package name specified' != 0 + : 1 + name: foo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + tests: * + EOI + + : buildtime + : + $* <>EOF + : 1 + name: foo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + tests: * foo-tests + EOF + : complete : { -- cgit v1.1