|
13 | 13 | find_bitcode_lib, |
14 | 14 | find_bitcode_lib_by_name, |
15 | 15 | locate_bitcode_lib, |
| 16 | + locate_bitcode_lib_by_name, |
16 | 17 | ) |
17 | 18 | from cuda.pathfinder._utils.env_vars import get_cuda_path_or_home |
18 | 19 |
|
@@ -141,7 +142,7 @@ def find_expected_sub_dir(sub_dir): |
141 | 142 |
|
142 | 143 | @pytest.mark.usefixtures("clear_find_bitcode_lib_cache") |
143 | 144 | @pytest.mark.agent_authored(model="gpt-5") |
144 | | -def test_find_bitcode_lib_by_name_search_order(monkeypatch, tmp_path): |
| 145 | +def test_bitcode_lib_by_name_search_order(monkeypatch, tmp_path): |
145 | 146 | libname = "device" |
146 | 147 | filename = "libdevice_sm_90.bc" |
147 | 148 | site_packages_lib_dir = _site_packages_bitcode_lib_dir_under(tmp_path / "site-packages", libname) |
@@ -172,14 +173,26 @@ def find_expected_sub_dir(sub_dir): |
172 | 173 | monkeypatch.setenv("CUDA_HOME", str(cuda_home)) |
173 | 174 | monkeypatch.delenv("CUDA_PATH", raising=False) |
174 | 175 |
|
| 176 | + located_lib = locate_bitcode_lib_by_name(libname, filename) |
| 177 | + assert located_lib.abs_path == site_packages_path |
| 178 | + assert located_lib.filename == filename |
| 179 | + assert located_lib.found_via == "site-packages" |
175 | 180 | assert find_bitcode_lib_by_name(libname, filename) == site_packages_path |
176 | 181 | os.remove(site_packages_path) |
177 | 182 | find_bitcode_lib_by_name.cache_clear() |
178 | 183 |
|
| 184 | + located_lib = locate_bitcode_lib_by_name(libname, filename) |
| 185 | + assert located_lib.abs_path == conda_path |
| 186 | + assert located_lib.filename == filename |
| 187 | + assert located_lib.found_via == "conda" |
179 | 188 | assert find_bitcode_lib_by_name(libname, filename) == conda_path |
180 | 189 | os.remove(conda_path) |
181 | 190 | find_bitcode_lib_by_name.cache_clear() |
182 | 191 |
|
| 192 | + located_lib = locate_bitcode_lib_by_name(libname, filename) |
| 193 | + assert located_lib.abs_path == cuda_home_path |
| 194 | + assert located_lib.filename == filename |
| 195 | + assert located_lib.found_via == "CUDA_PATH" |
183 | 196 | assert find_bitcode_lib_by_name(libname, filename) == cuda_home_path |
184 | 197 |
|
185 | 198 |
|
@@ -283,20 +296,23 @@ def test_find_bitcode_lib_invalid_name(): |
283 | 296 | "filename", |
284 | 297 | ("", ".", "..", "../file.bc", "subdir/file.bc", r"subdir\file.bc", r"C:\lib\file.bc", "bad\0name.bc"), |
285 | 298 | ) |
| 299 | +@pytest.mark.parametrize("lookup", (find_bitcode_lib_by_name, locate_bitcode_lib_by_name)) |
286 | 300 | @pytest.mark.agent_authored(model="gpt-5") |
287 | | -def test_find_bitcode_lib_by_name_rejects_paths(filename): |
| 301 | +def test_bitcode_lib_by_name_rejects_paths(lookup, filename): |
288 | 302 | with pytest.raises(ValueError, match="without a directory"): |
289 | | - find_bitcode_lib_by_name("device", filename) |
| 303 | + lookup("device", filename) |
290 | 304 |
|
291 | 305 |
|
292 | 306 | @pytest.mark.parametrize("filename", (None, 90)) |
| 307 | +@pytest.mark.parametrize("lookup", (find_bitcode_lib_by_name, locate_bitcode_lib_by_name)) |
293 | 308 | @pytest.mark.agent_authored(model="gpt-5") |
294 | | -def test_find_bitcode_lib_by_name_requires_string(filename): |
| 309 | +def test_bitcode_lib_by_name_requires_string(lookup, filename): |
295 | 310 | with pytest.raises(TypeError, match="filename must be a string"): |
296 | | - find_bitcode_lib_by_name("device", filename) |
| 311 | + lookup("device", filename) |
297 | 312 |
|
298 | 313 |
|
| 314 | +@pytest.mark.parametrize("lookup", (find_bitcode_lib_by_name, locate_bitcode_lib_by_name)) |
299 | 315 | @pytest.mark.agent_authored(model="gpt-5") |
300 | | -def test_find_bitcode_lib_by_name_invalid_project(): |
| 316 | +def test_bitcode_lib_by_name_invalid_project(lookup): |
301 | 317 | with pytest.raises(ValueError, match="Unknown bitcode library"): |
302 | | - find_bitcode_lib_by_name("not_a_real_lib", "libdevice_sm_90.bc") |
| 318 | + lookup("not_a_real_lib", "libdevice_sm_90.bc") |
0 commit comments