Bugfixes for yaml specs.
This commit is contained in:
parent
d687962b74
commit
1d0975bac6
@ -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 @@
|
||||
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 @@ def from_yaml(string):
|
||||
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))
|
||||
|
@ -49,6 +49,12 @@ def test_normal_spec(self):
|
||||
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()
|
||||
|
@ -592,7 +592,7 @@ def to_dict(self):
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user