twister: Allow deep folder scan

Upon discovery of a sample/testcase.yaml file, twister will disregard
further subfolders. Given the folder structure below, the testcase.yaml
will currently not be discovered:

samples/sample1/
samples/sample1/sample.yaml
samples/sample1/tests/
samples/sample1/tests/testcase.yaml

This is desirable to allow placing test code closer to sample code.

Signed-off-by: Jorgen Kvalvaag <jorgen.kvalvaag@nordicsemi.no>
This commit is contained in:
Jorgen Kvalvaag 2021-04-06 14:57:28 +02:00 committed by Carles Cufí
commit 36d96d2cd9

View file

@ -2893,7 +2893,7 @@ class TestSuite(DisablePyTestCollectionMixin):
logger.debug("Reading test case configuration files under %s..." % root) logger.debug("Reading test case configuration files under %s..." % root)
for dirpath, dirnames, filenames in os.walk(root, topdown=True): for dirpath, _, filenames in os.walk(root, topdown=True):
if self.SAMPLE_FILENAME in filenames: if self.SAMPLE_FILENAME in filenames:
filename = self.SAMPLE_FILENAME filename = self.SAMPLE_FILENAME
elif self.TESTCASE_FILENAME in filenames: elif self.TESTCASE_FILENAME in filenames:
@ -2903,7 +2903,6 @@ class TestSuite(DisablePyTestCollectionMixin):
logger.debug("Found possible test case in " + dirpath) logger.debug("Found possible test case in " + dirpath)
dirnames[:] = []
tc_path = os.path.join(dirpath, filename) tc_path = os.path.join(dirpath, filename)
try: try: