package sanity: ensure all variant defaults are allowed values (#20373)
This commit is contained in:

committed by
GitHub

parent
c6c1af4969
commit
e7f4c2b49e
@@ -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
|
||||
|
@@ -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.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
|
||||
|
@@ -82,8 +82,7 @@ def isa_type(v):
|
||||
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
|
||||
|
Reference in New Issue
Block a user