From e5cf5508242c9b1d2bfec19478e5cdfe3c2e02fc Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 22 Apr 2015 01:26:10 -0400 Subject: [PATCH 01/14] TST : enable coveralls - also update nose --- .coveragerc | 10 ++++++++++ .travis.yml | 3 ++- tests.py | 8 ++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000000..c4477f170148 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,10 @@ +[run] +source=matplotlib +[report] +omit = + */python?.?/* + */site-packages/nose/* + *test* + +exclude_lines = + raise NotImplemented diff --git a/.travis.yml b/.travis.yml index 47931f7680ff..825a2be6d8b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,7 +67,7 @@ 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 $PRE pep8 cycler coveralls coverage - 'pip install https://github.com/tacaswell/nose/zipball/mnt_py36_compat#egg=nose' # We manually install humor sans using the package from Ubuntu 14.10. Unfortunatly humor sans is not @@ -165,3 +165,4 @@ after_success: fi fi fi + coveralls diff --git a/tests.py b/tests.py index 529dbe70d112..a0a428d22660 100755 --- a/tests.py +++ b/tests.py @@ -23,6 +23,10 @@ def run(extra_args): from nose.plugins import multiprocess + env = {"NOSE_WITH_COVERAGE": 1, + 'NOSE_COVER_PACKAGE': 'matplotlib', + 'NOSE_COVER_HTML': 1} + matplotlib._init_tests() # Nose doesn't automatically instantiate all of the plugins in the @@ -33,8 +37,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 = [] From 38e559b95cf351d010180afd6cf657dc75266abb Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sun, 3 May 2015 13:32:28 -0400 Subject: [PATCH 02/14] TST : move coverage output where coveralls expects We run tests out-of-repo which is to ensure that we pick up the installed version of mpl, not version which happens to be in the current directory (but I am not sure we strictly need this any more now that absolute imports are a thing). The coveralls scripts assume that you are running your tests _in_ the repo and are trying to extract git information from the directory they are run in, hence are failing for everything but the doc builds (which don't run nose so have no coverage). This exclude the doc build from uploading to coveralls and moves the cover output to be where coveralls expects it to be (and cds back into the repo). --- .travis.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 825a2be6d8b5..5190821a2878 100644 --- a/.travis.yml +++ b/.travis.yml @@ -165,4 +165,10 @@ after_success: fi fi fi - coveralls + if [[ $BUILD_DOCS == false ]]; then + # account for us running the test out-of-repo and coveralls expects in-repo + # tests + mv cover .coverage ../matplotlib + cd ../matplotlib + coveralls + fi From 2f19ca08cf7f2dc9ca25e65abbf5fa0d4bb14a60 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sun, 3 May 2015 14:00:35 -0400 Subject: [PATCH 03/14] TST : don't upload pep8 test to coveralls --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5190821a2878..079ae3265fd9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -165,7 +165,7 @@ after_success: fi fi fi - if [[ $BUILD_DOCS == false ]]; then + if [[ $BUILD_DOCS == false && $TEST_ARGS != "--pep8" ]]; then # account for us running the test out-of-repo and coveralls expects in-repo # tests mv cover .coverage ../matplotlib From f8c7152ba0d363cb2cd0635093e44c74f6b9cf79 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sun, 3 May 2015 14:25:28 -0400 Subject: [PATCH 04/14] MNT : add coverage output to .gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 722a42ec6185..2b7d5ec615c7 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,10 @@ result_images *.swp setup.cfg + +# Coverage generated files # +############################ + +.coverage +.coverage.* +cover/ From afd250c4373c7d6fac6e33a486d7568da062a6d6 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sun, 3 May 2015 15:19:12 -0400 Subject: [PATCH 05/14] TST : tweak cover report filters --- .coveragerc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.coveragerc b/.coveragerc index c4477f170148..91a75b3541f8 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,10 +1,6 @@ [run] source=matplotlib [report] -omit = - */python?.?/* - */site-packages/nose/* - *test* exclude_lines = raise NotImplemented From b824add5d8bad73e70d50bb52b8df7181a478c7c Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sun, 3 May 2015 15:37:46 -0400 Subject: [PATCH 06/14] TST : don't report coverage on testing code --- .coveragerc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.coveragerc b/.coveragerc index 91a75b3541f8..00174e3e6c2a 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,9 @@ [run] source=matplotlib [report] +omit = + matplotlib/tests/* + matplotlib/testing/* exclude_lines = raise NotImplemented From 33757bac54fb2c798349cfdfe1bc5a3def51c625 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sun, 12 Jul 2015 23:27:31 -0500 Subject: [PATCH 07/14] use pip install -e --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 079ae3265fd9..80f4f513896c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,7 +94,7 @@ 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 @@ -168,7 +168,5 @@ after_success: if [[ $BUILD_DOCS == false && $TEST_ARGS != "--pep8" ]]; then # account for us running the test out-of-repo and coveralls expects in-repo # tests - mv cover .coverage ../matplotlib - cd ../matplotlib coveralls fi From 58069962b44a81c5077966465115c2273b52e9c5 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Tue, 3 Nov 2015 13:50:23 +0000 Subject: [PATCH 08/14] No longer need to install mistune and jsonschema --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 80f4f513896c..c63ddaa35cd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,11 +75,9 @@ install: # 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 From 530d26af1d70fe034646a185ce9f6adabaa4ac13 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Fri, 13 Nov 2015 07:53:13 +0000 Subject: [PATCH 09/14] Install my fork of nose with support for suppressing output from cover --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c63ddaa35cd5..1e082bf908ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,7 +68,7 @@ install: fi # Always install from pypi - pip install $PRE pep8 cycler coveralls coverage - - 'pip install https://github.com/tacaswell/nose/zipball/mnt_py36_compat#egg=nose' + - '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 From 64ee6ce6d4412fab07888e36b184ef2fd9782fdc Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Fri, 13 Nov 2015 07:55:59 +0000 Subject: [PATCH 10/14] Suppress output from cover to stdout --- tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests.py b/tests.py index a0a428d22660..57b243493f0e 100755 --- a/tests.py +++ b/tests.py @@ -25,7 +25,8 @@ def run(extra_args): env = {"NOSE_WITH_COVERAGE": 1, 'NOSE_COVER_PACKAGE': 'matplotlib', - 'NOSE_COVER_HTML': 1} + 'NOSE_COVER_HTML': 1, + 'NOSE_COVER_NO_PRINT': 1} matplotlib._init_tests() From 48b9250d5293ec7e70d14c6e61dfe7a829dd737d Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sun, 15 Nov 2015 08:56:40 +0000 Subject: [PATCH 11/14] Correct path to excluded files --- .coveragerc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.coveragerc b/.coveragerc index 00174e3e6c2a..4be9bb19b03c 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,8 +2,8 @@ source=matplotlib [report] omit = - matplotlib/tests/* - matplotlib/testing/* + lib/matplotlib/tests/* + lib/matplotlib/testing/* exclude_lines = raise NotImplemented From 2ce262e03bfe0749a3f531fe9c1576e3f5698fe4 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sun, 15 Nov 2015 12:25:18 +0000 Subject: [PATCH 12/14] Run coverage only when activated Run one of the jobs without multiprocesses and run coverage with this. The covarage plugin does not work well with multiprocessing --- .travis.yml | 9 ++++----- lib/matplotlib/__init__.py | 7 +++++++ tests.py | 5 +---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1e082bf908ee..fcfe1f721a49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ env: - PANDAS= - NPROC=2 - TEST_ARGS=--no-pep8 + - NOSE_ARGS="--processes=$NPROC --process-timeout=300" language: python @@ -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 @@ -102,7 +103,7 @@ script: - | 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 @@ -163,8 +164,6 @@ after_success: fi fi fi - if [[ $BUILD_DOCS == false && $TEST_ARGS != "--pep8" ]]; then - # account for us running the test out-of-repo and coveralls expects in-repo - # tests + if [[ $NOSE_ARGS="--with-coverage" ]]; then coveralls fi diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index c81cc8106a53..f9b2cb757683 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1529,6 +1529,13 @@ def _get_extra_test_plugins(): return [KnownFailure, attrib.Plugin] +def _get_nose_env(): + env = {'NOSE_COVER_PACKAGE': 'matplotlib', + 'NOSE_COVER_HTML': 1, + 'NOSE_COVER_NO_PRINT': 1} + return env + + def test(verbosity=1): """run the matplotlib test suite""" _init_tests() diff --git a/tests.py b/tests.py index 57b243493f0e..87a6f8ba6601 100755 --- a/tests.py +++ b/tests.py @@ -23,10 +23,7 @@ def run(extra_args): from nose.plugins import multiprocess - env = {"NOSE_WITH_COVERAGE": 1, - 'NOSE_COVER_PACKAGE': 'matplotlib', - 'NOSE_COVER_HTML': 1, - 'NOSE_COVER_NO_PRINT': 1} + env = matplotlib._get_nose_env() matplotlib._init_tests() From 6fa4a76918e600b01b1bab56657c8422f6779a2e Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sun, 15 Nov 2015 12:43:49 +0000 Subject: [PATCH 13/14] Add debug output --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index fcfe1f721a49..b749e95781ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -100,6 +100,7 @@ script: # 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 From 8f3dccb95330891d6d735bf1daf3a30b0dc67234 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Sun, 15 Nov 2015 14:05:16 +0000 Subject: [PATCH 14/14] Make it possible to toggle coverage from matplotlib.test() --- lib/matplotlib/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index f9b2cb757683..a19dd3c807db 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1536,7 +1536,7 @@ def _get_nose_env(): return env -def test(verbosity=1): +def test(verbosity=1, coverage=False): """run the matplotlib test suite""" _init_tests() @@ -1560,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':