test/compilers/conversion.py: use mock packages (#50391)
This commit is contained in:
parent
3891305005
commit
f1ba23316b
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
from spack.compilers.config import CompilerFactory
|
from spack.compilers.config import CompilerFactory
|
||||||
|
|
||||||
|
pytestmark = [pytest.mark.usefixtures("config", "mock_packages")]
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def mock_compiler(mock_executable):
|
def mock_compiler(mock_executable):
|
||||||
@ -55,7 +57,7 @@ def test_compiler_conversion_with_flags(mock_compiler):
|
|||||||
assert compiler_spec.extra_attributes["flags"]["cxxflags"] == "-O2 -g"
|
assert compiler_spec.extra_attributes["flags"]["cxxflags"] == "-O2 -g"
|
||||||
|
|
||||||
|
|
||||||
def tests_compiler_conversion_with_environment(mock_compiler):
|
def test_compiler_conversion_with_environment(mock_compiler):
|
||||||
"""Tests that custom environment modifications are converted appropriately
|
"""Tests that custom environment modifications are converted appropriately
|
||||||
for external compilers
|
for external compilers
|
||||||
"""
|
"""
|
||||||
@ -67,7 +69,7 @@ def tests_compiler_conversion_with_environment(mock_compiler):
|
|||||||
assert compiler_spec.extra_attributes["environment"] == mods
|
assert compiler_spec.extra_attributes["environment"] == mods
|
||||||
|
|
||||||
|
|
||||||
def tests_compiler_conversion_extra_rpaths(mock_compiler):
|
def test_compiler_conversion_extra_rpaths(mock_compiler):
|
||||||
"""Tests that extra rpaths are converted appropriately for external compilers"""
|
"""Tests that extra rpaths are converted appropriately for external compilers"""
|
||||||
mock_compiler["extra_rpaths"] = ["/foo/bar"]
|
mock_compiler["extra_rpaths"] = ["/foo/bar"]
|
||||||
compiler_spec = CompilerFactory.from_legacy_yaml(mock_compiler)[0]
|
compiler_spec = CompilerFactory.from_legacy_yaml(mock_compiler)[0]
|
||||||
@ -76,7 +78,7 @@ def tests_compiler_conversion_extra_rpaths(mock_compiler):
|
|||||||
assert compiler_spec.extra_attributes["extra_rpaths"] == ["/foo/bar"]
|
assert compiler_spec.extra_attributes["extra_rpaths"] == ["/foo/bar"]
|
||||||
|
|
||||||
|
|
||||||
def tests_compiler_conversion_modules(mock_compiler):
|
def test_compiler_conversion_modules(mock_compiler):
|
||||||
"""Tests that modules are converted appropriately for external compilers"""
|
"""Tests that modules are converted appropriately for external compilers"""
|
||||||
modules = ["foo/4.1.2", "bar/5.1.4"]
|
modules = ["foo/4.1.2", "bar/5.1.4"]
|
||||||
mock_compiler["modules"] = modules
|
mock_compiler["modules"] = modules
|
||||||
@ -86,7 +88,7 @@ def tests_compiler_conversion_modules(mock_compiler):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.regression("49717")
|
@pytest.mark.regression("49717")
|
||||||
def tests_compiler_conversion_corrupted_paths(mock_compiler):
|
def test_compiler_conversion_corrupted_paths(mock_compiler):
|
||||||
"""Tests that compiler entries with corrupted path do not raise"""
|
"""Tests that compiler entries with corrupted path do not raise"""
|
||||||
mock_compiler["paths"] = {"cc": "gcc", "cxx": "g++", "fc": "gfortran", "f77": "gfortran"}
|
mock_compiler["paths"] = {"cc": "gcc", "cxx": "g++", "fc": "gfortran", "f77": "gfortran"}
|
||||||
# Test this call doesn't raise
|
# Test this call doesn't raise
|
||||||
|
@ -31,6 +31,7 @@ class Gcc(CompilerPackage, Package):
|
|||||||
provides("fortran", when="languages=fortran")
|
provides("fortran", when="languages=fortran")
|
||||||
|
|
||||||
depends_on("c", type="build")
|
depends_on("c", type="build")
|
||||||
|
depends_on("cxx", type="build")
|
||||||
|
|
||||||
c_names = ["gcc"]
|
c_names = ["gcc"]
|
||||||
cxx_names = ["g++"]
|
cxx_names = ["g++"]
|
||||||
@ -48,6 +49,19 @@ class Gcc(CompilerPackage, Package):
|
|||||||
"fortran": os.path.join("gcc", "gfortran"),
|
"fortran": os.path.join("gcc", "gfortran"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
implicit_rpath_libs = ["libgcc", "libgfortran"]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def determine_variants(cls, exes, version_str):
|
||||||
|
compilers = cls.determine_compiler_paths(exes=exes)
|
||||||
|
|
||||||
|
languages = set()
|
||||||
|
translation = {"cxx": "c++"}
|
||||||
|
for lang, compiler in compilers.items():
|
||||||
|
languages.add(translation.get(lang, lang))
|
||||||
|
variant_str = "languages={0}".format(",".join(languages))
|
||||||
|
return variant_str, {"compilers": compilers}
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
# Create the minimal compiler that will fool `spack compiler find`
|
# Create the minimal compiler that will fool `spack compiler find`
|
||||||
mkdirp(prefix.bin)
|
mkdirp(prefix.bin)
|
||||||
|
Loading…
Reference in New Issue
Block a user