summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Becker <becker33@llnl.gov>2021-12-10 01:49:33 -0800
committerMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-12-23 16:02:09 +0100
commit7e5de95a3025237247fda6552eea24cd406a1ded (patch)
treef706c8fefff0a687c28e11fb18a4f9ef04ea3596
parente9f7fb03c9f92e78637480cbda7e5ecdc3e28dda (diff)
downloadspack-7e5de95a3025237247fda6552eea24cd406a1ded.tar.gz
spack-7e5de95a3025237247fda6552eea24cd406a1ded.tar.bz2
spack-7e5de95a3025237247fda6552eea24cd406a1ded.tar.xz
spack-7e5de95a3025237247fda6552eea24cd406a1ded.zip
Improve debug info from concretizer (#27707)
-rw-r--r--lib/spack/spack/solver/asp.py24
-rw-r--r--lib/spack/spack/test/concretize.py11
2 files changed, 33 insertions, 2 deletions
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):