11import argparse
22from pathlib import Path
3+ from typing import List , Dict
34
45import pytest
56from cloudai .__main__ import handle_dry_run_and_run
67
78SLURM_TEST_SCENARIOS = [
8- Path ("conf/v0.6/general/test_scenario/sleep.toml" ),
9- Path ("conf/v0.6/general/test_scenario/ucc_test.toml" ),
9+ {
10+ "path" : Path ("conf/v0.6/general/test_scenario/sleep.toml" ),
11+ "expected_dirs_number" : 3 ,
12+
13+ },
14+ {
15+ "path" : Path ("conf/v0.6/general/test_scenario/ucc_test.toml" ),
16+ "expected_dirs_number" : 1 ,
17+ }
1018]
1119
1220
13- @pytest .mark .parametrize ("test_scenario_path" , SLURM_TEST_SCENARIOS , ids = lambda x : str (x ))
14- def test_slurm (tmp_path : Path , test_scenario_path : Path ):
21+ @pytest .mark .parametrize ("scenario" , SLURM_TEST_SCENARIOS , ids = lambda x : str (x ))
22+ def test_slurm (tmp_path : Path , scenario : Dict ):
23+ test_scenario_path = scenario ["path" ]
24+ expected_dirs_number = scenario .get ("expected_dirs_number" )
25+
1526 args = argparse .Namespace (
1627 log_file = None ,
1728 log_level = None ,
@@ -24,7 +35,12 @@ def test_slurm(tmp_path: Path, test_scenario_path: Path):
2435 )
2536 handle_dry_run_and_run (args )
2637
27- test_dir = list (tmp_path .glob ("*" ))[0 ]
28- for td in test_dir .iterdir ():
38+ results_output = list (tmp_path .glob ("*" ))[0 ]
39+ test_dirs = list (results_output .iterdir ())
40+
41+ if expected_dirs_number is not None :
42+ assert len (test_dirs ) == expected_dirs_number , "Dirs number in output is not as expected"
43+
44+ for td in test_dirs :
2945 assert td .is_dir (), "Invalid test directory"
3046 assert "Tests." in td .name , "Invalid test directory name"
0 commit comments