main
py 54 lines 1.94 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 from pathlib import Path
5
6
7 def pytest_addoption(parser):
8 """Add custom command line options."""
9 parser.addoption(
10 "--config-list-file",
11 default="configs/models-small.txt",
12 help="File containing list of config files to test",
13 )
14
15
16 def pytest_generate_tests(metafunc):
17 """Generate test parameters from config files."""
18 if "config_filename" in metafunc.fixturenames:
19 config_list_file = metafunc.config.getoption("--config-list-file")
20
21 config_list_path = Path(config_list_file)
22 if not config_list_path.is_absolute():
23 test_dir_path = Path(__file__).parent / config_list_file
24 if test_dir_path.exists():
25 config_list_path = test_dir_path
26 else:
27 config_list_path = Path.cwd() / config_list_file
28
29 print(f"Looking for config list at: {config_list_path}")
30
31 config_files = []
32 if config_list_path.exists():
33 config_dir = config_list_path.parent
34 with open(config_list_path) as f:
35 for line in f:
36 line = line.strip()
37 if line and not line.startswith("#"):
38 config_path = config_dir / line
39 if config_path.exists():
40 config_files.append(config_path)
41 print(f" ✓ Found: {config_path}")
42 else:
43 print(f" ✗ Missing: {config_path}")
44 else:
45 print(f"Config list file not found: {config_list_path}")
46
47 if config_files:
48 metafunc.parametrize(
49 "config_filename",
50 config_files,
51 ids=[config_file.stem for config_file in config_files],
52 )
53 else:
54 print("No config files found, test will be skipped")