From 839891e0391e1fae0eef67a6837924ad443aa30b Mon Sep 17 00:00:00 2001 From: Moritz Marquardt Date: Fri, 10 Mar 2023 11:48:03 +0100 Subject: [PATCH 1/3] Implement separate "boa test" command to fix #326, including an --extra-deps argument --- boa/cli/boa.py | 17 +++++++++++++++++ boa/cli/test.py | 22 ++++++++++++++++++++++ boa/core/test.py | 3 +++ 3 files changed, 42 insertions(+) create mode 100644 boa/cli/test.py diff --git a/boa/cli/boa.py b/boa/cli/boa.py index 13dc7f6d..92bb1cb2 100644 --- a/boa/cli/boa.py +++ b/boa/cli/boa.py @@ -65,6 +65,18 @@ def main(config=None): help="Validate recipe.yaml", ) + test_parser = argparse.ArgumentParser(add_help=False) + test_parser.add_argument( + "--extra-deps", + action="append", + help="Extra dependencies to add to all test environment creation steps.", + ) + subparsers.add_parser( + "test", + parents=[parent_parser, test_parser], + help="test an already built package (include_recipe of the package must be true)", + ) + build_parser = argparse.ArgumentParser(add_help=False) build_parser.add_argument( "-i", @@ -201,6 +213,7 @@ def main(config=None): from boa.cli import convert from boa.cli import transmute from boa.cli import validate + from boa.cli import test if command == "convert": convert.main(args.target) @@ -210,6 +223,10 @@ def main(config=None): validate.main(args.target) exit() + if command == "test": + test.main(args) + exit() + if command == "transmute": transmute.main(args) exit() diff --git a/boa/cli/test.py b/boa/cli/test.py new file mode 100644 index 00000000..6f987d66 --- /dev/null +++ b/boa/cli/test.py @@ -0,0 +1,22 @@ +# Copyright (C) 2021, QuantStack +# SPDX-License-Identifier: BSD-3-Clause +from boa.core.run_build import initialize_conda_build_config +from boa.core.test import run_test + +from rich.console import Console + +console = Console() + + +def main(args): + stats = {} + config = initialize_conda_build_config(args) + + run_test( + args.target, + config, + stats, + move_broken=False, + provision_only=False, + extra_deps=getattr(args, "extra_deps", []) + ) diff --git a/boa/core/test.py b/boa/core/test.py index 5105456b..51ff6d9d 100644 --- a/boa/core/test.py +++ b/boa/core/test.py @@ -653,6 +653,7 @@ def run_test( move_broken=True, provision_only=False, solver=None, + extra_deps=[], ): """ Execute any test scripts for the given package. @@ -754,6 +755,8 @@ def run_test( # get_build_metadata(metadata) specs = metadata.get_test_deps(py_files, pl_files, lua_files, r_files) + if extra_deps is not None and len(extra_deps) > 0: + specs += extra_deps tests_metadata = metadata.output.data.get("test") exists_metadata = tests_metadata.get("exists", {}) From 5e8f3b1244187d283a10b9b64d0cb34f8f874919 Mon Sep 17 00:00:00 2001 From: Moritz Marquardt Date: Fri, 5 May 2023 10:47:18 +0200 Subject: [PATCH 2/3] Remove mutable argument default --- boa/core/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boa/core/test.py b/boa/core/test.py index 51ff6d9d..d89db25a 100644 --- a/boa/core/test.py +++ b/boa/core/test.py @@ -653,7 +653,7 @@ def run_test( move_broken=True, provision_only=False, solver=None, - extra_deps=[], + extra_deps=None, ): """ Execute any test scripts for the given package. From 77c0231151538472805b0f1ba7afc74c927cd608 Mon Sep 17 00:00:00 2001 From: Moritz Marquardt Date: Fri, 5 May 2023 10:56:14 +0200 Subject: [PATCH 3/3] Run black formatter --- boa/cli/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boa/cli/test.py b/boa/cli/test.py index 6f987d66..e9d59fa0 100644 --- a/boa/cli/test.py +++ b/boa/cli/test.py @@ -18,5 +18,5 @@ def main(args): stats, move_broken=False, provision_only=False, - extra_deps=getattr(args, "extra_deps", []) + extra_deps=getattr(args, "extra_deps", []), )