1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
##############################################################################
# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
#
# This file is part of Spack.
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
# LLNL-CODE-647188
#
# For details, see https://github.com/llnl/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 Lesser General Public License (as
# published by the Free Software Foundation) version 2.1, 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 Lesser 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
##############################################################################
from StringIO import StringIO
import unittest
import spack
from spack.spec import Spec
from spack.provider_index import ProviderIndex
from spack.test.mock_packages_test import *
# Test assume that mock packages provide this:
#
# {'blas': {
# blas: set([netlib-blas, openblas, openblas-with-lapack])},
# 'lapack': {lapack: set([netlib-lapack, openblas-with-lapack])},
# 'mpi': {mpi@:1: set([mpich@:1]),
# mpi@:2.0: set([mpich2]),
# mpi@:2.1: set([mpich2@1.1:]),
# mpi@:2.2: set([mpich2@1.2:]),
# mpi@:3: set([mpich@3:]),
# mpi@:10.0: set([zmpi])},
# 'stuff': {stuff: set([externalvirtual])}}
#
class ProviderIndexTest(MockPackagesTest):
def test_yaml_round_trip(self):
p = ProviderIndex(spack.repo.all_package_names())
ostream = StringIO()
p.to_yaml(ostream)
istream = StringIO(ostream.getvalue())
q = ProviderIndex.from_yaml(istream)
self.assertEqual(p, q)
def test_providers_for_simple(self):
p = ProviderIndex(spack.repo.all_package_names())
blas_providers = p.providers_for('blas')
self.assertTrue(Spec('netlib-blas') in blas_providers)
self.assertTrue(Spec('openblas') in blas_providers)
self.assertTrue(Spec('openblas-with-lapack') in blas_providers)
lapack_providers = p.providers_for('lapack')
self.assertTrue(Spec('netlib-lapack') in lapack_providers)
self.assertTrue(Spec('openblas-with-lapack') in lapack_providers)
def test_mpi_providers(self):
p = ProviderIndex(spack.repo.all_package_names())
mpi_2_providers = p.providers_for('mpi@2')
self.assertTrue(Spec('mpich2') in mpi_2_providers)
self.assertTrue(Spec('mpich@3:') in mpi_2_providers)
mpi_3_providers = p.providers_for('mpi@3')
self.assertTrue(Spec('mpich2') not in mpi_3_providers)
self.assertTrue(Spec('mpich@3:') in mpi_3_providers)
self.assertTrue(Spec('zmpi') in mpi_3_providers)
def test_equal(self):
p = ProviderIndex(spack.repo.all_package_names())
q = ProviderIndex(spack.repo.all_package_names())
self.assertEqual(p, q)
def test_copy(self):
p = ProviderIndex(spack.repo.all_package_names())
q = p.copy()
self.assertEqual(p, q)
def test_copy(self):
pass
|