bugfix: env concretize after remove (#37877)
This commit is contained in:
parent
8096ed4b22
commit
033599c4cd
@ -1351,6 +1351,10 @@ def concretize(self, force=False, tests=False):
|
|||||||
self.concretized_order = []
|
self.concretized_order = []
|
||||||
self.specs_by_hash = {}
|
self.specs_by_hash = {}
|
||||||
|
|
||||||
|
# Remove concrete specs that no longer correlate to a user spec
|
||||||
|
for spec in set(self.concretized_user_specs) - set(self.user_specs):
|
||||||
|
self.deconcretize(spec)
|
||||||
|
|
||||||
# Pick the right concretization strategy
|
# Pick the right concretization strategy
|
||||||
if self.unify == "when_possible":
|
if self.unify == "when_possible":
|
||||||
return self._concretize_together_where_possible(tests=tests)
|
return self._concretize_together_where_possible(tests=tests)
|
||||||
@ -1364,6 +1368,16 @@ def concretize(self, force=False, tests=False):
|
|||||||
msg = "concretization strategy not implemented [{0}]"
|
msg = "concretization strategy not implemented [{0}]"
|
||||||
raise SpackEnvironmentError(msg.format(self.unify))
|
raise SpackEnvironmentError(msg.format(self.unify))
|
||||||
|
|
||||||
|
def deconcretize(self, spec):
|
||||||
|
# spec has to be a root of the environment
|
||||||
|
index = self.concretized_user_specs.index(spec)
|
||||||
|
dag_hash = self.concretized_order.pop(index)
|
||||||
|
del self.concretized_user_specs[index]
|
||||||
|
|
||||||
|
# If this was the only user spec that concretized to this concrete spec, remove it
|
||||||
|
if dag_hash not in self.concretized_order:
|
||||||
|
del self.specs_by_hash[dag_hash]
|
||||||
|
|
||||||
def _get_specs_to_concretize(
|
def _get_specs_to_concretize(
|
||||||
self,
|
self,
|
||||||
) -> Tuple[Set[spack.spec.Spec], Set[spack.spec.Spec], List[spack.spec.Spec]]:
|
) -> Tuple[Set[spack.spec.Spec], Set[spack.spec.Spec], List[spack.spec.Spec]]:
|
||||||
|
@ -390,6 +390,19 @@ def test_remove_after_concretize():
|
|||||||
assert not any(s.name == "mpileaks" for s in env_specs)
|
assert not any(s.name == "mpileaks" for s in env_specs)
|
||||||
|
|
||||||
|
|
||||||
|
def test_remove_before_concretize():
|
||||||
|
e = ev.create("test")
|
||||||
|
e.unify = True
|
||||||
|
|
||||||
|
e.add("mpileaks")
|
||||||
|
e.concretize()
|
||||||
|
|
||||||
|
e.remove("mpileaks")
|
||||||
|
e.concretize()
|
||||||
|
|
||||||
|
assert not list(e.concretized_specs())
|
||||||
|
|
||||||
|
|
||||||
def test_remove_command():
|
def test_remove_command():
|
||||||
env("create", "test")
|
env("create", "test")
|
||||||
assert "test" in env("list")
|
assert "test" in env("list")
|
||||||
|
Loading…
Reference in New Issue
Block a user