Skip to content

Commit

Permalink
Rust: Fix rust coverage (#790)
Browse files Browse the repository at this point in the history
This PR fixes how rust coverage report is interpreted in build_runner

---------

Signed-off-by: Arthur Chan <[email protected]>
  • Loading branch information
arthurscchan authored Feb 14, 2025
1 parent 248a804 commit 435be08
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
11 changes: 10 additions & 1 deletion experiment/builder_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,8 @@ def _extract_local_textcoverage_data(self,
new_textcov = textcov.Textcov.from_jvm_file(f)
elif self.benchmark.language == 'python':
new_textcov = textcov.Textcov.from_python_file(f)
elif self.benchmark.language == 'rust':
new_textcov = textcov.Textcov.from_rust_file(f)
else:
target_basename = os.path.basename(self.benchmark.target_path)
new_textcov = textcov.Textcov.from_file(
Expand Down Expand Up @@ -1060,8 +1062,15 @@ def build_and_run_cloud(
run_result.coverage = textcov.Textcov.from_python_file(f)
self._copy_textcov_to_workdir(bucket, textcov_blob_path,
generated_target_name)
elif self.benchmark.language == 'rust':
blob = bucket.blob(textcov_blob_path)
if blob.exists():
with blob.open() as f:
run_result.coverage = textcov.Textcov.from_rust_file(f)
self._copy_textcov_to_workdir(bucket, textcov_blob_path,
generated_target_name)
else:
# C/C++/Rust
# C/C++
blob = bucket.blob(textcov_blob_path)
if blob.exists():
with blob.open('rb') as f:
Expand Down
10 changes: 6 additions & 4 deletions run_all_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,12 @@ def _process_total_coverage_gain() -> dict[str, dict[str, Any]]:
for textcov_file in os.listdir(summary):
if textcov_file.endswith('.covreport'):
with open(os.path.join(summary, textcov_file), 'rb') as f:

textcov_dict[project_name].append(
textcov.Textcov.from_file(
f, ignore_function_patterns=ignore_patterns))
if benchmark_used[0].language == 'rust':
textcov_dict[project_name].append(textcov.Textcov.from_file(f))
else:
textcov_dict[project_name].append(
textcov.Textcov.from_rust_file(
f, ignore_function_patterns=ignore_patterns))
elif textcov_file == 'all_cov.json':
with open(os.path.join(summary, textcov_file)) as f:
textcov_dict[project_name].append(
Expand Down

0 comments on commit 435be08

Please sign in to comment.