Compare commits

...

4 Commits

Author SHA1 Message Date
Peter Scheibel
c899dcac5b style fix 2024-05-23 22:25:25 -07:00
Peter Scheibel
94dc25ecfa add test 2024-05-23 17:14:00 -07:00
Peter Scheibel
aded859856 Merge branch 'develop' into bugfix/invalid-compiler-warning 2024-05-23 16:30:54 -07:00
Gregory Becker
2e3fc288ae warn and continue on failure to parse compiler from external 2024-04-18 08:46:05 -07:00
2 changed files with 32 additions and 1 deletions

View File

@@ -156,7 +156,15 @@ def get_compiler_config_from_packages(
def _compiler_config_from_package_config(config):
compilers = []
for entry in config:
compiler = _compiler_config_from_external(entry)
try:
compiler = _compiler_config_from_external(entry)
except Exception as e:
msg = "Reading compiler from packages config section failed\n"
msg += f" Compiler: {entry.get('spec', None)}\n"
msg += f" Prefix: {entry.get('prefix', None)}\n"
msg += f" Failure: {e}"
warnings.warn(msg)
compiler = None
if compiler:
compilers.append(compiler)

View File

@@ -1492,3 +1492,26 @@ def test_config_path_dsl(path, it_should_work, expected_parsed):
else:
with pytest.raises(ValueError):
spack.config.ConfigPath._validate(path)
def test_compiler_parsing_errors(tmpdir):
content = """\
packages:
gcc:
externals:
- spec: gcc@8.5.0 languages='c,c++,fortran'
prefix: /usr
extra_attributes:
compilers:
c: /usr/bin/gcc
cxx: /usr/bin/g++
fortran: /usr/bin/gfortran
"""
testscope = join_path(tmpdir.strpath, "packages.yaml")
with open(testscope, "w") as f:
f.write(content)
with spack.config.use_configuration(tmpdir.strpath):
compilers = spack.compilers.get_compiler_config_from_packages(spack.config.CONFIG)
assert spack.spec.Spec(compilers[0]["compiler"]["spec"]).satisfies("gcc@8.5.0")