Improve debug info from concretizer (#27707)
This commit is contained in:
parent
d17511a806
commit
dc87157e80
@ -366,6 +366,19 @@ def format_minimal_cores(self):
|
|||||||
string_list.extend(self.format_core(core))
|
string_list.extend(self.format_core(core))
|
||||||
return string_list
|
return string_list
|
||||||
|
|
||||||
|
def format_cores(self):
|
||||||
|
"""List of facts for each core
|
||||||
|
|
||||||
|
Separate cores are separated by an empty line
|
||||||
|
Cores are not minimized
|
||||||
|
"""
|
||||||
|
string_list = []
|
||||||
|
for core in self.cores:
|
||||||
|
if string_list:
|
||||||
|
string_list.append('\n')
|
||||||
|
string_list.extend(self.format_core(core))
|
||||||
|
return string_list
|
||||||
|
|
||||||
def raise_if_unsat(self):
|
def raise_if_unsat(self):
|
||||||
"""
|
"""
|
||||||
Raise an appropriate error if the result is unsatisfiable.
|
Raise an appropriate error if the result is unsatisfiable.
|
||||||
@ -379,7 +392,9 @@ def raise_if_unsat(self):
|
|||||||
constraints = self.abstract_specs
|
constraints = self.abstract_specs
|
||||||
if len(constraints) == 1:
|
if len(constraints) == 1:
|
||||||
constraints = constraints[0]
|
constraints = constraints[0]
|
||||||
conflicts = self.format_minimal_cores()
|
|
||||||
|
debug = spack.config.get('config:debug', False)
|
||||||
|
conflicts = self.format_cores() if debug else self.format_minimal_cores()
|
||||||
|
|
||||||
raise spack.error.UnsatisfiableSpecError(constraints, conflicts=conflicts)
|
raise spack.error.UnsatisfiableSpecError(constraints, conflicts=conflicts)
|
||||||
|
|
||||||
@ -496,7 +511,12 @@ def fact(self, head, assumption=False):
|
|||||||
self.out.write("%s.\n" % str(symbol))
|
self.out.write("%s.\n" % str(symbol))
|
||||||
|
|
||||||
atom = self.backend.add_atom(symbol)
|
atom = self.backend.add_atom(symbol)
|
||||||
choice = self.cores and assumption
|
|
||||||
|
# in debug mode, make all facts choices/assumptions
|
||||||
|
# otherwise, only if we're generating cores and assumption=True
|
||||||
|
debug = spack.config.get('config:debug', False)
|
||||||
|
choice = debug or (self.cores and assumption)
|
||||||
|
|
||||||
self.backend.add_rule([atom], [], choice=choice)
|
self.backend.add_rule([atom], [], choice=choice)
|
||||||
if choice:
|
if choice:
|
||||||
self.assumptions.append(atom)
|
self.assumptions.append(atom)
|
||||||
|
@ -557,6 +557,17 @@ def test_conflicts_in_spec(self, conflict_spec):
|
|||||||
with pytest.raises(spack.error.SpackError):
|
with pytest.raises(spack.error.SpackError):
|
||||||
s.concretize()
|
s.concretize()
|
||||||
|
|
||||||
|
def test_conflicts_new_concretizer_debug(self, conflict_spec, mutable_config):
|
||||||
|
if spack.config.get('config:concretizer') == 'original':
|
||||||
|
pytest.skip('Testing debug statements specific to new concretizer')
|
||||||
|
|
||||||
|
spack.config.set('config:debug', True)
|
||||||
|
s = Spec(conflict_spec)
|
||||||
|
with pytest.raises(spack.error.SpackError) as e:
|
||||||
|
s.concretize()
|
||||||
|
|
||||||
|
assert "conflict_trigger(" in e.value.message
|
||||||
|
|
||||||
def test_conflict_in_all_directives_true(self):
|
def test_conflict_in_all_directives_true(self):
|
||||||
s = Spec('when-directives-true')
|
s = Spec('when-directives-true')
|
||||||
with pytest.raises(spack.error.SpackError):
|
with pytest.raises(spack.error.SpackError):
|
||||||
|
Loading…
Reference in New Issue
Block a user