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

fix: report line coverage instead of function coverage #171

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions integration_tests/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _get_current_coverage(coverage_config, no_cleanup, test_scope):
shutil.rmtree(cov_build_dir, ignore_errors=True)

llvm_cov_command = (
f"CARGO_TARGET_DIR={cov_build_dir} cargo llvm-cov test --summary-only"
f"CARGO_TARGET_DIR={cov_build_dir} cargo llvm-cov test --json --summary-only"
)

additional_exclude_path = coverage_config["exclude_path"]
Expand All @@ -97,13 +97,8 @@ def _get_current_coverage(coverage_config, no_cleanup, test_scope):
llvm_cov_command, shell=True, check=True, input=b"", stdout=subprocess.PIPE
)

summary = result.stdout.split(b"\n")[-2]
# Output of llvm-cov is like
# TOTAL 743 153 79.41% 185 50 72.97% 1531 125 91.84% 0 0 -
# where the first three numbers are related to region coverage, and next three to line coverage (what we want)
# and the last three to branch coverage (which is not yet supported). Below grabs the line coverage, and strips
# off the '%'.
coverage = float(summary.split()[6][:-1])
summary = json.loads(result.stdout)
coverage = summary["data"][0]["totals"]["lines"]["percent"]

shutil.rmtree(cov_build_dir, ignore_errors=True)

Expand Down
Loading