Skip to content

Commit 145f2c8

Browse files
committed
TST: UT for spin coverage
1 parent d66940b commit 145f2c8

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

noxfile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33

44
@nox.session
55
def test(session: nox.Session) -> None:
6-
session.install(".", "pytest", "build", "meson-python", "ninja", "gcovr")
6+
session.install(
7+
".", "pytest", "build", "meson-python", "ninja", "gcovr", "pytest-cov"
8+
)
79
session.run("pytest", "spin", *session.posargs)

spin/tests/test_build_cmds.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,18 @@ def test_parallel_builds(example_pkg):
201201
assert "build-install" in example_pkg_path
202202
assert "parallel/build-install" in example_pkg_parallel_path
203203
assert "parallel/build-install" not in example_pkg_path
204+
205+
206+
def test_coverage_default(example_pkg):
207+
"""Does `spin coverage` run and produce terminal coverage output?"""
208+
p = spin("coverage", sys_exit=False)
209+
assert p.returncode == 0
210+
assert "coverage" in stdout(p).lower() or "TOTAL" in stdout(p)
211+
212+
213+
def test_coverage_with_cov_report(example_pkg):
214+
"""Does `spin coverage --cov-report` generate a file-based report?"""
215+
p = spin("coverage", "--cov-report", "json:coverage.json", sys_exit=False)
216+
assert p.returncode == 0
217+
report = Path("build/coverage/coverage.json")
218+
assert report.exists(), f"coverage report not generated at {report}"

0 commit comments

Comments
 (0)