From 488a08b4642db9d7519b35d915c3959e44fbb7b7 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Tue, 12 Jan 2021 15:42:11 +0100 Subject: concretizer: require at least a dependency type to say the dependency holds fixes #20784 Similarly to the previous bug, here we were deducing conditions to be imposed on nodes that were not part of the DAG. --- lib/spack/spack/solver/concretize.lp | 3 +++ lib/spack/spack/test/concretize.py | 8 ++++++++ .../test-dep-with-imposed-conditions/package.py | 17 +++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 var/spack/repos/builtin.mock/packages/test-dep-with-imposed-conditions/package.py diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp index 938f4ece89..d0174ca2e0 100644 --- a/lib/spack/spack/solver/concretize.lp +++ b/lib/spack/spack/solver/concretize.lp @@ -88,6 +88,9 @@ dependency_conditions_hold(ID, Parent, Dependency) :- attr(Name, Arg1, Arg2) : required_dependency_condition(ID, Name, Arg1, Arg2); attr(Name, Arg1, Arg2, Arg3) : required_dependency_condition(ID, Name, Arg1, Arg2, Arg3); dependency_condition(ID, Parent, Dependency); + % There must be at least a dependency type declared, + % otherwise the dependency doesn't hold + dependency_type(ID, _); node(Parent); not external(Parent). diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py index 3eab265d8c..dae162a12f 100644 --- a/lib/spack/spack/test/concretize.py +++ b/lib/spack/spack/test/concretize.py @@ -1089,3 +1089,11 @@ class TestConcretize(object): ).concretized() assert root.dag_hash() == new_root.dag_hash() + + @pytest.mark.regression('20784') + def test_concretization_of_test_dependencies(self): + # With clingo we emit dependency_conditions regardless of the type + # of the dependency. We need to ensure that there's at least one + # dependency type declared to infer that the dependency holds. + s = Spec('test-dep-with-imposed-conditions').concretized() + assert 'c' not in s diff --git a/var/spack/repos/builtin.mock/packages/test-dep-with-imposed-conditions/package.py b/var/spack/repos/builtin.mock/packages/test-dep-with-imposed-conditions/package.py new file mode 100644 index 0000000000..a61107495f --- /dev/null +++ b/var/spack/repos/builtin.mock/packages/test-dep-with-imposed-conditions/package.py @@ -0,0 +1,17 @@ +# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +from spack import * + + +class TestDepWithImposedConditions(Package): + """Simple package with no dependencies""" + + homepage = "http://www.example.com" + url = "http://www.example.com/e-1.0.tar.gz" + + version('1.0', '0123456789abcdef0123456789abcdef') + + depends_on('c@1.0', type='test') -- cgit v1.2.3-70-g09d2