Fix spack find not able to display version ranges in compilers (#37715)

This commit is contained in:
Massimiliano Culpo 2023-05-17 06:24:38 +02:00
parent 14a703a4bb
commit 8cf4bf7559
2 changed files with 16 additions and 1 deletions

View File

@ -347,7 +347,7 @@ def iter_groups(specs, indent, all_headers):
spack.spec.architecture_color,
architecture if architecture else "no arch",
spack.spec.compiler_color,
f"{compiler.name}@{compiler.version}" if compiler else "no compiler",
f"{compiler}" if compiler else "no compiler",
)
# Sometimes we want to display specs that are not yet concretized.

View File

@ -357,3 +357,18 @@ def test_find_loaded(database, working_env):
output = find("--loaded")
expected = find()
assert output == expected
@pytest.mark.regression("37712")
def test_environment_with_version_range_in_compiler_doesnt_fail(tmp_path):
"""Tests that having an active environment with a root spec containing a compiler constrained
by a version range (i.e. @X.Y rather the single version than @=X.Y) doesn't result in an error
when invoking "spack find".
"""
test_environment = ev.create_in_dir(tmp_path)
test_environment.add("zlib %gcc@12.1.0")
test_environment.write()
with test_environment:
output = find()
assert "zlib%gcc@12.1.0" in output