Fix an issue with deconcretization/reconcretization of environments (#41294)
This commit is contained in:
parent
df2a3bd531
commit
f39a1e5fc8
2 changed files with 34 additions and 7 deletions
|
@ -2675,15 +2675,13 @@ def literal_specs(self, specs):
|
||||||
self.gen.fact(fn.pkg_fact(spec.name, fn.condition_trigger(condition_id, trigger_id)))
|
self.gen.fact(fn.pkg_fact(spec.name, fn.condition_trigger(condition_id, trigger_id)))
|
||||||
self.gen.fact(fn.condition_reason(condition_id, f"{spec} requested explicitly"))
|
self.gen.fact(fn.condition_reason(condition_id, f"{spec} requested explicitly"))
|
||||||
|
|
||||||
# Effect imposes the spec
|
|
||||||
imposed_spec_key = str(spec), None
|
imposed_spec_key = str(spec), None
|
||||||
cache = self._effect_cache[spec.name]
|
cache = self._effect_cache[spec.name]
|
||||||
msg = (
|
if imposed_spec_key in cache:
|
||||||
"literal specs have different requirements. clear cache before computing literals"
|
effect_id, requirements = cache[imposed_spec_key]
|
||||||
)
|
else:
|
||||||
assert imposed_spec_key not in cache, msg
|
effect_id = next(self._id_counter)
|
||||||
effect_id = next(self._id_counter)
|
requirements = self.spec_clauses(spec)
|
||||||
requirements = self.spec_clauses(spec)
|
|
||||||
root_name = spec.name
|
root_name = spec.name
|
||||||
for clause in requirements:
|
for clause in requirements:
|
||||||
clause_name = clause.args[0]
|
clause_name = clause.args[0]
|
||||||
|
|
|
@ -778,3 +778,32 @@ def test_env_with_include_def_missing(mutable_mock_env_path, mock_packages):
|
||||||
with e:
|
with e:
|
||||||
with pytest.raises(UndefinedReferenceError, match=r"which does not appear"):
|
with pytest.raises(UndefinedReferenceError, match=r"which does not appear"):
|
||||||
e.concretize()
|
e.concretize()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.regression("41292")
|
||||||
|
def test_deconcretize_then_concretize_does_not_error(mutable_mock_env_path, mock_packages):
|
||||||
|
"""Tests that, after having deconcretized a spec, we can reconcretize an environment which
|
||||||
|
has 2 or more user specs mapping to the same concrete spec.
|
||||||
|
"""
|
||||||
|
mutable_mock_env_path.mkdir()
|
||||||
|
spack_yaml = mutable_mock_env_path / ev.manifest_name
|
||||||
|
spack_yaml.write_text(
|
||||||
|
"""spack:
|
||||||
|
specs:
|
||||||
|
# These two specs concretize to the same hash
|
||||||
|
- c
|
||||||
|
- c@1.0
|
||||||
|
# Spec used to trigger the bug
|
||||||
|
- a
|
||||||
|
concretizer:
|
||||||
|
unify: true
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
e = ev.Environment(mutable_mock_env_path)
|
||||||
|
with e:
|
||||||
|
e.concretize()
|
||||||
|
e.deconcretize(spack.spec.Spec("a"), concrete=False)
|
||||||
|
e.concretize()
|
||||||
|
assert len(e.concrete_roots()) == 3
|
||||||
|
all_root_hashes = set(x.dag_hash() for x in e.concrete_roots())
|
||||||
|
assert len(all_root_hashes) == 2
|
||||||
|
|
Loading…
Reference in a new issue