summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-05-05 14:24:46 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2015-05-05 14:24:46 -0700
commit1d0975bac676c607b6e4c18edcdf683e11b4f457 (patch)
tree24922ef652f5c661188ae61bc9ad77c3ddccfc93
parentd687962b746c1b8e10789799ba20e1f2ea01407f (diff)
downloadspack-1d0975bac676c607b6e4c18edcdf683e11b4f457.tar.gz
spack-1d0975bac676c607b6e4c18edcdf683e11b4f457.tar.bz2
spack-1d0975bac676c607b6e4c18edcdf683e11b4f457.tar.xz
spack-1d0975bac676c607b6e4c18edcdf683e11b4f457.zip
Bugfixes for yaml specs.
-rw-r--r--lib/spack/spack/spec.py13
-rw-r--r--lib/spack/spack/test/spec_yaml.py6
-rw-r--r--lib/spack/spack/version.py2
3 files changed, 18 insertions, 3 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 72a95de79e..dd9ec5dbe3 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -1,5 +1,5 @@
##############################################################################
-# Copyright (c) 2013, Lawrence Livermore National Security, LLC.
+# Copyright (c) 2013-2015, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
@@ -96,6 +96,7 @@ import hashlib
from StringIO import StringIO
from operator import attrgetter
from external import yaml
+from external.yaml.error import MarkedYAMLError
import llnl.util.tty as tty
from llnl.util.lang import *
@@ -656,7 +657,11 @@ class Spec(object):
deps = {}
spec = None
- yfile = yaml.load(string)
+ try:
+ yfile = yaml.load(string)
+ except MarkedYAMLError, e:
+ raise SpackYAMLError("error parsing YMAL spec:", str(e))
+
for node in yfile['spec']:
name = next(iter(node))
dep = Spec.from_node_dict(node)
@@ -1776,3 +1781,7 @@ class UnsatisfiableDependencySpecError(UnsatisfiableSpecError):
def __init__(self, provided, required):
super(UnsatisfiableDependencySpecError, self).__init__(
provided, required, "dependency")
+
+class SpackYAMLError(spack.error.SpackError):
+ def __init__(self, msg, yaml_error):
+ super(SpackError, self).__init__(msg, str(yaml_error))
diff --git a/lib/spack/spack/test/spec_yaml.py b/lib/spack/spack/test/spec_yaml.py
index b1339b6da3..74c957827e 100644
--- a/lib/spack/spack/test/spec_yaml.py
+++ b/lib/spack/spack/test/spec_yaml.py
@@ -49,6 +49,12 @@ class SpecDagTest(MockPackagesTest):
self.check_yaml_round_trip(spec)
+ def test_ambiguous_version_spec(self):
+ spec = Spec('mpileaks@1.0:5.0,6.1,7.3+debug~opt')
+ spec.normalize()
+ self.check_yaml_round_trip(spec)
+
+
def test_concrete_spec(self):
spec = Spec('mpileaks+debug~opt')
spec.concretize()
diff --git a/lib/spack/spack/version.py b/lib/spack/spack/version.py
index 908577122a..61b1e328ce 100644
--- a/lib/spack/spack/version.py
+++ b/lib/spack/spack/version.py
@@ -592,7 +592,7 @@ class VersionList(object):
if self.concrete:
return { 'version' : str(self[0]) }
else:
- return { 'versions' : str(v) for v in self }
+ return { 'versions' : [str(v) for v in self] }
@staticmethod