diff options
author | Greg Becker <becker33@llnl.gov> | 2023-05-24 15:41:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-24 15:41:57 +0200 |
commit | 033599c4cd0889af2cb8ae4b52984fa88558f5c2 (patch) | |
tree | 29744c5d8098dd039727c2fda5e00bd6ce18f4e3 /lib | |
parent | 8096ed4b22f1187bc7262521534ec5ebeb41be67 (diff) | |
download | spack-033599c4cd0889af2cb8ae4b52984fa88558f5c2.tar.gz spack-033599c4cd0889af2cb8ae4b52984fa88558f5c2.tar.bz2 spack-033599c4cd0889af2cb8ae4b52984fa88558f5c2.tar.xz spack-033599c4cd0889af2cb8ae4b52984fa88558f5c2.zip |
bugfix: env concretize after remove (#37877)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/environment/environment.py | 14 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/env.py | 13 |
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py index 3d56a7d207..d2a025443b 100644 --- a/lib/spack/spack/environment/environment.py +++ b/lib/spack/spack/environment/environment.py @@ -1351,6 +1351,10 @@ class Environment: self.concretized_order = [] 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 if self.unify == "when_possible": return self._concretize_together_where_possible(tests=tests) @@ -1364,6 +1368,16 @@ class Environment: msg = "concretization strategy not implemented [{0}]" 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( self, ) -> Tuple[Set[spack.spec.Spec], Set[spack.spec.Spec], List[spack.spec.Spec]]: diff --git a/lib/spack/spack/test/cmd/env.py b/lib/spack/spack/test/cmd/env.py index 5855e0e208..f89b708568 100644 --- a/lib/spack/spack/test/cmd/env.py +++ b/lib/spack/spack/test/cmd/env.py @@ -390,6 +390,19 @@ def test_remove_after_concretize(): 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(): env("create", "test") assert "test" in env("list") |