twister: testplan: Fix duplicate scenarios error reporting

Fix duplicate test scenario error reporting to show paths to all
twister.yaml configuration files where these duplicates were found.

Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
This commit is contained in:
Dmitrii Golovanov 2024-11-24 15:04:45 +01:00 committed by Benjamin Cabé
commit 89466f9d7e
2 changed files with 27 additions and 16 deletions

View file

@ -168,7 +168,7 @@ class TestPlan:
sub_tests = self.options.sub_test
if sub_tests:
for subtest in sub_tests:
_subtests = self.get_testsuite(subtest)
_subtests = self.get_testcase(subtest)
for _subtest in _subtests:
self.run_individual_testsuite.append(_subtest.name)
@ -1088,6 +1088,13 @@ class TestPlan:
def get_testsuite(self, identifier):
results = []
for _, ts in self.testsuites.items():
if ts.id == identifier:
results.append(ts)
return results
def get_testcase(self, identifier):
results = []
for _, ts in self.testsuites.items():
for case in ts.testcases:

View file

@ -1699,27 +1699,31 @@ def test_testplan_add_instances():
}
def test_testplan_get_testsuite():
def test_testplan_get_testcase():
testplan = TestPlan(env=mock.Mock())
testplan.testsuites = {
'testsuite0': mock.Mock(testcases=[mock.Mock(), mock.Mock()]),
'testsuite1': mock.Mock(testcases=[mock.Mock()]),
'testsuite2': mock.Mock(testcases=[mock.Mock(), mock.Mock()]),
'testsuite3': mock.Mock(testcases=[])
'test1.suite0': mock.Mock(testcases=[mock.Mock(), mock.Mock()]),
'test1.suite1': mock.Mock(testcases=[mock.Mock(), mock.Mock()]),
'test1.suite2': mock.Mock(testcases=[mock.Mock(), mock.Mock()]),
'test1.suite3': mock.Mock(testcases=[])
}
testplan.testsuites['testsuite0'].testcases[0].name = 'testcase name 0'
testplan.testsuites['testsuite0'].testcases[1].name = 'testcase name 1'
testplan.testsuites['testsuite1'].testcases[0].name = 'sample id'
testplan.testsuites['testsuite2'].testcases[0].name = 'dummy id'
testplan.testsuites['testsuite2'].testcases[1].name = 'sample id'
id = 'sample id'
testplan.testsuites['test1.suite0'].testcases[0].name = 'test1.suite0.case0'
testplan.testsuites['test1.suite0'].testcases[1].name = 'test1.suite0.case1'
#
testplan.testsuites['test1.suite1'].testcases[0].name = 'test1.suite1.case0'
testplan.testsuites['test1.suite1'].testcases[1].name = 'test1.suite1.case0' # in suite duplicate
#
testplan.testsuites['test1.suite2'].testcases[0].name = 'test1.suite2.case0'
testplan.testsuites['test1.suite2'].testcases[1].name = 'test1.suite1.case0' # out suite duplicate
res = testplan.get_testsuite(id)
id = 'test1.suite1.case0'
assert len(res) == 2
assert testplan.testsuites['testsuite1'] in res
assert testplan.testsuites['testsuite2'] in res
res = testplan.get_testcase(id)
assert len(res) == 3
assert testplan.testsuites['test1.suite1'] in res
assert testplan.testsuites['test1.suite2'] in res
def test_testplan_verify_platforms_existence(caplog):