mirror of https://github.com/google/oss-fuzz.git
infra: base-runner: add filtering to python cov reports (#9698)
This is to avoid reporting coverage on files that are essentially not part of a given project, which butchers the summarised coverage stats at the moment. Signed-off-by: David Korczynski <david@adalogics.com> Signed-off-by: David Korczynski <david@adalogics.com>
This commit is contained in:
parent
d39c930d5b
commit
2f0f64b2b0
|
@ -25,6 +25,23 @@ from coverage.cmdline import main as coverage_main
|
|||
from coverage.data import CoverageData
|
||||
|
||||
|
||||
def should_exclude_file(filepath):
|
||||
"""Returns whether the path should be excluded from the coverage report."""
|
||||
# Skip all atheris code
|
||||
if "atheris" in filepath:
|
||||
return True
|
||||
|
||||
# Filter out all standard python libraries
|
||||
if '/usr/local/lib/python' in filepath and 'site-packages' not in filepath:
|
||||
return True
|
||||
|
||||
# Avoid all PyInstaller modules.
|
||||
if 'PyInstaller' in filepath:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def translate_lines(cov_data, new_cov_data, all_file_paths):
|
||||
"""
|
||||
Translate lines in a .coverage file created by coverage.py such that
|
||||
|
@ -40,6 +57,8 @@ def translate_lines(cov_data, new_cov_data, all_file_paths):
|
|||
|
||||
# Check if this file exists in our file paths:
|
||||
for local_file_path in all_file_paths:
|
||||
if should_exclude_file(local_file_path):
|
||||
continue
|
||||
if local_file_path.endswith(stripped_py_file_path):
|
||||
print('Found matching: %s' % (local_file_path))
|
||||
new_cov_data.add_lines(
|
||||
|
|
Loading…
Reference in New Issue