Skip to content

Measure line coverage per project in report #996

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions report/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ <h2>Accumulated results</h2>
<td>{{ accumulated_results.build_rate |percent }}%</td>
</tr>
<tr>
<td>Average coverage</td>
<td>Average line coverage per benchmark</td>
<td>{{ accumulated_results.average_coverage |percent }}%</td>
</tr>
<tr>
<td>Average line coverage diff</td>
<td>Average line coverage diff per benchmark</td>
<td>{{ accumulated_results.average_line_coverage_diff |percent }}%</td>
</tr>
<tr>
Expand Down
53 changes: 52 additions & 1 deletion run_all_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ def _process_total_coverage_gain() -> dict[str, dict[str, Any]]:
return {}

coverage_gain: dict[str, dict[str, Any]] = {}
sum_coverage_diff: float = 0.0
sum_coverage_relative_gain: float = 0.0
sum_coverage_ofg_total_covered_lines: int = 0
sum_coverage_ofg_total_new_covered_lines: int = 0
sum_coverage_existing_total_covered_lines: int = 0
sum_coverage_existing_total_lines: int = 0
for project, cov_list in textcov_dict.items():
total_cov = textcov.Textcov()
for cov in cov_list:
Expand Down Expand Up @@ -537,7 +543,52 @@ def _process_total_coverage_gain() -> dict[str, dict[str, Any]]:
# Fail safe when total_lines is 0 because of invalid coverage report
logger.warning(
'Line coverage information missing from the coverage report.')
coverage_gain[project] = {'coverage_diff': 0.0}
coverage_gain[project] = {
'language':
oss_fuzz_checkout.get_project_language(project),
'coverage_diff':
0.0,
'coverage_relative_gain':
cov_relative_gain,
'coverage_ofg_total_covered_lines':
total_cov_covered_lines_before_subtraction,
'coverage_ofg_total_new_covered_lines':
total_cov.covered_lines,
'coverage_existing_total_covered_lines':
existing_textcov.covered_lines,
'coverage_existing_total_lines':
total_existing_lines,
}
sum_coverage_diff += coverage_gain[project]['coverage_diff']
sum_coverage_relative_gain += (
coverage_gain[project]['coverage_relative_gain'])
sum_coverage_ofg_total_covered_lines += (
coverage_gain[project]['coverage_ofg_total_covered_lines'])
sum_coverage_ofg_total_new_covered_lines += (
coverage_gain[project]['coverage_ofg_total_new_covered_lines'])
sum_coverage_existing_total_covered_lines += (
coverage_gain[project]['coverage_existing_total_covered_lines'])
sum_coverage_existing_total_lines += (
coverage_gain[project]['coverage_existing_total_lines'])

# Project-level average data.
if len(coverage_gain):
coverage_gain['AVERAGE'] = {
'language':
'-',
'coverage_diff':
sum_coverage_diff / len(coverage_gain),
'coverage_relative_gain':
sum_coverage_relative_gain / len(coverage_gain),
'coverage_ofg_total_covered_lines':
sum_coverage_ofg_total_covered_lines / len(coverage_gain),
'coverage_ofg_total_new_covered_lines':
sum_coverage_ofg_total_new_covered_lines / len(coverage_gain),
'coverage_existing_total_covered_lines':
sum_coverage_existing_total_covered_lines / len(coverage_gain),
'coverage_existing_total_lines':
sum_coverage_existing_total_lines / len(coverage_gain),
}

return coverage_gain

Expand Down