twister: Fix skipping unskippable tests when --subset is used

Fixes a bug causing tests with error status get silently skipped
when --subset is used.

Fixes: #39619

Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
This commit is contained in:
Maciej Perkowski 2021-10-21 14:05:54 +02:00 committed by Anas Nashif
commit 2253c6efd8
2 changed files with 11 additions and 2 deletions

View file

@ -3285,6 +3285,7 @@ class TestSuite(DisablePyTestCollectionMixin):
self.discards = discards
self.selected_platforms = set(p.platform.name for p in self.instances.values())
remove_from_discards = [] # configurations to be removed from discards.
for instance in self.discards:
instance.reason = self.discards[instance]
# If integration mode is on all skips on integration_platforms are treated as errors.
@ -3294,6 +3295,8 @@ class TestSuite(DisablePyTestCollectionMixin):
instance.reason += " but is one of the integration platforms"
instance.fill_results_by_status()
self.instances[instance.name] = instance
# Such configuration has to be removed from discards to make sure it won't get skipped
remove_from_discards.append(instance)
else:
instance.status = "skipped"
instance.fill_results_by_status()
@ -3301,6 +3304,10 @@ class TestSuite(DisablePyTestCollectionMixin):
self.filtered_platforms = set(p.platform.name for p in self.instances.values()
if p.status != "skipped" )
# Remove from discards configururations that must not be discarded (e.g. integration_platforms when --integration was used)
for instance in remove_from_discards:
del self.discards[instance]
return discards
def add_instances(self, instance_list):

View file

@ -1178,11 +1178,13 @@ def main():
sliced_instances = islice(to_run.items(), start, end)
skipped = {k : v for k,v in suite.instances.items() if v.status == 'skipped'}
errors = {k : v for k,v in suite.instances.items() if v.status == 'error'}
suite.instances = OrderedDict(sliced_instances)
if subset == 1:
# add all pre-filtered tests that are skipped to the first set to
# allow for better distribution among all sets.
# add all pre-filtered tests that are skipped or got error status
# to the first set to allow for better distribution among all sets.
suite.instances.update(skipped)
suite.instances.update(errors)
if options.save_tests:
suite.csv_report(options.save_tests)