Skip to content

Commit 91f6905

Browse files
committed
fix: Debug coverage using nox target
1 parent a1a69d3 commit 91f6905

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

noxfile.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,28 @@ def coverage_report(session):
146146

147147
import pathlib
148148

149-
coverage_dir = pathlib.Path("coverage")
149+
# Use absolute path relative to session.invoked_from
150+
project_root = pathlib.Path(session.invoked_from)
151+
coverage_dir = project_root / "coverage"
152+
150153
if not coverage_dir.exists():
151-
session.error("No coverage directory found. Run tests with --coverage first.")
152-
153-
# Combine all coverage files from coverage directory
154-
session.run(
155-
"coverage", "combine", "--data-file=coverage/.coverage", "coverage/.coverage.*"
156-
)
154+
session.error("No coverage directory found. Run tests with nox -s unit first.")
155+
156+
# Check if we have a combined coverage file or individual files
157+
combined_file = coverage_dir / ".coverage"
158+
coverage_files = sorted(coverage_dir.glob(".coverage.*"))
159+
160+
if not combined_file.exists() and not coverage_files:
161+
session.error("No coverage files found. Run tests with nox -s unit first.")
162+
163+
if coverage_files:
164+
session.log(f"Combining {len(coverage_files)} coverage files")
165+
session.run("coverage", "combine", "--data-file=coverage/.coverage", *[str(f) for f in coverage_files])
166+
else:
167+
session.log("Using existing combined coverage file")
157168

158169
# Generate reports in coverage directory
159-
session.run("coverage", "report", "--format=markdown")
160-
session.run("coverage", "html", "-d", "coverage/htmlcov")
161-
session.run("coverage", "xml", "-o", "coverage/coverage.xml", "-i")
162-
session.run("coverage", "json", "-o", "coverage/coverage.json")
170+
session.run("coverage", "report", "--data-file=coverage/.coverage", "--format=markdown")
171+
session.run("coverage", "html", "--data-file=coverage/.coverage", "-d", "coverage/htmlcov")
172+
session.run("coverage", "xml", "--data-file=coverage/.coverage", "-o", "coverage/coverage.xml", "-i")
173+
session.run("coverage", "json", "--data-file=coverage/.coverage", "-o", "coverage/coverage.json")

0 commit comments

Comments
 (0)