Skip to content

Relativize LCOV paths against a root, match coverage roots at segments - #73

Merged
davidanthoff merged 1 commit into
mainfrom
lcov-relative-paths
Aug 20, 2026
Merged

Relativize LCOV paths against a root, match coverage roots at segments#73
davidanthoff merged 1 commit into
mainfrom
lcov-relative-paths

Conversation

@davidanthoff

Copy link
Copy Markdown
Member

Groundwork for julia-testitems/testitem-workflow#11 (Codecov reporting 0%). The workflow-side fix is julia-testitems/testitem-workflow#13; this PR fixes the LCOV output itself.

write_lcov gains root

write_lcov emitted the absolute path uri2filepath hands back — and on Windows a backslashed one, which no LCOV consumer recognizes at all, so a Windows matrix leg contributed nothing to a merged report even before the absolute-path problem. Coverage services match SF: paths against paths in the repository, so the absolute paths of a CI runner match nothing, and a fully covered package can come out at 0%.

It now takes the same root keyword write_junit_xml already has, implemented by the same helper: _relative_path is split into _report_path (returns nothing for a URI it cannot turn into a path) plus the URI-falling-back wrapper the JUnit classnames need. So both writers relativize identically, abspath a relative root the same way, and refuse to walk out of the root with .. the same way.

  • Paths always use / separators now, root or no root.
  • A file outside root keeps its absolute path rather than a ..-heavy one — the choice the JUnit writer already makes, and the one that keeps a stray record looking like a stray record rather than a coverage regression.

write_lcov is itself unreleased (it is in the 2.0.0 section of the CHANGELOG), so the signature change is not breaking for anyone; the existing bullet is amended rather than a new one added.

Coverage roots match whole path segments

Separate bug in the test process, found while making TestItemApp narrow its roots to src/ext: a root is a folder URI and filepath2uri never leaves a trailing slash, so startswith also accepted siblings whose names merely started with it — a root of <workspace>/Foo collected coverage for <workspace>/Foo2.

Tests

Four new items, all passing; the whole of test_junit.jl + test_coverage.jl is green (20/20).

  • LCOV relativizes against a root, including a relative root (the relpath trap the JUnit test already guards).
  • A file outside the root stays absolute.
  • Forward slashes everywhere, non-file: URIs skipped.
  • Coverage roots match whole path segments — verified it fails on the old prefix match and passes with the fix.

Note for whoever tags this

Project.toml says 1.7.1-DEV while the CHANGELOG heads its unreleased section ## [2.0.0] - Unreleased and contains a breaking JSONRPC entry. Not touched here, but the two disagree.

🤖 Generated with Claude Code

`write_lcov` emitted the absolute path `uri2filepath` hands back — and on
Windows a backslashed one, which no LCOV consumer recognizes at all. Coverage
services match `SF:` paths against paths in the repository, so the absolute
paths of a CI runner match nothing, and a fully covered package can be reported
as 0%.

It gains a `root` keyword, the same one `write_junit_xml` already takes and now
implemented by the same helper: `_relative_path` is split into `_report_path`,
which returns `nothing` for a URI it cannot turn into a path, plus the
URI-falling-back wrapper the JUnit classnames need. Paths always use `/`
separators now, root or no root, so a Windows leg and a Linux leg of the same
matrix contribute the same file names to a merged report. A file outside `root`
keeps its absolute path rather than a `..`-heavy one — the choice the JUnit
writer already makes, and the one that keeps a stray record looking like a
stray record instead of a coverage regression.

Separately, coverage root URIs are now matched at whole path segments. A root
is a folder URI and `filepath2uri` never leaves a trailing slash, so the prefix
test also accepted siblings whose names merely started with it: a root of
`<workspace>/Foo` collected coverage for `<workspace>/Foo2`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@davidanthoff
davidanthoff merged commit d91f8f6 into main Aug 20, 2026
12 checks passed
@davidanthoff
davidanthoff deleted the lcov-relative-paths branch August 20, 2026 19:08
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.

1 participant