Skip to content

Commit

Permalink
Merge pull request #4678 from jenshnielsen/tst_coveralls
Browse files Browse the repository at this point in the history
TST: Enable coveralls/codecov code coverage
  • Loading branch information
tacaswell committed Nov 16, 2015
2 parents 6dd4103 + 8f3dccb commit ab100f4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[run]
source=matplotlib
[report]
omit =
lib/matplotlib/tests/*
lib/matplotlib/testing/*

exclude_lines =
raise NotImplemented
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@ result_images

*.swp
setup.cfg

# Coverage generated files #
############################

.coverage
.coverage.*
cover/
19 changes: 11 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ env:
- PANDAS=
- NPROC=2
- TEST_ARGS=--no-pep8
- NOSE_ARGS="--processes=$NPROC --process-timeout=300"

language: python

Expand All @@ -38,7 +39,7 @@ matrix:
env: MOCK=mock NUMPY=numpy==1.6
- python: 3.4
- python: 3.5
env: PANDAS=pandas
env: PANDAS=pandas NOSE_ARGS=--with-coverage
- python: 3.5
env: TEST_ARGS=--pep8
- python: 2.7
Expand Down Expand Up @@ -67,19 +68,17 @@ install:
pip install $PRE python-dateutil $NUMPY pyparsing!=2.0.4 pillow sphinx!=1.3.0;
fi
# Always install from pypi
- pip install $PRE pep8 cycler
- 'pip install https://github.com/tacaswell/nose/zipball/mnt_py36_compat#egg=nose'
- pip install $PRE pep8 cycler coveralls coverage
- 'pip install git+https://github.com/jenshnielsen/nose.git@matplotlibnose'

# We manually install humor sans using the package from Ubuntu 14.10. Unfortunatly humor sans is not
# availible in the Ubuntu version used by Travis but we can manually install the deb from a later
# version since is it basically just a .ttf file
# The current Travis Ubuntu image is to old to search .local/share/fonts so we store fonts in .fonts

# We install ipython to use the console highlighting. From IPython 3 this depends on jsonschema and mistune.
# Neihter is installed as a dependency of IPython since they are not used by the IPython console.
- |
if [[ $BUILD_DOCS == true ]]; then
pip install $PRE numpydoc ipython jsonschema mistune
pip install $PRE numpydoc ipython
pip install -q $PRE linkchecker
wget https://github.com/google/fonts/blob/master/ofl/felipa/Felipa-Regular.ttf?raw=true -O Felipa-Regular.ttf
wget http://mirrors.kernel.org/ubuntu/pool/universe/f/fonts-humor-sans/fonts-humor-sans_1.0-1_all.deb
Expand All @@ -94,17 +93,18 @@ install:
cp .travis/setup.cfg .
fi;
- python setup.py install
- pip install -e .

script:
# The number of processes is hardcoded, because using too many causes the
# Travis VM to run out of memory (since so many copies of inkscape and
# ghostscript are running at the same time).
- echo Testing using $NPROC processes
- echo The following args are passed to nose $NOSE_ARGS
- |
if [[ $BUILD_DOCS == false ]]; then
export MPL_REPO_DIR=$PWD # needed for pep8-conformance test of the examples
gdb -return-child-result -batch -ex r -ex bt --args python tests.py --processes=$NPROC --process-timeout=300 $TEST_ARGS
gdb -return-child-result -batch -ex r -ex bt --args python tests.py $NOSE_ARGS $TEST_ARGS
else
cd doc
python make.py html --small --warningsaserrors
Expand Down Expand Up @@ -165,3 +165,6 @@ after_success:
fi
fi
fi
if [[ $NOSE_ARGS="--with-coverage" ]]; then
coveralls
fi
14 changes: 13 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,14 @@ def _get_extra_test_plugins():
return [KnownFailure, attrib.Plugin]


def test(verbosity=1):
def _get_nose_env():
env = {'NOSE_COVER_PACKAGE': 'matplotlib',
'NOSE_COVER_HTML': 1,
'NOSE_COVER_NO_PRINT': 1}
return env


def test(verbosity=1, coverage=False):
"""run the matplotlib test suite"""
_init_tests()

Expand All @@ -1553,9 +1560,14 @@ def test(verbosity=1):
# a list.
multiprocess._instantiate_plugins = plugins

env = _get_nose_env()
if coverage:
env['NOSE_WITH_COVERAGE'] = 1

success = nose.run(
defaultTest=default_test_modules,
config=config,
env=env,
)
finally:
if old_backend.lower() != 'agg':
Expand Down
6 changes: 4 additions & 2 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
def run(extra_args):
from nose.plugins import multiprocess

env = matplotlib._get_nose_env()

matplotlib._init_tests()

# Nose doesn't automatically instantiate all of the plugins in the
Expand All @@ -33,8 +35,8 @@ def run(extra_args):

nose.main(addplugins=[x() for x in plugins],
defaultTest=default_test_modules,
argv=sys.argv + extra_args)

argv=sys.argv + extra_args,
env=env)

if __name__ == '__main__':
extra_args = []
Expand Down

0 comments on commit ab100f4

Please sign in to comment.