From 83843619aad7570a603091d4ae486614b56d54e6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 3 Apr 2020 16:39:10 +0300 Subject: Add support for test-exclude task manifest value --- bbot/worker/worker.cxx | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'bbot') diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx index 025fa04..8d8f65c 100644 --- a/bbot/worker/worker.cxx +++ b/bbot/worker/worker.cxx @@ -12,7 +12,7 @@ #include // strchr() #include #include -#include // find() +#include // find(), find_if(), remove_if() #include #include @@ -922,13 +922,41 @@ build (size_t argc, const char* argv[]) package_manifest pm (parse_manifest (mf, "package")); // Run the package external tests if any of the tests, examples, or - // benchmarks manifest values are specified. + // benchmarks manifest values are specified. But first filter these values + // against the test-exclude task manifest values using the package names. // - // Note that we assume that these packages belong to the dependent - // package's repository or its complement repositories, recursively. Thus, - // we test them in the configuration used to build the dependent package - // (except for the build system module). + // Note that a proper implementation should also make sure that the + // excluded test package version matches the version that will supposedly + // be configured by bpkg and probably abort the build if that's not the + // case. Such a mismatch can happen due to some valid reasons (the + // repository was updated since the task was issued, etc) and should + // probably be followed with automatic rebuild (the flake monitor idea). + // Anyway, this all requires additional thinking, so let's keep it simple + // for now. // + // Filter the external test dependencies in place. + // + auto filter = [&tm] (small_vector& deps) + { + const small_vector& tes (tm.test_exclusions); + + deps.erase ( + remove_if (deps.begin (), deps.end (), + [&tes] (const dependency& d) + { + return find_if (tes.begin (), tes.end (), + [&d] (const package& te) + { + return te.name == d.name; + }) != tes.end (); + }), + deps.end ()); + }; + + filter (pm.tests); + filter (pm.examples); + filter (pm.benchmarks); + bool external_tests (!pm.tests.empty () || !pm.examples.empty () || !pm.benchmarks.empty ()); @@ -937,12 +965,17 @@ build (size_t argc, const char* argv[]) // current working directory. Optionally set the environment variables for // bpkg processes. Return true if all operations for all packages succeed. // + // Note that we assume that these packages belong to the dependent + // package's repository or its complement repositories, recursively. Thus, + // we test them in the configuration used to build the dependent package + // (except for the build system module). + // auto test = [&trace, &wre, &step_args, &config_args, &env_args] - (const small_vector& pkgs, + (const small_vector& deps, operation_result& r, const small_vector& envvars = {}) { - for (const dependency& d: pkgs) + for (const dependency& d: deps) { const string& pkg (d.name.string ()); -- cgit v1.1