summaryrefslogtreecommitdiff
path: root/lib/spack/spack/test/spec_syntax.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/spack/spack/test/spec_syntax.py')
-rw-r--r--lib/spack/spack/test/spec_syntax.py94
1 files changed, 45 insertions, 49 deletions
diff --git a/lib/spack/spack/test/spec_syntax.py b/lib/spack/spack/test/spec_syntax.py
index e17ed724a4..3401575767 100644
--- a/lib/spack/spack/test/spec_syntax.py
+++ b/lib/spack/spack/test/spec_syntax.py
@@ -952,64 +952,60 @@ def test_disambiguate_hash_by_spec(spec1, spec2, constraint, mock_packages, monk
@pytest.mark.parametrize(
- "text,exc_cls",
+ "text,match_string",
[
# Duplicate variants
- ("x@1.2+debug+debug", spack.variant.DuplicateVariantError),
- ("x ^y@1.2+debug debug=true", spack.variant.DuplicateVariantError),
- ("x ^y@1.2 debug=false debug=true", spack.variant.DuplicateVariantError),
- ("x ^y@1.2 debug=false ~debug", spack.variant.DuplicateVariantError),
+ ("x@1.2+debug+debug", "variant"),
+ ("x ^y@1.2+debug debug=true", "variant"),
+ ("x ^y@1.2 debug=false debug=true", "variant"),
+ ("x ^y@1.2 debug=false ~debug", "variant"),
# Multiple versions
- ("x@1.2@2.3", spack.spec.MultipleVersionError),
- ("x@1.2:2.3@1.4", spack.spec.MultipleVersionError),
- ("x@1.2@2.3:2.4", spack.spec.MultipleVersionError),
- ("x@1.2@2.3,2.4", spack.spec.MultipleVersionError),
- ("x@1.2 +foo~bar @2.3", spack.spec.MultipleVersionError),
- ("x@1.2%y@1.2@2.3:2.4", spack.spec.MultipleVersionError),
+ ("x@1.2@2.3", "version"),
+ ("x@1.2:2.3@1.4", "version"),
+ ("x@1.2@2.3:2.4", "version"),
+ ("x@1.2@2.3,2.4", "version"),
+ ("x@1.2 +foo~bar @2.3", "version"),
+ ("x@1.2%y@1.2@2.3:2.4", "version"),
# Duplicate dependency
- ("x ^y@1 ^y@2", spack.spec.DuplicateDependencyError),
+ ("x ^y@1 ^y@2", "Cannot depend on incompatible specs"),
# Duplicate compiler
- ("x%intel%intel", spack.spec.DuplicateCompilerSpecError),
- ("x%intel%gcc", spack.spec.DuplicateCompilerSpecError),
- ("x%gcc%intel", spack.spec.DuplicateCompilerSpecError),
- ("x ^y%intel%intel", spack.spec.DuplicateCompilerSpecError),
- ("x ^y%intel%gcc", spack.spec.DuplicateCompilerSpecError),
- ("x ^y%gcc%intel", spack.spec.DuplicateCompilerSpecError),
+ ("x%intel%intel", "compiler"),
+ ("x%intel%gcc", "compiler"),
+ ("x%gcc%intel", "compiler"),
+ ("x ^y%intel%intel", "compiler"),
+ ("x ^y%intel%gcc", "compiler"),
+ ("x ^y%gcc%intel", "compiler"),
# Duplicate Architectures
- (
- "x arch=linux-rhel7-x86_64 arch=linux-rhel7-x86_64",
- spack.spec.DuplicateArchitectureError,
- ),
- (
- "x arch=linux-rhel7-x86_64 arch=linux-rhel7-ppc64le",
- spack.spec.DuplicateArchitectureError,
- ),
- (
- "x arch=linux-rhel7-ppc64le arch=linux-rhel7-x86_64",
- spack.spec.DuplicateArchitectureError,
- ),
- (
- "y ^x arch=linux-rhel7-x86_64 arch=linux-rhel7-x86_64",
- spack.spec.DuplicateArchitectureError,
- ),
- (
- "y ^x arch=linux-rhel7-x86_64 arch=linux-rhel7-ppc64le",
- spack.spec.DuplicateArchitectureError,
- ),
- ("x os=fe os=fe", spack.spec.DuplicateArchitectureError),
- ("x os=fe os=be", spack.spec.DuplicateArchitectureError),
- ("x target=fe target=fe", spack.spec.DuplicateArchitectureError),
- ("x target=fe target=be", spack.spec.DuplicateArchitectureError),
- ("x platform=test platform=test", spack.spec.DuplicateArchitectureError),
- ("x os=fe platform=test target=fe os=fe", spack.spec.DuplicateArchitectureError),
- ("x target=be platform=test os=be os=fe", spack.spec.DuplicateArchitectureError),
- ("^[@foo] zlib", spack.parser.SpecParsingError),
+ ("x arch=linux-rhel7-x86_64 arch=linux-rhel7-x86_64", "two architectures"),
+ ("x arch=linux-rhel7-x86_64 arch=linux-rhel7-ppc64le", "two architectures"),
+ ("x arch=linux-rhel7-ppc64le arch=linux-rhel7-x86_64", "two architectures"),
+ ("y ^x arch=linux-rhel7-x86_64 arch=linux-rhel7-x86_64", "two architectures"),
+ ("y ^x arch=linux-rhel7-x86_64 arch=linux-rhel7-ppc64le", "two architectures"),
+ ("x os=fe os=fe", "'os'"),
+ ("x os=fe os=be", "'os'"),
+ ("x target=fe target=fe", "'target'"),
+ ("x target=fe target=be", "'target'"),
+ ("x platform=test platform=test", "'platform'"),
+ # TODO: these two seem wrong: need to change how arch is initialized (should fail on os)
+ ("x os=fe platform=test target=fe os=fe", "'platform'"),
+ ("x target=be platform=test os=be os=fe", "'platform'"),
+ # Dependencies
+ ("^[@foo] zlib", "edge attributes"),
# TODO: Remove this as soon as use variants are added and we can parse custom attributes
- ("^[foo=bar] zlib", spack.parser.SpecParsingError),
+ ("^[foo=bar] zlib", "edge attributes"),
+ # Propagating reserved names generates a parse error
+ ("x namespace==foo.bar.baz", "Propagation"),
+ ("x arch==linux-rhel9-x86_64", "Propagation"),
+ ("x architecture==linux-rhel9-x86_64", "Propagation"),
+ ("x os==rhel9", "Propagation"),
+ ("x operating_system==rhel9", "Propagation"),
+ ("x target==x86_64", "Propagation"),
+ ("x dev_path==/foo/bar/baz", "Propagation"),
+ ("x patches==abcde12345,12345abcde", "Propagation"),
],
)
-def test_error_conditions(text, exc_cls):
- with pytest.raises(exc_cls):
+def test_error_conditions(text, match_string):
+ with pytest.raises(spack.parser.SpecParsingError, match=match_string):
SpecParser(text).next_spec()