Skip to content

Commit a294a9a

Browse files
LukaszMrugalaaescolar
authored andcommitted
scripts: twister: Name prefix loading
Sped up Twister via name prefix loading. If the only thing influencing the platform selection is the platform filter (-p), then we only load *.yaml files that start the same way as those selected platforms. We split the platform name to the first '/' or '@'. Signed-off-by: Lukasz Mrugala <lukaszx.mrugala@intel.com>
1 parent 698df11 commit a294a9a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

scripts/pylib/twister/twisterlib/testplan.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,18 @@ def add_configurations(self):
417417
platform_config = self.test_config.get('platforms', {})
418418
for folder in board_dirs:
419419
for file in glob.glob(os.path.join(folder, "*.yaml")):
420+
# If the user set a platform filter, we can, if no other option would increase
421+
# the allowed platform pool, save on time by not loading YAMLs of any boards
422+
# that do not start with the required names.
423+
if self.options.platform and \
424+
not self.options.all and \
425+
not self.options.integration and \
426+
not any([
427+
os.path.basename(file).startswith(
428+
re.split('[/@]', p)[0]
429+
) for p in self.options.platform
430+
]):
431+
continue
420432
try:
421433
platform = Platform()
422434
platform.load(file)
@@ -702,15 +714,17 @@ def apply_filters(self, **kwargs):
702714
if ts.build_on_all and not platform_filter and platform_config.get('increased_platform_scope', True):
703715
platform_scope = self.platforms
704716
elif ts.integration_platforms:
705-
self.verify_platforms_existence(
706-
ts.integration_platforms, f"{ts_name} - integration_platforms")
707717
integration_platforms = list(filter(lambda item: item.name in ts.integration_platforms,
708718
self.platforms))
709719
if self.options.integration:
720+
self.verify_platforms_existence(
721+
ts.integration_platforms, f"{ts_name} - integration_platforms")
710722
platform_scope = integration_platforms
711723
else:
712724
# if not in integration mode, still add integration platforms to the list
713725
if not platform_filter:
726+
self.verify_platforms_existence(
727+
ts.integration_platforms, f"{ts_name} - integration_platforms")
714728
platform_scope = platforms + integration_platforms
715729
else:
716730
platform_scope = platforms

0 commit comments

Comments
 (0)