Compare commits
5 Commits
develop
...
bugfix/tra
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2d46de5741 | ||
![]() |
b9cf63aa41 | ||
![]() |
0ced62480d | ||
![]() |
265d80cee3 | ||
![]() |
0f1d36585e |
@ -1345,28 +1345,38 @@ def concretize(self, force=False, tests=False):
|
|||||||
List of specs that have been concretized. Each entry is a tuple of
|
List of specs that have been concretized. Each entry is a tuple of
|
||||||
the user spec and the corresponding concretized spec.
|
the user spec and the corresponding concretized spec.
|
||||||
"""
|
"""
|
||||||
if force:
|
old_concretized_user_specs = self.concretized_user_specs[:]
|
||||||
# Clear previously concretized specs
|
old_concretized_order = self.concretized_order[:]
|
||||||
self.concretized_user_specs = []
|
old_specs_by_hash = self.specs_by_hash.copy()
|
||||||
self.concretized_order = []
|
|
||||||
self.specs_by_hash = {}
|
|
||||||
|
|
||||||
# Remove concrete specs that no longer correlate to a user spec
|
try:
|
||||||
for spec in set(self.concretized_user_specs) - set(self.user_specs):
|
if force:
|
||||||
self.deconcretize(spec)
|
# Clear previously concretized specs
|
||||||
|
self.concretized_user_specs = []
|
||||||
|
self.concretized_order = []
|
||||||
|
self.specs_by_hash = {}
|
||||||
|
|
||||||
# Pick the right concretization strategy
|
# Remove concrete specs that no longer correlate to a user spec
|
||||||
if self.unify == "when_possible":
|
for spec in set(self.concretized_user_specs) - set(self.user_specs):
|
||||||
return self._concretize_together_where_possible(tests=tests)
|
self.deconcretize(spec)
|
||||||
|
|
||||||
if self.unify is True:
|
# Pick the right concretization strategy
|
||||||
return self._concretize_together(tests=tests)
|
if self.unify == "when_possible":
|
||||||
|
return self._concretize_together_where_possible(tests=tests)
|
||||||
|
|
||||||
if self.unify is False:
|
if self.unify is True:
|
||||||
return self._concretize_separately(tests=tests)
|
return self._concretize_together(tests=tests)
|
||||||
|
|
||||||
msg = "concretization strategy not implemented [{0}]"
|
if self.unify is False:
|
||||||
raise SpackEnvironmentError(msg.format(self.unify))
|
return self._concretize_separately(tests=tests)
|
||||||
|
|
||||||
|
msg = "concretization strategy not implemented [{0}]"
|
||||||
|
raise SpackEnvironmentError(msg.format(self.unify))
|
||||||
|
except Exception:
|
||||||
|
self.concretized_user_specs = old_concretized_user_specs
|
||||||
|
self.concretized_order = old_concretized_order
|
||||||
|
self.specs_by_hash = old_specs_by_hash
|
||||||
|
raise
|
||||||
|
|
||||||
def deconcretize(self, spec):
|
def deconcretize(self, spec):
|
||||||
# spec has to be a root of the environment
|
# spec has to be a root of the environment
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import llnl.util.link_tree
|
import llnl.util.link_tree
|
||||||
|
|
||||||
import spack.cmd.env
|
import spack.cmd.env
|
||||||
|
import spack.concretize
|
||||||
import spack.config
|
import spack.config
|
||||||
import spack.environment as ev
|
import spack.environment as ev
|
||||||
import spack.environment.environment
|
import spack.environment.environment
|
||||||
@ -25,6 +26,7 @@
|
|||||||
import spack.modules
|
import spack.modules
|
||||||
import spack.paths
|
import spack.paths
|
||||||
import spack.repo
|
import spack.repo
|
||||||
|
import spack.solver.asp
|
||||||
import spack.util.spack_json as sjson
|
import spack.util.spack_json as sjson
|
||||||
from spack.cmd.env import _env_create
|
from spack.cmd.env import _env_create
|
||||||
from spack.main import SpackCommand, SpackCommandError
|
from spack.main import SpackCommand, SpackCommandError
|
||||||
@ -2759,6 +2761,51 @@ def test_virtual_spec_concretize_together(tmpdir):
|
|||||||
assert any(s.package.provides("mpi") for _, s in e.concretized_specs())
|
assert any(s.package.provides("mpi") for _, s in e.concretized_specs())
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"unify,method_to_fail",
|
||||||
|
[
|
||||||
|
(True, (spack.concretize, "concretize_specs_together")),
|
||||||
|
("when_possible", (spack.solver.asp.Solver, "solve_in_rounds")),
|
||||||
|
# An earlier failure so that we test the case where the internal state
|
||||||
|
# has been changed, but the pointer to the internal variables has not change.
|
||||||
|
# This effectively tests that we are properly copying by value not by
|
||||||
|
# reference for the transactional concretization
|
||||||
|
(True, (spack.environment.Environment, "_get_specs_to_concretize")),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_concretize_transactional(unify, method_to_fail, monkeypatch):
|
||||||
|
e = ev.create("test")
|
||||||
|
e.unify = unify
|
||||||
|
|
||||||
|
e.add("mpi")
|
||||||
|
e.add("zlib")
|
||||||
|
e.concretize()
|
||||||
|
|
||||||
|
# remove one spec and add another to ensure we test with changes before
|
||||||
|
# and after the environment is cleared during concretization
|
||||||
|
e.remove("zlib")
|
||||||
|
e.add("libelf")
|
||||||
|
|
||||||
|
def fail(*args, **kwargs):
|
||||||
|
raise Exception("Test failures")
|
||||||
|
|
||||||
|
location, method = method_to_fail
|
||||||
|
monkeypatch.setattr(location, method, fail)
|
||||||
|
|
||||||
|
first_user_specs = e.concretized_user_specs[:]
|
||||||
|
first_order = e.concretized_order[:]
|
||||||
|
first_hash_dict = e.specs_by_hash.copy()
|
||||||
|
|
||||||
|
try:
|
||||||
|
e.concretize()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
assert e.concretized_user_specs == first_user_specs
|
||||||
|
assert e.concretized_order == first_order
|
||||||
|
assert e.specs_by_hash == first_hash_dict
|
||||||
|
|
||||||
|
|
||||||
def test_query_develop_specs():
|
def test_query_develop_specs():
|
||||||
"""Test whether a spec is develop'ed or not"""
|
"""Test whether a spec is develop'ed or not"""
|
||||||
env("create", "test")
|
env("create", "test")
|
||||||
|
Loading…
Reference in New Issue
Block a user