Skip to content

Commit 74e4d26

Browse files
committed
scripts: Add workflow for "common" directories in find_tests()
Some tests use a "common" directory to store pieces of code which are reused by different scenarios. In those cases, no test yaml is found within such director nor within its parents. If no test yaml is found in a directory, and the directory is called common, also look in collocated directories if they have test yamls. If so, add all those locations to the scope. E.g. tests/bluetooth/controller/common Signed-off-by: Maciej Perkowski <[email protected]>
1 parent ea2cdd2 commit 74e4d26

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

scripts/ci/test_plan.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import json
1313
import logging
1414
import sys
15+
import glob
1516
from pathlib import Path
1617
from git import Repo
1718
from west.manifest import Manifest
@@ -256,13 +257,25 @@ def find_tests(self):
256257
if f.endswith(".rst"):
257258
continue
258259
d = os.path.dirname(f)
259-
while d:
260+
scope_found = False
261+
while not scope_found and d:
262+
head, tail = os.path.split(d)
260263
if os.path.exists(os.path.join(d, "testcase.yaml")) or \
261264
os.path.exists(os.path.join(d, "sample.yaml")):
262265
tests.add(d)
263266
# Modified file is treated as resolved, since a matching scope was found
264267
self.resolved_files.append(f)
265-
break
268+
scope_found = True
269+
elif tail == "common":
270+
# Look for yamls in directories collocated with common
271+
272+
yamls_found = [yaml for yaml in glob.iglob(head + '/**/testcase.yaml', recursive=True)]
273+
yamls_found.extend([yaml for yaml in glob.iglob(head + '/**/sample.yaml', recursive=True)])
274+
if yamls_found:
275+
for yaml in yamls_found:
276+
tests.add(os.path.dirname(yaml))
277+
self.resolved_files.append(f)
278+
scope_found = True
266279
else:
267280
d = os.path.dirname(d)
268281

0 commit comments

Comments
 (0)