diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/spec.py | 9 | ||||
-rw-r--r-- | lib/spack/spack/test/spec_syntax.py | 26 |
2 files changed, 28 insertions, 7 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 03f334597a..b09d72003e 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -3945,7 +3945,8 @@ class SpecLexer(spack.parse.Lexer): # Filenames match before identifiers, so no initial filename # component is parsed as a spec (e.g., in subdir/spec.yaml) - (r'[/\w.-]+\.yaml[^\b]*', lambda scanner, v: self.token(FILE, v)), + (r'[/\w.-]*/[/\w/-]+\.yaml[^\b]*', + lambda scanner, v: self.token(FILE, v)), # Hash match after filename. No valid filename can be a hash # (files end w/.yaml), but a hash can match a filename prefix. @@ -4096,11 +4097,6 @@ class SpecParser(spack.parse.Parser): """ path = self.token.value - # don't treat builtin.yaml, builtin.yaml-cpp, etc. as filenames - if re.match(spec_id_re + '$', path): - self.push_tokens([spack.parse.Token(ID, self.token.value)]) - return None - # Special case where someone omits a space after a filename. Consider: # # libdwarf^/some/path/to/libelf.yamllibdwarf ^../../libelf.yaml @@ -4112,7 +4108,6 @@ class SpecParser(spack.parse.Parser): raise SpecFilenameError( "Spec filename must end in .yaml: '{0}'".format(path)) - # if we get here, we're *finally* interpreting path as a filename if not os.path.exists(path): raise NoSuchSpecFileError("No such spec file: '{0}'".format(path)) diff --git a/lib/spack/spack/test/spec_syntax.py b/lib/spack/spack/test/spec_syntax.py index 688c89022c..c9a2100b09 100644 --- a/lib/spack/spack/test/spec_syntax.py +++ b/lib/spack/spack/test/spec_syntax.py @@ -188,6 +188,32 @@ class TestSpecSyntax(object): " ^_openmpi@1.2:1.4,1.6%intel@12.1~qt_4 debug=2" " ^stackwalker@8.1_1e arch=test-redhat6-x86") + def test_yaml_specs(self): + self.check_parse( + "yaml-cpp@0.1.8%intel@12.1" + " ^boost@3.1.4") + tempspec = r"builtin.yaml-cpp%gcc" + self.check_parse( + tempspec.strip("builtin."), + spec=tempspec) + tempspec = r"testrepo.yaml-cpp%gcc" + self.check_parse( + tempspec.strip("testrepo."), + spec=tempspec) + tempspec = r"builtin.yaml-cpp@0.1.8%gcc" + self.check_parse( + tempspec.strip("builtin."), + spec=tempspec) + tempspec = r"builtin.yaml-cpp@0.1.8%gcc@7.2.0" + self.check_parse( + tempspec.strip("builtin."), + spec=tempspec) + tempspec = r"builtin.yaml-cpp@0.1.8%gcc@7.2.0" \ + r" ^boost@3.1.4" + self.check_parse( + tempspec.strip("builtin."), + spec=tempspec) + def test_canonicalize(self): self.check_parse( "mvapich_foo" |