Skip to content

Amend coverage after merge - #130

Open
gpeairs wants to merge 1 commit into
julia-testitems:mainfrom
gpeairs:amend-coverage-after-merge
Open

gpeairs wants to merge 1 commit into
julia-testitems:mainfrom
gpeairs:amend-coverage-after-merge

Conversation

@gpeairs

@gpeairs gpeairs commented Nov 4, 2026

Copy link
Copy Markdown

Julia reports no counts for a function that was never compiled, so amend_coverage_from_src! parses the source and marks the lines of such a function as missed (0). It skips any function where some line already has a count, which leaves the lines Julia does not instrument as nothing. TestItemServer.process_coverage_data runs that amend step on each test item' coverage, and the controller then sums the amended vectors across items. If a function f is first compiled in item B:

  • In item A that runs before B on any process, f has no counts. Amend marks every line of f as 0, including lines Julia never instruments, such as the signature of a method that is only ever inlined.
  • In item B, f's instrumented lines have counts and those lines stay nothing.
  • merge_coverage_counts gives 0 + nothing = 0, so those lines come out missed even though f ran from start to finish.

Pkg.test runs amend once over the whole process, so there f counts as having run and the lines stay nothing. For my own package I see around a 2 percentage point drop in "coverage" switching from julia-runtest to the julia-run-testitems action, largely from counting method signatures and macro lines as missed.

This PR makes the following changes:

  • TestItemServer.process_coverage_data now sends the raw merged counts of the item. The amend_coverage_from_src! import is gone from the test process.
  • _check_testrun_complete! amends each file once, after merge_coverage_counts(tr.coverage), using _amend_coverage_from_src. If the file no longer exists or no longer parses (edited during the run, for example), its counts are reported as collected, with a warning when it doesn't parse. The test process used to throw from inside the item instead.
  • A CHANGELOG entry.
  • A test that fails without the fix.

There's a related issue not addressed here. On Julia 1.11–1.13, jl_clear_coverage_data resets counters to "not instrumented", and then the next hit only brings a counter back to "instrumented, 0 hits" (JuliaLang/julia#62199, fixed on master by JuliaLang/julia#62307, in 1.14 only). Because the test process clears coverage before every window, a line that was already compiled and runs exactly once in a window reads 0. I think a fix here would be more involved so I didn't touch it.

This branch has not been deployed

No deployments
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