diff options
author | Greg Becker <becker33@llnl.gov> | 2024-01-25 08:22:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-25 17:22:22 +0100 |
commit | d3c1f7a872a4097b74085b7275c338a1b52d96ae (patch) | |
tree | 732560707d6b520de0713328539e6649cef02396 /lib | |
parent | 84568b3454d88eb1630e83d87b98920eaddb27b9 (diff) | |
download | spack-d3c1f7a872a4097b74085b7275c338a1b52d96ae.tar.gz spack-d3c1f7a872a4097b74085b7275c338a1b52d96ae.tar.bz2 spack-d3c1f7a872a4097b74085b7275c338a1b52d96ae.tar.xz spack-d3c1f7a872a4097b74085b7275c338a1b52d96ae.zip |
Fix using sticky variants in externals (#42253)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/solver/asp.py | 13 | ||||
-rw-r--r-- | lib/spack/spack/test/concretize.py | 24 |
2 files changed, 29 insertions, 8 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 3661aa9b9b..151aef20a6 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -1768,15 +1768,12 @@ class SpackSolverSetup: for local_idx, spec in enumerate(external_specs): msg = "%s available as external when satisfying %s" % (spec.name, spec) - def external_imposition(input_spec, _): - return [fn.attr("external_conditions_hold", input_spec.name, local_idx)] + def external_imposition(input_spec, requirements): + return requirements + [ + fn.attr("external_conditions_hold", input_spec.name, local_idx) + ] - self.condition( - spec, - spack.spec.Spec(spec.name), - msg=msg, - transform_imposed=external_imposition, - ) + self.condition(spec, spec, msg=msg, transform_imposed=external_imposition) self.possible_versions[spec.name].add(spec.version) self.gen.newline() diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index 70743d8704..41b0eb600f 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -1522,6 +1522,30 @@ class TestConcretize: s = Spec("sticky-variant %clang").concretized() assert s.satisfies("%clang") and s.satisfies("~allow-gcc") + @pytest.mark.regression("42172") + @pytest.mark.only_clingo("Original concretizer cannot use sticky variants") + @pytest.mark.parametrize( + "spec,allow_gcc", + [ + ("sticky-variant@1.0+allow-gcc", True), + ("sticky-variant@1.0~allow-gcc", False), + ("sticky-variant@1.0", False), + ], + ) + def test_sticky_variant_in_external(self, spec, allow_gcc): + # setup external for sticky-variant+allow-gcc + config = {"externals": [{"spec": spec, "prefix": "/fake/path"}], "buildable": False} + spack.config.set("packages:sticky-variant", config) + + maybe = llnl.util.lang.nullcontext if allow_gcc else pytest.raises + with maybe(spack.error.SpackError): + s = Spec("sticky-variant-dependent%gcc").concretized() + + if allow_gcc: + assert s.satisfies("%gcc") + assert s["sticky-variant"].satisfies("+allow-gcc") + assert s["sticky-variant"].external + @pytest.mark.only_clingo("Use case not supported by the original concretizer") def test_do_not_invent_new_concrete_versions_unless_necessary(self): # ensure we select a known satisfying version rather than creating |