Skip to content

Commit 53bd9ea

Browse files
JordanYatesnashif
authored andcommitted
scripts: twisterlib: coverage: fix multiple branch excludes
Multiple values for `--exclude-branches-by-pattern` will result in only the last value taking effect. Resolve this by merging all the provided regex patterns into a single pattern with the `|` operator. Signed-off-by: Jordan Yates <[email protected]>
1 parent 6ade0cf commit 53bd9ea

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scripts/pylib/twister/twisterlib/coverage.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ def _generate(self, outdir, coveragelog):
330330
ztestfile = os.path.join(outdir, "ztest.json")
331331

332332
excludes = Gcovr._interleave_list("-e", self.ignores)
333-
excludes += Gcovr._interleave_list("--exclude-branches-by-pattern", self.ignore_branch_patterns)
333+
if len(self.ignore_branch_patterns) > 0:
334+
# Last pattern overrides previous values, so merge all patterns together
335+
merged_regex = "|".join([f"({p})" for p in self.ignore_branch_patterns])
336+
excludes += ["--exclude-branches-by-pattern", merged_regex]
334337

335338
# Different ifdef-ed implementations of the same function should not be
336339
# in conflict treated by GCOVR as separate objects for coverage statistics.

0 commit comments

Comments
 (0)