main
py 61 lines 2.28 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 # Handle both relative and absolute paths
22 config_list_path = Path(config_list_file)
23 if not config_list_path.is_absolute():
24 # If relative, try relative to test directory first
25 test_dir_path = Path(__file__).parent / config_list_file
26 if test_dir_path.exists():
27 config_list_path = test_dir_path
28 else:
29 # Try relative to current working directory
30 config_list_path = Path.cwd() / config_list_file
31
32 print(f"Looking for config list at: {config_list_path}")
33
34 config_files = []
35 if config_list_path.exists():
36 # Determine config directory (same directory as the list file)
37 config_dir = config_list_path.parent
38
39 with open(config_list_path) as f:
40 for line in f:
41 line = line.strip()
42 if line and not line.startswith("#"):
43 config_path = config_dir / line
44 print(f"Checking config file: {config_path}")
45 if config_path.exists():
46 config_files.append(config_path)
47 print(f" ✓ Found: {config_path}")
48 else:
49 print(f" ✗ Missing: {config_path}")
50 else:
51 print(f"Config list file not found: {config_list_path}")
52
53 # Generate test parameters
54 if config_files:
55 metafunc.parametrize(
56 "config_filename",
57 config_files,
58 ids=[config_file.stem for config_file in config_files],
59 )
60 else:
61 print("No config files found, test will be skipped")