twister: extend searching src directory
Extend scope of searching src directory with defined test source code. In some cases for optimization reason src direcotry is placed in parent directory (in relation to testcase.yaml file placement). This changes allow to detect such situations. Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
This commit is contained in:
parent
340da2ecf3
commit
e2d903fe31
1 changed files with 17 additions and 1 deletions
|
@ -1928,7 +1928,8 @@ Tests should reference the category and subsystem with a dot as a separator.
|
|||
has_test_main = False
|
||||
ztest_suite_names = []
|
||||
|
||||
for filename in glob.glob(os.path.join(path, "src", "*.c*")):
|
||||
src_dir_path = self._find_src_dir_path(path)
|
||||
for filename in glob.glob(os.path.join(src_dir_path, "*.c*")):
|
||||
try:
|
||||
result: ScanPathResult = self.scan_file(filename)
|
||||
if result.warnings:
|
||||
|
@ -1982,6 +1983,21 @@ Tests should reference the category and subsystem with a dot as a separator.
|
|||
|
||||
self.ztest_suite_names = ztest_suite_names
|
||||
|
||||
@staticmethod
|
||||
def _find_src_dir_path(test_dir_path):
|
||||
"""
|
||||
Try to find src directory with test source code. Sometimes due to the
|
||||
optimization reasons it is placed in upper directory.
|
||||
"""
|
||||
src_dir_name = "src"
|
||||
src_dir_path = os.path.join(test_dir_path, src_dir_name)
|
||||
if os.path.isdir(src_dir_path):
|
||||
return src_dir_path
|
||||
src_dir_path = os.path.join(test_dir_path, "..", src_dir_name)
|
||||
if os.path.isdir(src_dir_path):
|
||||
return src_dir_path
|
||||
return ""
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue