main
py 62 lines 2.31 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3 """Pytest configuration for GPT-OSS evaluation tests."""
4
5 from pathlib import Path
6
7
8 def pytest_addoption(parser):
9 """Add custom command line options."""
10 parser.addoption(
11 "--config-list-file",
12 required=True,
13 help="File containing list of config files to test",
14 )
15
16
17 def pytest_generate_tests(metafunc):
18 """Generate test parameters from config files."""
19 if "config_filename" in metafunc.fixturenames:
20 config_list_file = metafunc.config.getoption("--config-list-file")
21
22 # Handle both relative and absolute paths
23 config_list_path = Path(config_list_file)
24 if not config_list_path.is_absolute():
25 # If relative, try relative to test directory first
26 test_dir_path = Path(__file__).parent / config_list_file
27 if test_dir_path.exists():
28 config_list_path = test_dir_path
29 else:
30 # Try relative to current working directory
31 config_list_path = Path.cwd() / config_list_file
32
33 print(f"Looking for config list at: {config_list_path}")
34
35 config_files = []
36 if config_list_path.exists():
37 # Determine config directory (same directory as the list file)
38 config_dir = config_list_path.parent
39
40 with open(config_list_path) as f:
41 for line in f:
42 line = line.strip()
43 if line and not line.startswith("#"):
44 config_path = config_dir / line
45 print(f"Checking config file: {config_path}")
46 if config_path.exists():
47 config_files.append(config_path)
48 print(f" Found: {config_path}")
49 else:
50 print(f" Missing: {config_path}")
51 else:
52 print(f"Config list file not found: {config_list_path}")
53
54 # Generate test parameters
55 if config_files:
56 metafunc.parametrize(
57 "config_filename",
58 config_files,
59 ids=[config_file.stem for config_file in config_files],
60 )
61 else:
62 print("No config files found, test will be skipped")