summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/build_systems/cuda.py4
-rw-r--r--lib/spack/spack/test/package_sanity.py14
-rw-r--r--lib/spack/spack/variant.py3
3 files changed, 16 insertions, 5 deletions
diff --git a/lib/spack/spack/build_systems/cuda.py b/lib/spack/spack/build_systems/cuda.py
index ed574260e7..61007431a4 100644
--- a/lib/spack/spack/build_systems/cuda.py
+++ b/lib/spack/spack/build_systems/cuda.py
@@ -19,7 +19,7 @@ class CudaPackage(PackageBase):
# https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#gpu-feature-list
# https://developer.nvidia.com/cuda-gpus
# https://en.wikipedia.org/wiki/CUDA#GPUs_supported
- cuda_arch_values = [
+ cuda_arch_values = (
'10', '11', '12', '13',
'20', '21',
'30', '32', '35', '37',
@@ -27,7 +27,7 @@ class CudaPackage(PackageBase):
'60', '61', '62',
'70', '72', '75',
'80', '86'
- ]
+ )
# FIXME: keep cuda and cuda_arch separate to make usage easier until
# Spack has depends_on(cuda, when='cuda_arch!=None') or alike
diff --git a/lib/spack/spack/test/package_sanity.py b/lib/spack/spack/test/package_sanity.py
index 5c18544a56..d50169a1a4 100644
--- a/lib/spack/spack/test/package_sanity.py
+++ b/lib/spack/spack/test/package_sanity.py
@@ -2,7 +2,6 @@
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
"""This test does sanity checks on Spack's builtin package database."""
import os.path
import re
@@ -14,6 +13,7 @@ import spack.package
import spack.paths
import spack.repo
import spack.util.executable as executable
+import spack.variant
# A few functions from this module are used to
# do sanity checks only on packagess modified by a PR
import spack.cmd.flake8 as flake8
@@ -257,3 +257,15 @@ def test_variant_defaults_are_parsable_from_cli():
if not default_is_parsable:
failing.append((pkg.name, variant_name))
assert not failing
+
+
+def test_variant_defaults_listed_explicitly_in_values():
+ failing = []
+ for pkg in spack.repo.path.all_packages():
+ for variant_name, variant in pkg.variants.items():
+ vspec = variant.make_default()
+ try:
+ variant.validate_or_raise(vspec, pkg=pkg)
+ except spack.variant.InvalidVariantValueError:
+ failing.append((pkg.name, variant.name))
+ assert not failing
diff --git a/lib/spack/spack/variant.py b/lib/spack/spack/variant.py
index e50c34a07d..8fa52f9738 100644
--- a/lib/spack/spack/variant.py
+++ b/lib/spack/spack/variant.py
@@ -82,8 +82,7 @@ class Variant(object):
else:
# Otherwise assume values is the set of allowed explicit values
self.values = values
- allowed = tuple(self.values) + (self.default,)
- self.single_value_validator = lambda x: x in allowed
+ self.single_value_validator = lambda x: x in tuple(self.values)
self.multi = multi
self.group_validator = validator