From fb940889f0be56492bde5d008ed48ff58f172948 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 20 Dec 2021 18:55:59 +0300 Subject: Adapt to requirement alternatives parsing API change --- libbbot/manifest.cxx | 26 ++++++++++++++++++-------- tests/manifest/task.testscript | 18 +++++++++++++++++- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/libbbot/manifest.cxx b/libbbot/manifest.cxx index c604810..3f07091 100644 --- a/libbbot/manifest.cxx +++ b/libbbot/manifest.cxx @@ -530,6 +530,11 @@ namespace bbot optional repo_url; optional repo_type; + // We will also cache the requires values to parse them later, after the + // package name is parsed. + // + vector reqs; + for (nv = p.next (); !nv.empty (); nv = p.next ()) { string& n (nv.name); @@ -602,14 +607,7 @@ namespace bbot } else if (n == "requires") { - try - { - requirements.push_back (requirement_alternatives (v)); - } - catch (const invalid_argument& e) - { - bad_value (e.what ()); - } + reqs.push_back (move (nv)); } else if (n == "tests" || n == "examples" || n == "benchmarks") { @@ -754,6 +752,18 @@ namespace bbot nv = move (*repo_url); // Restore as bad_value() uses its line/column. bad_value (string ("invalid task repository URL: ") + e.what ()); } + + // Parse the requirements. + // + for (const name_value& r: reqs) + { + requirements.push_back ( + requirement_alternatives (r.value, + name, + p.name (), + r.value_line, + r.value_column)); + } } void task_manifest:: diff --git a/tests/manifest/task.testscript b/tests/manifest/task.testscript index 2d50914..bd1a365 100644 --- a/tests/manifest/task.testscript +++ b/tests/manifest/task.testscript @@ -79,13 +79,29 @@ test.options += -t name: foo version: 1.0 repository-url: http://pkg.example.org/1/math - requires: c++14 + requires: {c++ >= 14 windows} requires: host machine: windows target: x86_64-microsoft-win32-msvc14.0 EOF } + : requires-invalid + : + { + $* <>EOE != 0 + : 1 + name: foo + version: 1.0 + repository-url: http://pkg.example.org/1/math + requires: {c++ >= 14 windows + machine: windows + target: x86_64-microsoft-win32-msvc14.0 + EOI + stdin:5:29: error: requirement or '}' expected + EOE + } + : tests : { -- cgit v1.1