Skip to content

Commit f2c21eb

Browse files
committed
ENH, TST: Added checks for missing debug files
1 parent 9749de0 commit f2c21eb

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

spin/cmds/meson.py

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import re
77
import shutil
88
import sys
9+
from pathlib import Path
910

1011
import click
1112

@@ -149,6 +150,13 @@ def _check_coverage_tool_installation(coverage_type: GcovReports):
149150
"Generate coverage artefacts by running `spin test --gcov`"
150151
)
151152

153+
debug_files = Path(build_dir).rglob("*.gcno")
154+
if len(list(debug_files)) == 0:
155+
raise click.ClickException(
156+
"debug build not found, cannot generate coverage reports. "
157+
"Generate coverage artefacts by running `spin test --gcov`"
158+
)
159+
152160
# Verify the tools are installed prior to the build
153161
p = _run(["ninja", "-C", build_dir, "-t", "targets", "all"], output=False)
154162
if f"coverage-{coverage_type.value}" not in p.stdout.decode("ascii"):

spin/tests/test_build_cmds.py

+15
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ def test_coverage_reports(report_type, output_file):
8686
), f"coverage report not generated for gcov build ({report_type})"
8787

8888

89+
@pytest.mark.parametrize(
90+
"command,error_message",
91+
[
92+
("", "`build` folder not found"),
93+
("build", "debug build not found"),
94+
("test", "debug build not found"),
95+
],
96+
)
97+
def test_no_debug_coverage_attempt(command, error_message):
98+
"""Does gcov report throw error in case of missing debug files"""
99+
spin(command) if command else None
100+
output = spin("test", "--gcov-report", "html", sys_exit=False)
101+
assert error_message in stderr(output)
102+
103+
89104
def test_expand_pythonpath():
90105
"""Does an $ENV_VAR get expanded in `spin run`?"""
91106
output = spin("run", "echo $PYTHONPATH")

0 commit comments

Comments
 (0)