input_analysis.py: fix conditional requirements (#50194)
Fixes a logic bug where a -> b was assumed to imply not a -> not b in conditional requirements. Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:

committed by
GitHub

parent
8921612f6a
commit
3df5a85237
@@ -85,8 +85,10 @@ def is_virtual(self, name: str) -> bool:
|
||||
def is_allowed_on_this_platform(self, *, pkg_name: str) -> bool:
|
||||
"""Returns true if a package is allowed on the current host"""
|
||||
pkg_cls = self.repo.get_pkg_class(pkg_name)
|
||||
no_condition = spack.spec.Spec()
|
||||
for when_spec, conditions in pkg_cls.requirements.items():
|
||||
if not when_spec.intersects(self._platform_condition):
|
||||
# Restrict analysis to unconditional requirements
|
||||
if when_spec != no_condition:
|
||||
continue
|
||||
for requirements, _, _ in conditions:
|
||||
if not any(x.intersects(self._platform_condition) for x in requirements):
|
||||
|
@@ -3366,3 +3366,17 @@ def test_reuse_when_requiring_build_dep(
|
||||
with spack.config.override("concretizer:reuse", True):
|
||||
result = spack.concretize.concretize_one("pkg-b")
|
||||
assert pkgb_old.dag_hash() == result.dag_hash(), result.tree()
|
||||
|
||||
|
||||
@pytest.mark.regression("50167")
|
||||
def test_input_analysis_and_conditional_requirements(default_mock_concretization):
|
||||
"""Tests that input analysis doesn't account for conditional requirement
|
||||
to discard possible dependencies.
|
||||
|
||||
If the requirement is conditional, and impossible to achieve on the current
|
||||
platform, the valid search space is still the complement of the condition that
|
||||
activates the requirement.
|
||||
"""
|
||||
libceed = default_mock_concretization("libceed")
|
||||
assert libceed["libxsmm"].satisfies("@main")
|
||||
assert libceed["libxsmm"].satisfies("platform=test")
|
||||
|
Reference in New Issue
Block a user