Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement separate "boa test" command to fix #326 #343

Merged
merged 3 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Implement separate "boa test" command to fix #326, including an --ext…
…ra-deps argument
  • Loading branch information
moqmar committed May 5, 2023
commit 839891e0391e1fae0eef67a6837924ad443aa30b
17 changes: 17 additions & 0 deletions boa/cli/boa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
22 changes: 22 additions & 0 deletions boa/cli/test.py
Original file line number Diff line number Diff line change
@@ -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", [])
)
3 changes: 3 additions & 0 deletions boa/core/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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", {})
Expand Down