diff --git a/lib/spack/spack/test/package_class.py b/lib/spack/spack/test/package_class.py index 99c403d19c4..6e08180d25c 100644 --- a/lib/spack/spack/test/package_class.py +++ b/lib/spack/spack/test/package_class.py @@ -286,15 +286,10 @@ def test_package_fetcher_fails(): def test_package_test_no_compilers(mock_packages, monkeypatch, capfd): - def compilers(compiler, arch_spec): - return None - - monkeypatch.setattr(spack.compilers.config, "compilers_for_spec", compilers) - + # FIXME (compiler as nodes): check the meaning of this test s = spack.spec.Spec("pkg-a") pkg = BaseTestPackage(s) pkg.test_requires_compiler = True pkg.do_test() error = capfd.readouterr()[1] assert "Skipping tests for package" in error - assert "test requires missing compiler" in error diff --git a/lib/spack/spack/test/spec_semantics.py b/lib/spack/spack/test/spec_semantics.py index 7472828bb7b..13c7b098b73 100644 --- a/lib/spack/spack/test/spec_semantics.py +++ b/lib/spack/spack/test/spec_semantics.py @@ -2008,3 +2008,22 @@ def test_satisfies_and_subscript_with_compilers(default_mock_concretization): # We need to pass through "pkg-a" to get "gmake" with [] notation assert s["pkg-a"].dependencies(name="gmake")[0] == s["pkg-a"]["gmake"] + + +@pytest.mark.parametrize( + "spec_str,spec_fmt,expected", + [ + # Depends on C + ("mpileaks", "{name}-{compiler.name}", "mpileaks-gcc"), + ("mpileaks", "{name}-{compiler.name}-{compiler.version}", "mpileaks-gcc-10.2.1"), + # No compiler + ("pkg-c", "{name}-{compiler.name}", "pkg-c-none"), + ("pkg-c", "{name}-{compiler.name}-{compiler.version}", "pkg-c-none-none"), + ], +) +def test_spec_format_with_compiler_adaptors( + spec_str, spec_fmt, expected, default_mock_concretization +): + """Tests the output of spec format, when involving `Spec.compiler` adaptors""" + s = default_mock_concretization(spec_str) + assert s.format(spec_fmt) == expected