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.
This commit is contained in:
Massimiliano Culpo 2021-01-12 15:42:11 +01:00 committed by Todd Gamblin
parent ed8fe68cf2
commit 0bd76ac9e6
3 changed files with 28 additions and 0 deletions

View file

@ -93,6 +93,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).

View file

@ -1090,3 +1090,11 @@ def test_reuse_installed_packages(
).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

View file

@ -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')