diff --git a/lib/spack/spack/test/spec_yaml.py b/lib/spack/spack/test/spec_yaml.py index 3652d960673..72983681c06 100644 --- a/lib/spack/spack/test/spec_yaml.py +++ b/lib/spack/spack/test/spec_yaml.py @@ -420,13 +420,15 @@ def test_load_json_specfiles(specfile, expected_hash, reader_cls): openmpi_edges = s2.edges_to_dependencies(name="openmpi") assert len(openmpi_edges) == 1 - # Check that virtuals have been reconstructed - assert "mpi" in openmpi_edges[0].virtuals + # Check that virtuals have been reconstructed for specfiles conforming to + # version 4 on. + if reader_cls.SPEC_VERSION >= spack.spec.SpecfileV4.SPEC_VERSION: + assert "mpi" in openmpi_edges[0].virtuals - # The virtuals attribute must be a tuple, when read from a - # JSON or YAML file, not a list - for edge in s2.traverse_edges(): - assert isinstance(edge.virtuals, tuple), edge + # The virtuals attribute must be a tuple, when read from a + # JSON or YAML file, not a list + for edge in s2.traverse_edges(): + assert isinstance(edge.virtuals, tuple), edge # Ensure we can format {compiler} tokens assert s2.format("{compiler}") != "none"