Skip to content

xml: don't lose the report when a measured file is outside the cwd - #89

Merged
jaltmayerpizzorno merged 1 commit into
plasma-umass:mainfrom
Eljees:fix/87-xml-report-outside-cwd
Aug 10, 2026
Merged

xml: don't lose the report when a measured file is outside the cwd#89
jaltmayerpizzorno merged 1 commit into
plasma-umass:mainfrom
Eljees:fix/87-xml-report-outside-cwd

Conversation

@Eljees

@Eljees Eljees commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #87.

print_xml() makes each measured file relative with Path(...).relative_to(Path.cwd()), and relative_to raises ValueError for anything outside the cwd. It happens in the atexit handler — so the test run finishes, the coverage is collected, and then the entire report is lost.

--source does not help: the constructor only keeps paths that exist at report time and silently drops the rest.

SlipCover already answers this exact question in PathSimplifier.simplify() (src/slipcover/slipcover.py), where the same call is guarded and degrades to the absolute path. This brings the XML reporter in line with it: on ValueError the absolute path is used, and the sources entry is recorded only when the file really does live under the cwd.

Test test_xml_file_outside_cwd measures a file outside the working directory and asserts that the XML parses, that sources holds only the cwd, and that the class carries the absolute filename. It raises ValueError on main.

AI-assisted (LLM used for drafting and for running the checks); the analysis and the runs are mine.

@jaltmayerpizzorno
jaltmayerpizzorno merged commit 36cf9a6 into plasma-umass:main Aug 10, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xml report trying to get relative path which is not always available

2 participants