summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2023-12-19 18:05:33 +0100
committerGitHub <noreply@github.com>2023-12-19 18:05:33 +0100
commit0eca79e7e4f6ffba47dad9c76d58e131f8dfef99 (patch)
tree22f622286bc0d3765aa65cbcbd6b4962c908a5b5 /lib
parentf245bde77255eecb718f42ad547fabb92db7894a (diff)
downloadspack-0eca79e7e4f6ffba47dad9c76d58e131f8dfef99.tar.gz
spack-0eca79e7e4f6ffba47dad9c76d58e131f8dfef99.tar.bz2
spack-0eca79e7e4f6ffba47dad9c76d58e131f8dfef99.tar.xz
spack-0eca79e7e4f6ffba47dad9c76d58e131f8dfef99.zip
Add an audit to prevent virtual packages with variants specified (#41747)
Currently, a virtual spec is composed of just a name and a version. When a virtual spec contains other components, such as variants, Spack won't emit warnings or errors but will silently drop them - which is unexpected by users.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/audit.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/spack/spack/audit.py b/lib/spack/spack/audit.py
index 4fe1b1dddf..be1f72c2cf 100644
--- a/lib/spack/spack/audit.py
+++ b/lib/spack/spack/audit.py
@@ -757,6 +757,15 @@ def _issues_in_depends_on_directive(pkgs, error_cls):
]
errors.append(error_cls(summary=summary, details=details))
+ for s in (dependency_spec, when):
+ if s.virtual and s.variants:
+ summary = f"{pkg_name}: virtual dependency cannot have variants"
+ details = [
+ f"remove variants from '{str(s)}' in depends_on directive",
+ f"in {filename}",
+ ]
+ errors.append(error_cls(summary=summary, details=details))
+
# No need to analyze virtual packages
if spack.repo.PATH.is_virtual(dependency_name):
continue