Skip to content

Commit

Permalink
Apply suggestions from code review and also print report to terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanv committed Aug 19, 2023
1 parent 9fa421c commit f9f3023
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions spin/cmds/meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ def _get_configured_command(command_name):
@click.command()
@click.argument("pytest_args", nargs=-1)
@click.option(
"-c",
"--coverage",
is_flag=True,
help="Report coverage of project code. HTML output goes under build/coverage",
help="Generate a coverage report of executed tests. An HTML copy of the report is written to `build/coverage`.",
)
@click.pass_context
def test(ctx, pytest_args, coverage=False):
Expand Down Expand Up @@ -243,12 +244,13 @@ def test(ctx, pytest_args, coverage=False):

if coverage:
coverage_dir = os.path.join(os.getcwd(), "build/coverage/")
print(f"Removing `{coverage_dir}`")
if os.path.isdir(coverage_dir):
print(f"Removing `{coverage_dir}`")
shutil.rmtree(coverage_dir)
os.makedirs(coverage_dir)
pytest_args = [
*pytest_args,
"--cov-report=term",
f"--cov-report=html:{coverage_dir}",
f"--cov={package}",
]
Expand Down

0 comments on commit f9f3023

Please sign in to comment.