Improve debug info from concretizer (#27707)

This commit is contained in:
Greg Becker 2021-12-10 01:49:33 -08:00 committed by GitHub
parent d17511a806
commit dc87157e80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 2 deletions

View File

@ -366,6 +366,19 @@ def format_minimal_cores(self):
string_list.extend(self.format_core(core))
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):
"""
Raise an appropriate error if the result is unsatisfiable.
@ -379,7 +392,9 @@ def raise_if_unsat(self):
constraints = self.abstract_specs
if len(constraints) == 1:
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)
@ -496,7 +511,12 @@ def fact(self, head, assumption=False):
self.out.write("%s.\n" % str(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)
if choice:
self.assumptions.append(atom)

View File

@ -557,6 +557,17 @@ def test_conflicts_in_spec(self, conflict_spec):
with pytest.raises(spack.error.SpackError):
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):
s = Spec('when-directives-true')
with pytest.raises(spack.error.SpackError):