Skip to content

Commit

Permalink
Moving gcov clean to cmake (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch authored Oct 24, 2023
1 parent 85e7fb0 commit 1c9d5dd
Showing 1 changed file with 1 addition and 31 deletions.
32 changes: 1 addition & 31 deletions src/fprime/fbuild/gcovr.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,6 @@ def _using_root(builder: "Build", context: Path, scope: TargetScope):
return builder.is_project_root(context) or scope == TargetScope.GLOBAL


class GcovClean(ExecutableAction):
"""Target used to scrub gcov files before a coverage run
The way fprime builds unittests means it is easy to see gcov coverage files leak into the coverage report from other
runs. This target finds all gcov created files (.gcda) and removes them before the build. This applies to the
entire build cache as report should be complete and isolated to any given run.
"""

REMOVAL_EXTENSIONS = [".gcda"]

def execute(
self,
builder: "Build",
context: Path,
args: Tuple[Dict[str, str], List[str], Dict[str, bool]],
):
"""Execute the clean using os.walk"""
print(f"[INFO] Scrubbing leftover { ', '.join(self.REMOVAL_EXTENSIONS)} files")
self._recurse(builder.build_dir)

@classmethod
def _recurse(cls, parent_path: Path):
"""Recursive helper"""
for path in parent_path.iterdir():
if path.is_file() and path.suffix in cls.REMOVAL_EXTENSIONS:
path.unlink()
elif path.is_dir():
cls._recurse(path)


class Gcovr(ExecutableAction):
"""Target invoking `gcovr` utility to calculate coverage
Expand Down Expand Up @@ -232,7 +202,7 @@ def __init__(self, check_target: Target, scope: TargetScope, *args, **kwargs):
TargetScope.BOTH,
], "Cannot create composite target from incompatible target"
super().__init__(
[GcovClean(scope), check_target, Gcovr(scope)],
[check_target, Gcovr(scope)],
scope=scope,
*args,
**kwargs,
Expand Down

0 comments on commit 1c9d5dd

Please sign in to comment.