summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/config.py8
-rw-r--r--lib/spack/spack/test/cmd/config.py6
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py
index f3fc73e4b4..da19aab2dc 100644
--- a/lib/spack/spack/config.py
+++ b/lib/spack/spack/config.py
@@ -1090,11 +1090,11 @@ def get_valid_type(path):
jsonschema_error = e.validation_error
if jsonschema_error.validator == 'type':
return types[jsonschema_error.validator_value]()
- elif jsonschema_error.validator == 'anyOf':
+ elif jsonschema_error.validator in ('anyOf', 'oneOf'):
for subschema in jsonschema_error.validator_value:
- anyof_type = subschema.get('type')
- if anyof_type is not None:
- return types[anyof_type]()
+ schema_type = subschema.get('type')
+ if schema_type is not None:
+ return types[schema_type]()
else:
return type(None)
raise ConfigError("Cannot determine valid type for path '%s'." % path)
diff --git a/lib/spack/spack/test/cmd/config.py b/lib/spack/spack/test/cmd/config.py
index 63c3cab92a..bf77d78133 100644
--- a/lib/spack/spack/test/cmd/config.py
+++ b/lib/spack/spack/test/cmd/config.py
@@ -239,6 +239,12 @@ def test_config_add_ordered_dict(mutable_empty_config):
"""
+def test_config_add_interpret_oneof(mutable_empty_config):
+ # Regression test for a bug that would raise a validation error
+ config('add', 'packages:all:target:[x86_64]')
+ config('add', 'packages:all:variants:~shared')
+
+
def test_config_add_invalid_fails(mutable_empty_config):
config('add', 'packages:all:variants:+debug')
with pytest.raises(