Bugfix: find_libraries (#32653)
53a7b49 created a reference error which broke `.libs` (and
`find_libraries`) for many packages. This fixes the reference
error and improves the testing for `find_libraries` by actually
checking the extension types of libraries that are retrieved by
the function.
This commit is contained in:
@@ -72,7 +72,7 @@ def header_list():
|
||||
plat_shared_ext = "dll" if is_windows else "so"
|
||||
|
||||
|
||||
plat_apple_shared_ext = "dll" if is_windows else "dylib"
|
||||
plat_apple_shared_ext = "dylib"
|
||||
|
||||
|
||||
class TestLibraryList(object):
|
||||
@@ -86,7 +86,7 @@ def test_joined_and_str(self, library_list):
|
||||
expected = " ".join(
|
||||
[
|
||||
"/dir1/liblapack.%s" % plat_static_ext,
|
||||
"/dir2/libpython3.6.%s" % plat_apple_shared_ext,
|
||||
"/dir2/libpython3.6.%s" % (plat_apple_shared_ext if not is_windows else "dll"),
|
||||
"/dir1/libblas.%s" % plat_static_ext,
|
||||
"/dir3/libz.%s" % plat_shared_ext,
|
||||
"libmpi.%s.20.10.1" % plat_shared_ext,
|
||||
@@ -101,7 +101,7 @@ def test_joined_and_str(self, library_list):
|
||||
expected = ";".join(
|
||||
[
|
||||
"/dir1/liblapack.%s" % plat_static_ext,
|
||||
"/dir2/libpython3.6.%s" % plat_apple_shared_ext,
|
||||
"/dir2/libpython3.6.%s" % (plat_apple_shared_ext if not is_windows else "dll"),
|
||||
"/dir1/libblas.%s" % plat_static_ext,
|
||||
"/dir3/libz.%s" % plat_shared_ext,
|
||||
"libmpi.%s.20.10.1" % plat_shared_ext,
|
||||
@@ -254,6 +254,29 @@ def test_add(self, header_list):
|
||||
search_dir = os.path.join(spack.paths.test_path, "data", "directory_search")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"lib_list,kwargs",
|
||||
[
|
||||
(["liba"], {"shared": True, "recursive": True}),
|
||||
(["liba"], {"shared": False, "recursive": True}),
|
||||
(["libc", "liba"], {"shared": True, "recursive": True}),
|
||||
(["liba", "libc"], {"shared": False, "recursive": True}),
|
||||
(["libc", "libb", "liba"], {"shared": True, "recursive": True}),
|
||||
(["liba", "libb", "libc"], {"shared": False, "recursive": True}),
|
||||
],
|
||||
)
|
||||
def test_library_type_search(lib_list, kwargs):
|
||||
results = find_libraries(lib_list, search_dir, **kwargs)
|
||||
assert len(results) != 0
|
||||
for result in results:
|
||||
lib_type_ext = plat_shared_ext
|
||||
if not kwargs["shared"]:
|
||||
lib_type_ext = plat_static_ext
|
||||
assert result.endswith(lib_type_ext) or (
|
||||
kwargs["shared"] and result.endswith(plat_apple_shared_ext)
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"search_fn,search_list,root,kwargs",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user