diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2020-12-15 10:22:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-15 10:22:15 +0100 |
commit | e7f4c2b49e38ceecb895b4ad6885ceea377a9737 (patch) | |
tree | 7ffce9345ddf9edd419273f5bff34603cacddc08 /lib | |
parent | c6c1af496926792b20b3616217f205b7dcb20d21 (diff) | |
download | spack-e7f4c2b49e38ceecb895b4ad6885ceea377a9737.tar.gz spack-e7f4c2b49e38ceecb895b4ad6885ceea377a9737.tar.bz2 spack-e7f4c2b49e38ceecb895b4ad6885ceea377a9737.tar.xz spack-e7f4c2b49e38ceecb895b4ad6885ceea377a9737.zip |
package sanity: ensure all variant defaults are allowed values (#20373)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/build_systems/cuda.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/test/package_sanity.py | 14 | ||||
-rw-r--r-- | lib/spack/spack/variant.py | 3 |
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 |