diff options
-rw-r--r-- | libbpkg/manifest.cxx | 16 | ||||
-rw-r--r-- | libbpkg/manifest.hxx | 12 | ||||
-rw-r--r-- | 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<version_constraint> 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 + : + $* <<EOI 2>'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 >>EOF + : 1 + name: foo + version: 2.0.0 + summary: Modern C++ parser + license: LGPLv2 + tests: * foo-tests + EOF + : complete : { |