Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: calculate incremental unittest coverage #1783

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

Abingcbc
Copy link
Collaborator

@Abingcbc Abingcbc commented Sep 25, 2024

背景

现在统计增量覆盖率,比较粗放。直接统计每个修改文件的单测覆盖率。这就导致修改老文件时,覆盖率一直失败。

修复

目前,没有已有的工具能够计算本次提交中代码的覆盖率。所以,写了一个python脚本,大概原理如下:

  1. git diff获取文件中+的代码行号
  2. gcovr 计算所有代码的覆盖情况,输出成json
  3. diff代码与gcovr结果求交集,得到有效代码,统计这些有效代码中的覆盖和没覆盖的条数
  4. 计算覆盖率

@Abingcbc Abingcbc merged commit f96049c into alibaba:main Sep 25, 2024
15 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