Skip to content

Commit 1385f02

Browse files
jeremybettiskartben
authored andcommitted
twister: Collect test names in lcov
When using --coverage-per-instance, collect the test names in lcov, and add --show-details to the html report to display those test names. Signed-off-by: Jeremy Bettis <[email protected]>
1 parent b544e0a commit 1385f02

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scripts/pylib/twister/twisterlib/coverage.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ def _generate(self, outdir, coveragelog, build_dirs=None):
297297
cmd.append(filename)
298298
else:
299299
cmd = ["--capture", "--directory", outdir, "--output-file", coveragefile]
300+
if self.coverage_per_instance and len(self.instances) == 1:
301+
invalid_chars = re.compile(r"[^A-Za-z0-9_]")
302+
cmd.append("--test-name")
303+
cmd.append(invalid_chars.sub("_", next(iter(self.instances))))
300304
self.run_lcov(cmd, coveragelog)
301305

302306
# We want to remove tests/* and tests/ztest/test/* but save tests/ztest
@@ -325,7 +329,10 @@ def _generate(self, outdir, coveragelog, build_dirs=None):
325329

326330
cmd = ["genhtml", "--legend", "--branch-coverage",
327331
"--prefix", self.base_dir,
328-
"-output-directory", os.path.join(outdir, "coverage")] + files
332+
"-output-directory", os.path.join(outdir, "coverage")]
333+
if self.coverage_per_instance:
334+
cmd.append("--show-details")
335+
cmd += files
329336
ret = self.run_command(cmd, coveragelog)
330337

331338
# TODO: Add LCOV summary coverage report.

0 commit comments

Comments
 (0)