From dc87157e80a25c4d3fa1b75bf42f80b3560b362d Mon Sep 17 00:00:00 2001 From: Greg Becker Date: Fri, 10 Dec 2021 01:49:33 -0800 Subject: Improve debug info from concretizer (#27707) --- lib/spack/spack/solver/asp.py | 24 ++++++++++++++++++++++-- lib/spack/spack/test/concretize.py | 11 +++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index c1c3cb33a9..4ad05cd9bf 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -366,6 +366,19 @@ class Result(object): 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 @@ class Result(object): 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 @@ class PyclingoDriver(object): 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) diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index 54d886a55b..5e9188b888 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -557,6 +557,17 @@ class TestConcretize(object): 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): -- cgit v1.2.3-60-g2f50