From 066c25383db8d24cc0aed21d9bd4a071c1afdbbd Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 6 Sep 2021 19:05:38 +0300 Subject: Add support for requires, tests, examples, benchmarks, and host task manifest values and drop test-exclude value --- libbbot/manifest.cxx | 57 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 23 deletions(-) (limited to 'libbbot/manifest.cxx') diff --git a/libbbot/manifest.cxx b/libbbot/manifest.cxx index 33b5046..5e00201 100644 --- a/libbbot/manifest.cxx +++ b/libbbot/manifest.cxx @@ -68,9 +68,9 @@ namespace bbot // interactive_mode // string - to_string (interactive_mode s) + to_string (interactive_mode m) { - switch (s) + switch (m) { case interactive_mode::false_: return "false"; case interactive_mode::true_: return "true"; @@ -329,7 +329,8 @@ namespace bbot } catch (const invalid_argument&) { - bad_value (string ("invalid task request interactive mode")); + bad_value ( + string ("invalid task request interactive mode '" + v + "'")); } } else if (n == "interactive-login") @@ -597,37 +598,28 @@ namespace bbot trust.emplace_back (move (v)); } - else if (n == "test-exclude") + else if (n == "requires") { - size_t p (v.find ('/')); - if (p == string::npos) - bad_value ("invalid test exclusion package: '/' is expected"); - - package_name pn; - try { - pn = package_name (string (v, 0, p)); + requirements.push_back (requirement_alternatives (v)); } catch (const invalid_argument& e) { - bad_value (string ("invalid test exclusion package name: ") + - e.what ()); + bad_value (e.what ()); } - - bpkg::version pv; - + } + else if (n == "tests" || n == "examples" || n == "benchmarks") + { try { - pv = bpkg::version (string (v, p + 1)); + tests.push_back (test_dependency (move (v), + to_test_dependency_type (n))); } catch (const invalid_argument& e) { - bad_value (string ("invalid test exclusion package version: ") + - e.what ()); + bad_value (e.what ()); } - - test_exclusions.push_back (package {move (pn), move (pv)}); } else if (n == "machine") { @@ -673,6 +665,18 @@ namespace bbot if (config.empty ()) bad_value ("empty task configuration"); } + else if (n == "host") + { + if (host) + bad_name ("task host value redefinition"); + + if (v == "true") + host = true; + else if (v == "false") + host = false; + else + bad_value ("invalid task host value '" + v + "'"); + } else if (n == "warning-regex") { if (!warning_regex.empty ()) @@ -758,8 +762,11 @@ namespace bbot for (const string& v: trust) s.next ("trust", v); - for (const package& te: test_exclusions) - s.next ("test-exclude", te.name.string () + '/' + te.version.string ()); + for (const requirement_alternatives& r: requirements) + s.next ("requires", r.string ()); + + for (const test_dependency& t: tests) + s.next (to_string (t.type), t.string ()); s.next ("machine", machine); s.next ("target", target.string ()); @@ -788,6 +795,10 @@ namespace bbot }; serialize_list ("config", config); + + if (host) + s.next ("host", *host ? "true" : "false"); + serialize_list ("warning-regex", warning_regex); if (interactive) -- cgit v1.1