summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2022-10-17 16:57:58 +0200
committerGitHub <noreply@github.com>2022-10-17 08:57:58 -0600
commite882583b013be66aeed777f19a4b2604a377f2c7 (patch)
treeec089ac33746788a2f9fff4550ba48e36f66fd4d /lib
parent1be6506e29b57bd905145c8f08fbd7193e74bb78 (diff)
downloadspack-e882583b013be66aeed777f19a4b2604a377f2c7.tar.gz
spack-e882583b013be66aeed777f19a4b2604a377f2c7.tar.bz2
spack-e882583b013be66aeed777f19a4b2604a377f2c7.tar.xz
spack-e882583b013be66aeed777f19a4b2604a377f2c7.zip
installer.py: fix/test get_deptypes (#33363)
Fixing an oversight in https://github.com/spack/spack/pull/32537 `get_deptypes` should depend on new `package/dependencies_cache_only` props.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/installer.py8
-rw-r--r--lib/spack/spack/test/buildrequest.py33
2 files changed, 40 insertions, 1 deletions
diff --git a/lib/spack/spack/installer.py b/lib/spack/spack/installer.py
index 7ec31f0267..1de78e392b 100644
--- a/lib/spack/spack/installer.py
+++ b/lib/spack/spack/installer.py
@@ -2391,7 +2391,13 @@ class BuildRequest(object):
"""
deptypes = ["link", "run"]
include_build_deps = self.install_args.get("include_build_deps")
- if not self.install_args.get("cache_only") or include_build_deps:
+
+ if self.pkg_id == package_id(pkg):
+ cache_only = self.install_args.get("package_cache_only")
+ else:
+ cache_only = self.install_args.get("dependencies_cache_only")
+
+ if not cache_only or include_build_deps:
deptypes.append("build")
if self.run_tests(pkg):
deptypes.append("test")
diff --git a/lib/spack/spack/test/buildrequest.py b/lib/spack/spack/test/buildrequest.py
index e656cfa99e..7c986bb844 100644
--- a/lib/spack/spack/test/buildrequest.py
+++ b/lib/spack/spack/test/buildrequest.py
@@ -62,3 +62,36 @@ def test_build_request_strings(install_mockery):
istr = str(request)
assert "package=dependent-install" in istr
assert "install_args=" in istr
+
+
+@pytest.mark.parametrize(
+ "package_cache_only,dependencies_cache_only,package_deptypes,dependencies_deptypes",
+ [
+ (False, False, ["build", "link", "run"], ["build", "link", "run"]),
+ (True, False, ["link", "run"], ["build", "link", "run"]),
+ (False, True, ["build", "link", "run"], ["link", "run"]),
+ (True, True, ["link", "run"], ["link", "run"]),
+ ],
+)
+def test_build_request_deptypes(
+ install_mockery,
+ package_cache_only,
+ dependencies_cache_only,
+ package_deptypes,
+ dependencies_deptypes,
+):
+ s = spack.spec.Spec("dependent-install").concretized()
+
+ build_request = inst.BuildRequest(
+ s.package,
+ {
+ "package_cache_only": package_cache_only,
+ "dependencies_cache_only": dependencies_cache_only,
+ },
+ )
+
+ actual_package_deptypes = build_request.get_deptypes(s.package)
+ actual_dependency_deptypes = build_request.get_deptypes(s["dependency-install"].package)
+
+ assert sorted(actual_package_deptypes) == package_deptypes
+ assert sorted(actual_dependency_deptypes) == dependencies_deptypes