Skip to content

coverage: keep same-named functions from different builds apart - #7141

Merged
matz merged 1 commit into
mruby:masterfrom
takumin:coverage-merge-mode-functions
Aug 14, 2026
Merged

coverage: keep same-named functions from different builds apart#7141
matz merged 1 commit into
mruby:masterfrom
takumin:coverage-merge-mode-functions

Conversation

@takumin

@takumin takumin commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

The Coverage job on master has been failing since #7138 was merged. Every test in it passes; the job dies in the report step.

#7138 added a build on the default gembox to ci/gcc-clang, so for the first time the coverage run holds gcov data from a build without MRB_UTF8_STRING next to data from three that take full-core. A source file that defines a function twice, once under #ifdef MRB_UTF8_STRING and once under #else, then reaches gcovr as two functions of the same name on different lines of one file, and gcovr's default strict function merge mode treats that as an error:

gcovr.exceptions.GcovrMergeAssertionError: mrbgems/mruby-string-ext/src/string.c:1026 Got function str_ord on multiple lines: 1026, 1222.
        You can run gcovr with --merge-mode-functions=MERGE_MODE.

gcovr exits 64 and the job fails. str_ord is just where it stops first: str_codepoints, str_scrub_core and mrb_str_char_len are the same shape, so fixing one name at a time would not get the job green.

This passes --merge-mode-functions=separate. The two definitions are distinct function bodies and no single build ever holds both, so counting them as two functions is what the source says; the merging modes would instead fold them onto one line number, which describes neither build.

I reproduced the failure and the fix outside mruby with gcovr 8.6, on the smallest program of this shape: one static function defined twice under #ifdef and #else, compiled --coverage into two directories with the macro on and off. gcovr's default mode raises the same GcovrMergeAssertionError and exits 64; with --merge-mode-functions=separate the report is generated and counts both bodies.

This follows 01e1e2b, which reached for a gcovr flag the same way when the Prism sources made gcov fail to resolve paths.

Summary by CodeRabbit

  • Chores
    • Updated coverage reporting to separately merge function coverage data, improving the accuracy of coverage results.

`ci/gcc-clang` now has a build on the default gembox, which compiles
without `MRB_UTF8_STRING`, alongside the three that take `full-core`. A
source file that defines a function twice under `#ifdef MRB_UTF8_STRING`
and `#else` therefore reaches gcovr as two functions of the same name on
different lines of the same file, and its default `strict` function
merge mode rejects that:

    mrbgems/mruby-string-ext/src/string.c:1026 Got function str_ord on
    multiple lines: 1026, 1222.

The report step then exits 64 and the job fails, though every test in it
passed. `str_ord` is only where gcovr stops first; `str_codepoints`,
`str_scrub_core` and `mrb_str_char_len` collide the same way.

Pass --merge-mode-functions=separate. The two definitions are distinct
function bodies that no single build ever holds at once, so counting
them as separate functions is what the source says; merging them into
one line number would not be.
@takumin
takumin requested a review from matz as a code owner August 14, 2026 02:46
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 89c4cc1f-97f5-4092-8fb5-17a687f37811

📥 Commits

Reviewing files that changed from the base of the PR and between 9ff0255 and 020a78a.

📒 Files selected for processing (1)
  • .github/workflows/coverage.yml

📝 Walkthrough

Walkthrough

The coverage workflow now passes --merge-mode-functions=separate to gcovr when it generates the coverage report.

Changes

Coverage Configuration

Layer / File(s) Summary
Configure separate function merging
.github/workflows/coverage.yml
The gcovr coverage command now uses separate function merge mode.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 020a7

This is a localized CI configuration change that separates same-named coverage functions across builds and restores report generation; no actionable merge-blocking risk remains after normal checks and review.

Suggested labels: build

Suggested reviewers: matz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the coverage configuration change that keeps same-named functions from different builds separate.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@matz
matz merged commit f10d65b into mruby:master Aug 14, 2026
20 of 21 checks passed
@takumin
takumin deleted the coverage-merge-mode-functions branch August 14, 2026 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants