17
17
sys .path .insert (0 , os .path .join (ZEPHYR_BASE , "scripts/pylib/twister" ))
18
18
19
19
from twisterlib .statuses import TwisterStatus
20
- from twisterlib .testplan import TestPlan , change_skip_to_error_if_integration
20
+ from twisterlib .testplan import TestPlan , TestConfiguration , change_skip_to_error_if_integration
21
21
from twisterlib .testinstance import TestInstance
22
22
from twisterlib .testsuite import TestSuite
23
23
from twisterlib .platform import Platform
@@ -60,7 +60,7 @@ def test_add_configurations_short(test_data, class_env, board_root_dir):
60
60
"""
61
61
class_env .board_roots = [os .path .abspath (test_data + board_root_dir )]
62
62
plan = TestPlan (class_env )
63
- plan .parse_configuration ( config_file = class_env .test_config )
63
+ plan .test_config = TestConfiguration ( class_env .test_config )
64
64
if board_root_dir == "board_config" :
65
65
plan .add_configurations ()
66
66
print (sorted (plan .default_platforms ))
@@ -69,6 +69,7 @@ def test_add_configurations_short(test_data, class_env, board_root_dir):
69
69
plan .add_configurations ()
70
70
assert sorted (plan .default_platforms ) != sorted (['demo_board_1' ])
71
71
72
+ plan .levels = plan .test_config .get_levels (plan .scenarios )
72
73
73
74
def test_get_all_testsuites_short (class_testplan , all_testsuites_dict ):
74
75
""" Testing get_all_testsuites function of TestPlan class in Twister """
@@ -470,12 +471,12 @@ def test_testplan_parse_configuration(tmp_path, config_yaml, expected_scenarios)
470
471
tmp_config_file .write_text (config_yaml )
471
472
472
473
with pytest .raises (TwisterRuntimeError ) if not config_yaml else nullcontext ():
473
- testplan . parse_configuration (tmp_config_file )
474
-
475
- if not testplan .levels :
476
- assert expected_scenarios == {}
477
- for level in testplan .levels :
478
- assert sorted (level .scenarios ) == sorted (expected_scenarios [level .name ])
474
+ tc = TestConfiguration (tmp_config_file )
475
+ testplan . levels = tc . get_levels ( testplan . scenarios )
476
+ if not testplan .levels :
477
+ assert expected_scenarios == {}
478
+ for level in testplan .levels :
479
+ assert sorted (level .scenarios ) == sorted (expected_scenarios [level .name ])
479
480
480
481
481
482
TESTDATA_2 = [
@@ -535,7 +536,6 @@ def test_testplan_find_subtests(
535
536
(0 , 0 , [], False , [], TwisterRuntimeError , []),
536
537
(1 , 1 , [], False , [], TwisterRuntimeError , []),
537
538
(1 , 0 , [], True , [], TwisterRuntimeError , ['No quarantine list given to be verified' ]),
538
- # (1, 0, ['qfile.yaml'], False, ['# empty'], None, ['Quarantine file qfile.yaml is empty']),
539
539
(1 , 0 , ['qfile.yaml' ], False , ['- platforms:\n - demo_board_3\n comment: "board_3"' ], None , []),
540
540
]
541
541
@@ -557,15 +557,22 @@ def test_testplan_discover(
557
557
exception ,
558
558
expected_logs
559
559
):
560
+ # Just a dummy test configuration file
561
+ tc = "options: {}\n "
562
+ tmp_tc = tmp_path / 'test_config.yaml'
563
+ tmp_tc .write_text (tc )
564
+
560
565
for qf , data in zip (ql , ql_data ):
561
566
tmp_qf = tmp_path / qf
562
567
tmp_qf .write_text (data )
563
568
564
- testplan = TestPlan (env = mock .Mock ())
569
+ env = mock .Mock ()
570
+ env .test_config = tmp_tc
571
+ testplan = TestPlan (env = env )
565
572
testplan .options = mock .Mock (
566
573
test = 'ts1' ,
567
574
quarantine_list = [tmp_path / qf for qf in ql ],
568
- quarantine_verify = qv ,
575
+ quarantine_verify = qv
569
576
)
570
577
testplan .testsuites = {
571
578
'ts1' : mock .Mock (id = 1 ),
@@ -576,7 +583,7 @@ def test_testplan_discover(
576
583
testplan .add_testsuites = mock .Mock (return_value = added_testsuite_count )
577
584
testplan .find_subtests = mock .Mock ()
578
585
testplan .report_duplicates = mock .Mock ()
579
- testplan .parse_configuration = mock .Mock ()
586
+ testplan .test_config = mock .Mock ()
580
587
testplan .add_configurations = mock .Mock ()
581
588
582
589
with pytest .raises (exception ) if exception else nullcontext ():
@@ -1113,13 +1120,9 @@ def test_testplan_add_configurations(
1113
1120
env = mock .Mock (board_roots = [tmp_path / 'boards' ], soc_roots = [tmp_path ], arch_roots = [tmp_path ])
1114
1121
1115
1122
testplan = TestPlan (env = env )
1116
-
1117
- testplan .test_config = {
1118
- 'platforms' : {
1119
- 'override_default_platforms' : override_default_platforms ,
1120
- 'default_platforms' : ['p3' , 'p1e1' ]
1121
- }
1122
- }
1123
+ testplan .test_config = mock .Mock ()
1124
+ testplan .test_config .override_default_platforms = override_default_platforms
1125
+ testplan .test_config .default_platforms = ['p3' , 'p1e1' ]
1123
1126
1124
1127
def mock_gen_plat (board_roots , soc_roots , arch_roots ):
1125
1128
assert [tmp_path ] == board_roots
0 commit comments