From ef792d1b9a22cba85c41cde4b6f6a1fe2ed106d0 Mon Sep 17 00:00:00 2001 From: Lukasz Mrugala Date: Mon, 22 Apr 2024 12:11:30 +0000 Subject: [PATCH] scripts: twister: Fix duplicate scans If the src_dir_path is a child of testsuite_path, some c files might be scanned twice. To prevent that, we check for parentage. Signed-off-by: Lukasz Mrugala --- scripts/pylib/twister/twisterlib/testsuite.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/pylib/twister/twisterlib/testsuite.py b/scripts/pylib/twister/twisterlib/testsuite.py index c3c9daed72b..2a132c3945f 100644 --- a/scripts/pylib/twister/twisterlib/testsuite.py +++ b/scripts/pylib/twister/twisterlib/testsuite.py @@ -310,7 +310,13 @@ def scan_testsuite_path(testsuite_path): except ValueError as e: logger.error("%s: error parsing source file: %s" % (filename, e)) + src_dir_pathlib_path = Path(src_dir_path) for filename in find_c_files_in(testsuite_path): + # If we have already scanned those files in the src_dir step, skip them. + filename_path = Path(filename) + if src_dir_pathlib_path in filename_path.parents: + continue + try: result: ScanPathResult = scan_file(filename) if result.warnings: