diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2015-05-05 13:07:02 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2015-05-05 13:18:44 -0700 |
commit | d687962b746c1b8e10789799ba20e1f2ea01407f (patch) | |
tree | 261c3354dbe48b0cf486960a80cd597fe4b55a51 | |
parent | 53e8e44a8b63e615b0d2baa74b4e51fc551365c1 (diff) | |
download | spack-d687962b746c1b8e10789799ba20e1f2ea01407f.tar.gz spack-d687962b746c1b8e10789799ba20e1f2ea01407f.tar.bz2 spack-d687962b746c1b8e10789799ba20e1f2ea01407f.tar.xz spack-d687962b746c1b8e10789799ba20e1f2ea01407f.zip |
Add test for YAML specs.
-rw-r--r-- | lib/spack/spack/test/__init__.py | 3 | ||||
-rw-r--r-- | lib/spack/spack/test/spec_yaml.py | 65 |
2 files changed, 67 insertions, 1 deletions
diff --git a/lib/spack/spack/test/__init__.py b/lib/spack/spack/test/__init__.py index c53e6774fc..77c8bd3191 100644 --- a/lib/spack/spack/test/__init__.py +++ b/lib/spack/spack/test/__init__.py @@ -52,7 +52,8 @@ test_names = ['versions', 'mirror', 'url_extrapolate', 'cc', - 'link_tree'] + 'link_tree', + 'spec_yaml'] def list_tests(): diff --git a/lib/spack/spack/test/spec_yaml.py b/lib/spack/spack/test/spec_yaml.py new file mode 100644 index 0000000000..b1339b6da3 --- /dev/null +++ b/lib/spack/spack/test/spec_yaml.py @@ -0,0 +1,65 @@ +############################################################################## +# Copyright (c) 2013-2015, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Written by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://scalability-llnl.github.io/spack +# Please also see the LICENSE file for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License (as published by +# the Free Software Foundation) version 2.1 dated February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## +"""Test YAML serialization for specs. + +YAML format preserves DAG informatoin in the spec. + +""" +from spack.spec import Spec +from spack.test.mock_packages_test import * + +class SpecDagTest(MockPackagesTest): + + def check_yaml_round_trip(self, spec): + yaml_text = spec.to_yaml() + spec_from_yaml = Spec.from_yaml(yaml_text) + self.assertTrue(spec.eq_dag(spec_from_yaml)) + + + def test_simple_spec(self): + spec = Spec('mpileaks') + self.check_yaml_round_trip(spec) + + + def test_normal_spec(self): + spec = Spec('mpileaks+debug~opt') + spec.normalize() + self.check_yaml_round_trip(spec) + + + def test_concrete_spec(self): + spec = Spec('mpileaks+debug~opt') + spec.concretize() + self.check_yaml_round_trip(spec) + + + def test_yaml_subdag(self): + spec = Spec('mpileaks^mpich+debug~opt') + spec.concretize() + + yaml_spec = Spec.from_yaml(spec.to_yaml()) + + for dep in ('callpath', 'mpich', 'dyninst', 'libdwarf', 'libelf'): + self.assertTrue(spec[dep].eq_dag(yaml_spec[dep])) |