1717sys .path .insert (0 , os .path .join (ZEPHYR_BASE , "scripts/pylib/twister" ))
1818
1919from 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
2121from twisterlib .testinstance import TestInstance
2222from twisterlib .testsuite import TestSuite
2323from twisterlib .platform import Platform
@@ -60,7 +60,7 @@ def test_add_configurations_short(test_data, class_env, board_root_dir):
6060 """
6161 class_env .board_roots = [os .path .abspath (test_data + board_root_dir )]
6262 plan = TestPlan (class_env )
63- plan .parse_configuration ( config_file = class_env .test_config )
63+ plan .test_config = TestConfiguration ( class_env .test_config )
6464 if board_root_dir == "board_config" :
6565 plan .add_configurations ()
6666 print (sorted (plan .default_platforms ))
@@ -69,6 +69,7 @@ def test_add_configurations_short(test_data, class_env, board_root_dir):
6969 plan .add_configurations ()
7070 assert sorted (plan .default_platforms ) != sorted (['demo_board_1' ])
7171
72+ plan .levels = plan .test_config .get_levels (plan .scenarios )
7273
7374def test_get_all_testsuites_short (class_testplan , all_testsuites_dict ):
7475 """ 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)
470471 tmp_config_file .write_text (config_yaml )
471472
472473 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 ])
479480
480481
481482TESTDATA_2 = [
@@ -535,7 +536,6 @@ def test_testplan_find_subtests(
535536 (0 , 0 , [], False , [], TwisterRuntimeError , []),
536537 (1 , 1 , [], False , [], TwisterRuntimeError , []),
537538 (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']),
539539 (1 , 0 , ['qfile.yaml' ], False , ['- platforms:\n - demo_board_3\n comment: "board_3"' ], None , []),
540540]
541541
@@ -557,15 +557,22 @@ def test_testplan_discover(
557557 exception ,
558558 expected_logs
559559):
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+
560565 for qf , data in zip (ql , ql_data ):
561566 tmp_qf = tmp_path / qf
562567 tmp_qf .write_text (data )
563568
564- testplan = TestPlan (env = mock .Mock ())
569+ env = mock .Mock ()
570+ env .test_config = tmp_tc
571+ testplan = TestPlan (env = env )
565572 testplan .options = mock .Mock (
566573 test = 'ts1' ,
567574 quarantine_list = [tmp_path / qf for qf in ql ],
568- quarantine_verify = qv ,
575+ quarantine_verify = qv
569576 )
570577 testplan .testsuites = {
571578 'ts1' : mock .Mock (id = 1 ),
@@ -576,7 +583,7 @@ def test_testplan_discover(
576583 testplan .add_testsuites = mock .Mock (return_value = added_testsuite_count )
577584 testplan .find_subtests = mock .Mock ()
578585 testplan .report_duplicates = mock .Mock ()
579- testplan .parse_configuration = mock .Mock ()
586+ testplan .test_config = mock .Mock ()
580587 testplan .add_configurations = mock .Mock ()
581588
582589 with pytest .raises (exception ) if exception else nullcontext ():
@@ -1113,13 +1120,9 @@ def test_testplan_add_configurations(
11131120 env = mock .Mock (board_roots = [tmp_path / 'boards' ], soc_roots = [tmp_path ], arch_roots = [tmp_path ])
11141121
11151122 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' ]
11231126
11241127 def mock_gen_plat (board_roots , soc_roots , arch_roots ):
11251128 assert [tmp_path ] == board_roots
0 commit comments