X Tutup
Skip to content

Commit a5700a8

Browse files
authored
Use codecov for coverage instead of coveralls (spack#2933)
* Switch from coveralls to codecov - Add .codecov.yml, simplify .travis.yml - Add codecov badge to README.md * Add tests for spack graph.
1 parent f59011f commit a5700a8

File tree

5 files changed

+176
-33
lines changed

5 files changed

+176
-33
lines changed

.codecov.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
coverage:
2+
precision: 2
3+
round: nearest
4+
range: 60...100
5+
6+
ignore:
7+
- lib/spack/spack/test/.*
8+
- lib/spack/env/.*
9+
- lib/spack/docs/.*
10+
- lib/spack/external/.*

.travis.yml

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#=============================================================================
22
# Project settings
33
#=============================================================================
4-
language: python
5-
64
# Only build master and develop on push; do not build every branch.
75
branches:
86
only:
@@ -13,29 +11,27 @@ branches:
1311
#=============================================================================
1412
# Build matrix
1513
#=============================================================================
16-
python:
17-
- 2.6
18-
- 2.7
19-
20-
env:
21-
- TEST_SUITE=unit
22-
- TEST_SUITE=flake8
23-
- TEST_SUITE=doc
24-
2514
matrix:
26-
# Flake8 and Sphinx no longer support Python 2.6, and one run is enough.
27-
exclude:
28-
- python: 2.6
29-
env: TEST_SUITE=flake8
30-
- python: 2.6
31-
env: TEST_SUITE=doc
32-
# Explicitly include an OS X build with homebrew's python.
33-
# Works around Python issues on Travis for OSX, described here:
34-
# http://blog.fizyk.net.pl/blog/running-python-tests-on-traviss-osx-workers.html
3515
include:
36-
- os: osx
37-
language: generic
38-
env: TEST_SUITE=unit
16+
- python: '2.6'
17+
os: linux
18+
language: python
19+
env: TEST_SUITE=unit
20+
- python: '2.7'
21+
os: linux
22+
language: python
23+
env: TEST_SUITE=unit
24+
- python: '2.7'
25+
os: linux
26+
language: python
27+
env: TEST_SUITE=flake8
28+
- python: '2.7'
29+
os: linux
30+
language: python
31+
env: TEST_SUITE=doc
32+
- os: osx
33+
language: generic
34+
env: [ TEST_SUITE=unit, PYTHON_VERSION=2.7 ]
3935

4036
#=============================================================================
4137
# Environment
@@ -61,7 +57,7 @@ before_install:
6157

6258
# Install various dependencies
6359
install:
64-
- pip install --upgrade coveralls
60+
- pip install --upgrade codecov
6561
- pip install --upgrade flake8
6662
- pip install --upgrade sphinx
6763
- pip install --upgrade mercurial
@@ -80,7 +76,7 @@ before_script:
8076
script: share/spack/qa/run-$TEST_SUITE-tests
8177

8278
after_success:
83-
- if [[ $TEST_SUITE == unit && $TRAVIS_PYTHON_VERSION == 2.7 && $TRAVIS_OS_NAME == "linux" ]]; then coveralls; fi
79+
- if [[ $TEST_SUITE == unit && $TRAVIS_PYTHON_VERSION == 2.7 && $TRAVIS_OS_NAME == "linux" ]]; then codecov --env PY_VERSION; fi
8480

8581
#=============================================================================
8682
# Notifications

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
============
33

44
[![Build Status](https://travis-ci.org/LLNL/spack.svg?branch=develop)](https://travis-ci.org/LLNL/spack)
5-
[![Coverage Status](https://coveralls.io/repos/github/LLNL/spack/badge.svg?branch=develop)](https://coveralls.io/github/LLNL/spack?branch=develop)
5+
[![codecov](https://codecov.io/gh/LLNL/spack/branch/develop/graph/badge.svg)](https://codecov.io/gh/LLNL/spack)
66

77
Spack is a package management tool designed to support multiple
88
versions and configurations of software on a wide variety of platforms

lib/spack/spack/graph.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class AsciiGraph(object):
138138
def __init__(self):
139139
# These can be set after initialization or after a call to
140140
# graph() to change behavior.
141-
self.node_character = '*'
141+
self.node_character = 'o'
142142
self.debug = False
143143
self.indent = 0
144144
self.deptype = alldeps
@@ -364,7 +364,7 @@ def _expand_right_line(self, index):
364364
self._set_state(EXPAND_RIGHT, index)
365365
self._out.write("\n")
366366

367-
def write(self, spec, **kwargs):
367+
def write(self, spec, color=None, out=None):
368368
"""Write out an ascii graph of the provided spec.
369369
370370
Arguments:
@@ -378,14 +378,13 @@ def write(self, spec, **kwargs):
378378
based on output file.
379379
380380
"""
381-
out = kwargs.get('out', None)
382-
if not out:
381+
if out is None:
383382
out = sys.stdout
384383

385-
color = kwargs.get('color', None)
386-
if not color:
384+
if color is None:
387385
color = out.isatty()
388-
self._out = ColorStream(sys.stdout, color=color)
386+
387+
self._out = ColorStream(out, color=color)
389388

390389
# We'll traverse the spec in topo order as we graph it.
391390
topo_order = topological_sort(spec, reverse=True, deptype=self.deptype)

lib/spack/spack/test/graph.py

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
##############################################################################
2+
# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
3+
# Produced at the Lawrence Livermore National Laboratory.
4+
#
5+
# This file is part of Spack.
6+
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
7+
# LLNL-CODE-647188
8+
#
9+
# For details, see https://github.com/llnl/spack
10+
# Please also see the LICENSE file for our notice and the LGPL.
11+
#
12+
# This program is free software; you can redistribute it and/or modify
13+
# it under the terms of the GNU Lesser General Public License (as
14+
# published by the Free Software Foundation) version 2.1, February 1999.
15+
#
16+
# This program is distributed in the hope that it will be useful, but
17+
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
18+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
19+
# conditions of the GNU Lesser General Public License for more details.
20+
#
21+
# You should have received a copy of the GNU Lesser General Public
22+
# License along with this program; if not, write to the Free Software
23+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24+
##############################################################################
25+
from StringIO import StringIO
26+
27+
from spack.spec import Spec
28+
from spack.graph import AsciiGraph, topological_sort, graph_dot
29+
30+
31+
def test_topo_sort(builtin_mock):
32+
"""Test topo sort gives correct order."""
33+
s = Spec('mpileaks').normalized()
34+
35+
topo = topological_sort(s)
36+
37+
assert topo.index('mpileaks') < topo.index('callpath')
38+
assert topo.index('mpileaks') < topo.index('mpi')
39+
assert topo.index('mpileaks') < topo.index('dyninst')
40+
assert topo.index('mpileaks') < topo.index('libdwarf')
41+
assert topo.index('mpileaks') < topo.index('libelf')
42+
43+
assert topo.index('callpath') < topo.index('mpi')
44+
assert topo.index('callpath') < topo.index('dyninst')
45+
assert topo.index('callpath') < topo.index('libdwarf')
46+
assert topo.index('callpath') < topo.index('libelf')
47+
48+
assert topo.index('dyninst') < topo.index('libdwarf')
49+
assert topo.index('dyninst') < topo.index('libelf')
50+
51+
assert topo.index('libdwarf') < topo.index('libelf')
52+
53+
54+
def test_static_graph_mpileaks(builtin_mock):
55+
"""Test a static spack graph for a simple package."""
56+
s = Spec('mpileaks').normalized()
57+
58+
stream = StringIO()
59+
graph_dot([s], static=True, out=stream)
60+
61+
dot = stream.getvalue()
62+
63+
assert ' "mpileaks" [label="mpileaks"]\n' in dot
64+
assert ' "dyninst" [label="dyninst"]\n' in dot
65+
assert ' "callpath" [label="callpath"]\n' in dot
66+
assert ' "libelf" [label="libelf"]\n' in dot
67+
assert ' "libdwarf" [label="libdwarf"]\n' in dot
68+
69+
assert ' "dyninst" -> "libdwarf"\n' in dot
70+
assert ' "callpath" -> "dyninst"\n' in dot
71+
assert ' "mpileaks" -> "mpi"\n' in dot
72+
assert ' "libdwarf" -> "libelf"\n' in dot
73+
assert ' "callpath" -> "mpi"\n' in dot
74+
assert ' "mpileaks" -> "callpath"\n' in dot
75+
assert ' "dyninst" -> "libelf"\n' in dot
76+
77+
78+
def test_dynamic_dot_graph_mpileaks(builtin_mock):
79+
"""Test dynamically graphing the mpileaks package."""
80+
s = Spec('mpileaks').normalized()
81+
82+
stream = StringIO()
83+
graph_dot([s], static=False, out=stream)
84+
85+
dot = stream.getvalue()
86+
87+
mpileaks_hash, mpileaks_lbl = s.dag_hash(), s.format('$_$#')
88+
mpi_hash, mpi_lbl = s['mpi'].dag_hash(), s['mpi'].format('$_$#')
89+
callpath_hash, callpath_lbl = (
90+
s['callpath'].dag_hash(), s['callpath'].format('$_$#'))
91+
dyninst_hash, dyninst_lbl = (
92+
s['dyninst'].dag_hash(), s['dyninst'].format('$_$#'))
93+
libdwarf_hash, libdwarf_lbl = (
94+
s['libdwarf'].dag_hash(), s['libdwarf'].format('$_$#'))
95+
libelf_hash, libelf_lbl = (
96+
s['libelf'].dag_hash(), s['libelf'].format('$_$#'))
97+
98+
assert ' "%s" [label="%s"]\n' % (mpileaks_hash, mpileaks_lbl) in dot
99+
assert ' "%s" [label="%s"]\n' % (callpath_hash, callpath_lbl) in dot
100+
assert ' "%s" [label="%s"]\n' % (mpi_hash, mpi_lbl) in dot
101+
assert ' "%s" [label="%s"]\n' % (dyninst_hash, dyninst_lbl) in dot
102+
assert ' "%s" [label="%s"]\n' % (libdwarf_hash, libdwarf_lbl) in dot
103+
assert ' "%s" [label="%s"]\n' % (libelf_hash, libelf_lbl) in dot
104+
105+
assert ' "%s" -> "%s"\n' % (dyninst_hash, libdwarf_hash) in dot
106+
assert ' "%s" -> "%s"\n' % (callpath_hash, dyninst_hash) in dot
107+
assert ' "%s" -> "%s"\n' % (mpileaks_hash, mpi_hash) in dot
108+
assert ' "%s" -> "%s"\n' % (libdwarf_hash, libelf_hash) in dot
109+
assert ' "%s" -> "%s"\n' % (callpath_hash, mpi_hash) in dot
110+
assert ' "%s" -> "%s"\n' % (mpileaks_hash, callpath_hash) in dot
111+
assert ' "%s" -> "%s"\n' % (dyninst_hash, libelf_hash) in dot
112+
113+
114+
def test_ascii_graph_mpileaks(builtin_mock):
115+
"""Test dynamically graphing the mpileaks package."""
116+
s = Spec('mpileaks').normalized()
117+
118+
stream = StringIO()
119+
graph = AsciiGraph()
120+
graph.write(s, out=stream, color=False)
121+
string = stream.getvalue()
122+
123+
# Some lines in spack graph still have trailing space
124+
# TODO: fix this.
125+
string = '\n'.join([line.rstrip() for line in string.split('\n')])
126+
127+
assert string == r'''o mpileaks
128+
|\
129+
| o callpath
130+
|/|
131+
o | mpi
132+
/
133+
o dyninst
134+
|\
135+
| o libdwarf
136+
|/
137+
o libelf
138+
'''

0 commit comments

Comments
 (0)
X Tutup