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 ++++++++++++++++++++++++++++++++++++-------- doc/manual.cli | 32 +++++++++++++++++++++++------ tests/integration/testscript | 2 +- 3 files changed, 68 insertions(+), 15 deletions(-) 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 ()); diff --git a/doc/manual.cli b/doc/manual.cli index 4191d6d..85ad89a 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -321,6 +321,7 @@ version: repository-url: [repository-type]: pkg|git|dir [trust]: +[test-exclude]: / machine: target: @@ -385,6 +386,21 @@ some agents may only trust their internally-specified fingerprints to prevent the \"man in the middle\" attacks. +\h2#arch-task-test-exclude|\c{test-exclude}| + +\ +[test-exclude]: / +\ + +The separate test, example, or benchmark package to exclude from building +together with the primary package. This value may be specified multiple times. + +The controller adds this value for packages specified via the \c{tests}, +\c{examples}, and \c{benchmarks} primary package manifest values which should +be excluded from building due to their \c{builds}, \c{build-include}, and +\c{build-exclude} manifest values. + + \h2#arch-task-machine|\c{machine}| \ @@ -795,7 +811,8 @@ bpkg -v update bpkg -v test # for each package referred to by the tests, examples, or benchmarks -# package manifest values: +# package manifest values and not excluded by the test-exclude task +# manifest values: # { # bpkg.configure.build @@ -837,7 +854,8 @@ bpkg -v test } # if any of the tests, examples, or benchmarks package manifest - # values are specified: + # values are specified and are not all excluded by the test-exclude + # task manifest values: # { # bpkg.test-installed.create @@ -853,7 +871,8 @@ bpkg -v test bpkg -v fetch --trust # for each package referred to by the tests, examples, or - # benchmarks package manifest values: + # benchmarks package manifest values and not excluded by the + # test-exclude task manifest values: # { # bpkg.configure.build @@ -1062,9 +1081,10 @@ that applies to the \c{bpkg.configure.create} step, then in addition to building and possibly running tests, the \c{bbot} worker will also test installing and uninstalling each package. Furthermore, if the package contains subprojects that support the test operation and/or refers to other packages -via the \c{tests}, \c{examples}, or \c{benchmarks} manifest values, then the -worker will additionally build such subprojects/packages against the -installation and run their tests. +via the \c{tests}, \c{examples}, or \c{benchmarks} manifest values which are +not excluded by the \c{test-exclude} task manifest values, then the worker +will additionally build such subprojects/packages against the installation and +run their tests. Two types of installations can be tested: \i{system} and \i{private}. A system installation uses a well-known location, such as \c{/usr} or \c{/usr/local}, diff --git a/tests/integration/testscript b/tests/integration/testscript index 7970f0c..b99e37a 100644 --- a/tests/integration/testscript +++ b/tests/integration/testscript @@ -74,7 +74,7 @@ rfp = yes #\ pkg = libbuild2-hello -ver = 0.1.0-a.0.20200303044811.aeb178751f6a +ver = 0.1.0-a.0.20200402131859.22b478618203 rep_url = "https://github.com/build2/libbuild2-hello.git#master" rep_type = git rfp = yes -- cgit v1.1