Skip to content

Avoid counting macro call locations as uncovered lines - #91

Merged
maleadt merged 1 commit into
JuliaCI:masterfrom
devmotion:macrocall-location-is-not-runnable-code
Oct 2, 2026
Merged

maleadt merged 1 commit into
JuliaCI:masterfrom
devmotion:macrocall-location-is-not-runnable-code

Conversation

@devmotion

@devmotion devmotion commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

CoverageTools uses source analysis to mark lines inside uncalled functions as uncovered. A macro call contains a LineNumberNode recording where the macro was written. When the macro appears inside another statement, Julia may emit no coverage counter for that line, but CoverageTools currently marks it uncovered anyway. This produces a miss that no test can turn into a hit (#90).

The source analysis now skips that location node while continuing through the macro's arguments. A macro call used as a statement still gets its line from the enclosing block. For example, in return sum(@view(x[1:1])) split across lines, the @view line remains without a count in both called and uncalled functions; the surrounding runnable lines are still reported.

The regression tests cover a nested macro, a macro used as a statement, and code after the location node. The full suite passes on Julia 1.10 and nightly. I also reproduced the coverage output with Julia's .cov writer on 1.10.

Fixes #90.

@codecov

codecov Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.09%. Comparing base (4b28312) to head (4a40496).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #91      +/-   ##
==========================================
+ Coverage   96.08%   96.09%   +0.01%     
==========================================
  Files           4        4              
  Lines         383      384       +1     
==========================================
+ Hits          368      369       +1     
  Misses         15       15              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

A macro call's second argument records its location. When a macro is nested
inside an uncalled function, treating that node as a body statement creates
an uncovered line for which Julia emits no coverage counter. Skip the
location node while still visiting the macro arguments. Macro calls used
as statements keep the line from their enclosing block.
@maleadt
maleadt force-pushed the macrocall-location-is-not-runnable-code branch from 295c3ce to 4a40496 Compare October 2, 2026 11:55
@maleadt maleadt changed the title Don't treat a macro call's location as runnable code Avoid counting macro call locations as uncovered lines Oct 2, 2026
@maleadt
maleadt merged commit 85abac9 into JuliaCI:master Oct 2, 2026
10 of 11 checks passed
@devmotion
devmotion deleted the macrocall-location-is-not-runnable-code branch October 2, 2026 12:03
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.

amend_coverage_from_src! marks macro call lines as uncovered code that no test can cover

2 participants