From f475b92802530eb463ae5198135c844feb78a375 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Mon, 14 Mar 2016 15:09:30 -0400 Subject: [PATCH] Coverage tracking for the test suite. If you issue `make test`, it will run the tests and print out a coverage reporting indicating what lines of code were covered by the tests and which were not. This will (hopefully) be useful more over time as we start to write more tests. --- .coveragerc | 5 ++++ .gitignore | 1 + Makefile | 3 ++ tests/__init__.py | 0 tests/runtests.py | 32 --------------------- tests/{test___init__.py => test_parsers.py} | 0 6 files changed, 9 insertions(+), 32 deletions(-) create mode 100644 .coveragerc create mode 100644 tests/__init__.py delete mode 100755 tests/runtests.py rename tests/{test___init__.py => test_parsers.py} (100%) diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..087bddf2 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[run] + +omit = + /usr/lib/* + tests/* diff --git a/.gitignore b/.gitignore index 4857165f..846fc378 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.pyc *.pyo tests/test.py +.coverage diff --git a/Makefile b/Makefile index d5e9b776..d8f26585 100644 --- a/Makefile +++ b/Makefile @@ -63,6 +63,9 @@ clean: git-clean: @git clean -d -q -x +test: + nosetests --with-coverage --cover-package . + subdirs: for d in $(SUBDIRS); do make -C $$d; [ $$? = 0 ] || exit 1; done diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/runtests.py b/tests/runtests.py deleted file mode 100755 index 699e9e4e..00000000 --- a/tests/runtests.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/python - -"""Wrapper script for running unit tests""" - -__version__ = "$Revision: 1.1 $" - -import sys -import os -import os.path -import unittest - -testDir = os.path.dirname(sys.argv[0]) - -sys.path.insert(0, os.path.abspath('%s/..' % testDir)) - -allTests = unittest.TestSuite() -for root, dirs, files in os.walk(testDir): - common_path = os.path.commonprefix([os.path.abspath(testDir), - os.path.abspath(root)]) - root_path = os.path.abspath(root).replace(common_path, '').lstrip('/').replace('/', '.') - - for test_file in [item for item in files - if item.startswith("test_") and item.endswith(".py")]: - if len(sys.argv) == 1 or test_file in sys.argv[1:]: - print "adding %s..." % test_file - test_file = test_file[:-3] - if root_path: - test_file = "%s.%s" % (root_path, test_file) - suite = unittest.defaultTestLoader.loadTestsFromName(test_file) - allTests.addTests(suite._tests) - -unittest.TextTestRunner(verbosity=2).run(allTests) diff --git a/tests/test___init__.py b/tests/test_parsers.py similarity index 100% rename from tests/test___init__.py rename to tests/test_parsers.py