scripts: twister: snippet roots from modules

Automatically populate the snippet roots from Zephyr modules, instead of
only looking in `ZEPHYR_BASE`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2023-11-10 15:04:03 +10:00 committed by Anas Nashif
parent 2b2e6bad36
commit 8f7e3b8123
2 changed files with 8 additions and 1 deletions

View file

@ -863,6 +863,13 @@ class TwisterEnv:
self.board_roots = None
self.outdir = None
self.snippet_roots = [Path(ZEPHYR_BASE)]
modules = zephyr_module.parse_modules(ZEPHYR_BASE)
for module in modules:
snippet_root = module.meta.get("build", {}).get("settings", {}).get("snippet_root")
if snippet_root:
self.snippet_roots.append(Path(module.project) / snippet_root)
self.hwm = None
self.test_config = options.test_config if options else None

View file

@ -806,7 +806,7 @@ class TestPlan:
if ts.required_snippets:
missing_snippet = False
snippet_args = {"snippets": ts.required_snippets}
found_snippets = snippets.find_snippets_in_roots(snippet_args, [Path(ZEPHYR_BASE), Path(ts.source_dir)])
found_snippets = snippets.find_snippets_in_roots(snippet_args, [*self.env.snippet_roots, Path(ts.source_dir)])
# Search and check that all required snippet files are found
for this_snippet in snippet_args['snippets']: