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:
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:
|
def is_allowed_on_this_platform(self, *, pkg_name: str) -> bool:
|
||||||
"""Returns true if a package is allowed on the current host"""
|
"""Returns true if a package is allowed on the current host"""
|
||||||
pkg_cls = self.repo.get_pkg_class(pkg_name)
|
pkg_cls = self.repo.get_pkg_class(pkg_name)
|
||||||
|
no_condition = spack.spec.Spec()
|
||||||
for when_spec, conditions in pkg_cls.requirements.items():
|
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
|
continue
|
||||||
for requirements, _, _ in conditions:
|
for requirements, _, _ in conditions:
|
||||||
if not any(x.intersects(self._platform_condition) for x in requirements):
|
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):
|
with spack.config.override("concretizer:reuse", True):
|
||||||
result = spack.concretize.concretize_one("pkg-b")
|
result = spack.concretize.concretize_one("pkg-b")
|
||||||
assert pkgb_old.dag_hash() == result.dag_hash(), result.tree()
|
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")
|
||||||
|
18
var/spack/repos/builtin.mock/packages/libceed/package.py
Normal file
18
var/spack/repos/builtin.mock/packages/libceed/package.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Copyright Spack Project Developers. See COPYRIGHT file for details.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
from spack.package import *
|
||||||
|
|
||||||
|
|
||||||
|
class Libceed(Package):
|
||||||
|
"""Package that has a dependency imposing conditional requirements on platforms"""
|
||||||
|
|
||||||
|
homepage = "https://github.com/CEED/libCEED"
|
||||||
|
url = "http://www.fake.com/libceed.tgz"
|
||||||
|
|
||||||
|
version("0.12.0", sha256="e491ccadebc5cdcd1fc08b5b4509a0aba4e2c096f53d7880062a66b82a0baf84")
|
||||||
|
|
||||||
|
depends_on("c", type="build")
|
||||||
|
depends_on("cxx", type="build")
|
||||||
|
|
||||||
|
depends_on("libxsmm")
|
21
var/spack/repos/builtin.mock/packages/libxsmm/package.py
Normal file
21
var/spack/repos/builtin.mock/packages/libxsmm/package.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Copyright Spack Project Developers. See COPYRIGHT file for details.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
|
from spack.package import *
|
||||||
|
|
||||||
|
|
||||||
|
class Libxsmm(Package):
|
||||||
|
"""Package that imposes conditional requirements on platforms"""
|
||||||
|
|
||||||
|
homepage = "https://github.com/libxsmm/libxsmm"
|
||||||
|
url = "https://github.com/libxsmm/libxsmm/archive/1.17.tar.gz"
|
||||||
|
git = "https://github.com/libxsmm/libxsmm.git"
|
||||||
|
|
||||||
|
version("main", branch="main")
|
||||||
|
version("1.16.3", sha256="e491ccadebc5cdcd1fc08b5b4509a0aba4e2c096f53d7880062a66b82a0baf84")
|
||||||
|
|
||||||
|
depends_on("c", type="build")
|
||||||
|
depends_on("cxx", type="build")
|
||||||
|
|
||||||
|
requires("platform=linux", "platform=test")
|
||||||
|
requires("platform=linux", when="@:1")
|
Loading…
Reference in New Issue
Block a user