From 116f6b30eb7820b5f39e3edf0a94b8f0e2308dc9 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Thu, 22 Oct 2020 09:47:02 +0200 Subject: concretizer: handle variants defined through validators Variant of this kind don't have a list of possible values encoded in the ASP facts. Since all we have is a validator the list of possible values just includes just the default value and possibly the value passed from packages.yaml or cli. --- lib/spack/spack/solver/asp.py | 15 +++++++++++++++ lib/spack/spack/test/cmd/install.py | 10 ++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 292d3a5a3f..9e37ab5cf8 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -1486,6 +1486,21 @@ class SpackSolverSetup(object): else: for clause in self.spec_clauses(dep): self.gen.fact(clause) + # TODO: This might need to be moved somewhere else. + # TODO: It's needed to account for open-ended variants + # TODO: validated through a function. The rationale is + # TODO: that if a value is set from cli and validated + # TODO: then it's also a possible value. + if clause.name == 'variant_set': + variant_name = clause.args[1] + variant_def = dep.package.variants[variant_name] + variant_def.validate_or_raise( + dep.variants[variant_name], + dep.package + ) + self.gen.fact( + fn.variant_possible_value(*clause.args) + ) self.gen.h1("Virtual Constraints") self.define_virtual_constraints() diff --git a/lib/spack/spack/test/cmd/install.py b/lib/spack/spack/test/cmd/install.py index 93b1bc2eae..8e87f97c98 100644 --- a/lib/spack/spack/test/cmd/install.py +++ b/lib/spack/spack/test/cmd/install.py @@ -467,8 +467,14 @@ def test_cdash_report_concretization_error(tmpdir, mock_fetch, install_mockery, report_file = report_dir.join('Update.xml') assert report_file in report_dir.listdir() content = report_file.open().read() - assert 'Conflicts in concretized spec' \ - in content + assert '' in content + # The message is different based on using the + # new or the old concretizer + expected_messages = ( + 'Conflicts in concretized spec', + 'does not satisfy' + ) + assert any(x in content for x in expected_messages) @pytest.mark.disable_clean_stage_check -- cgit v1.2.3-60-g2f50