Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 26, 2025

The test coverage reports were showing misleading function coverage data where all individual files displayed 0.0% function coverage, even though functions were actually being executed during tests and the overall summary showed 90.5% function coverage.

Problem

The coverage scripts relied on lcov --list to display per-file coverage statistics, but this command has a known issue where it incorrectly shows 0.0% function coverage for individual files even when the underlying coverage data contains valid function execution information.

Before:

### Overall Coverage
- Lines: 76.9% (877/1141)  
- Functions: 90.5% (76/84)  ← Correct overall

### File Coverage
| File | Function Coverage |
|------|-------------------|
| src/jsrt.c | 0.0% |        ← Incorrect per-file
| src/console.c | 0.0% |     ← All showing 0%
| src/runtime.c | 0.0% |

This created confusion as the individual file percentages clearly didn't add up to the 90.5% overall coverage.

Root Cause

Investigation revealed that while lcov --list was showing 0.0% function coverage, the actual .info file contained correct function execution data:

  • FNF:28 (28 functions found) and FNH:27 (27 functions hit) for console.c
  • FNDA:420,jsrt_console_log showing actual function call counts
  • genhtml correctly processed this data and showed accurate function coverage

The issue was specifically with how lcov --list displays function coverage percentages in the per-file view.

Solution

Modified both coverage scripts to parse the .info file directly instead of relying on lcov --list:

  1. Direct parsing: Extract SF: (source file), FNH:/FNF: (functions hit/found) entries directly
  2. Accurate calculation: Compute function coverage as (functions_hit / functions_found) * 100
  3. Consistent methodology: Both badge and comment scripts now use identical parsing logic

Result

Function coverage now displays accurate, realistic values:

### Overall Coverage  
- Lines: 76.9% (877/1141)
- Functions: 90.5% (76/84)

### File Coverage
| File | Function Coverage |
|------|-------------------|
| src/jsrt.c | 100.0% |
| src/console.c | 96.4% |
| src/runtime.c | 73.3% |
| src/timer.c | 100.0% |

The per-file percentages now properly reflect the actual function execution and align with the overall coverage summary, eliminating user confusion about the coverage data accuracy.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] 修复测试覆盖率报告不准确问题。我看到的是这样的报告,整体覆盖率与文件覆盖率的数据明显对不上,请重新检查是不是算错了 ``` ## 📊 Test Coverage Report ### Overall Coverage - **Lines**: 76.9% - **F... Fix test coverage report inconsistency between overall and per-file percentages Aug 26, 2025
Copilot finished work on behalf of leizongmin August 26, 2025 08:31
Copilot AI requested a review from leizongmin August 26, 2025 08:31
@github-actions
Copy link

github-actions bot commented Aug 26, 2025

📊 Test Coverage Report

Overall Coverage

  • Lines: 76.9% (877/1141)
  • Functions: 90.5% (76/84)

File Coverage (src/ directory)

File Line Coverage Function Coverage
src/jsrt.c 67.9% 100.0%
src/runtime.c 62.6% 73.3%
src/std/base64.c 91.7% 100.0%
src/std/console.c 88.3% 96.4%
src/std/encoding.c 73.5% 100.0%
src/std/module.c 81.9% 100.0%
src/std/performance.c 89.5% 100.0%
src/std/timer.c 87.1% 100.0%
src/util/colorize.h 0.0% 0.0%
src/util/file.c 60.4% 75.0%
src/util/jsutils.c 0.0% 0.0%
src/util/path.c 100.0% 100.0%

Coverage report generated by jsrt CI

Copy link
Owner

@leizongmin leizongmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot-swe-agent 为什么 function coverage 的覆盖率全部是0?请修复

Copy link
Contributor Author

Copilot AI commented Aug 26, 2025

@copilot-swe-agent 为什么 function coverage 的覆盖率全部是0?请修复

Fixed! The issue was that lcov --list was incorrectly displaying 0.0% function coverage even though the underlying data showed functions were being executed. I updated both scripts to parse the .info file directly, and function coverage now shows the correct values: 90.5% overall (76/84 functions), with individual files showing realistic percentages like 100.0%, 96.4%, 73.3%, etc. Commit: 0f8ca31

Copilot AI changed the title Fix test coverage report inconsistency between overall and per-file percentages Fix function coverage reporting showing incorrect 0% values in test coverage reports Aug 26, 2025
Copilot finished work on behalf of leizongmin August 26, 2025 10:38
Copilot AI requested a review from leizongmin August 26, 2025 10:38
@leizongmin leizongmin marked this pull request as ready for review August 26, 2025 11:32
@leizongmin leizongmin merged commit 50411bb into main Aug 26, 2025
4 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.

2 participants