From 6eee65d7249e6621ca834c3eed3ff72a9cbf6f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= Date: Fri, 27 Nov 2015 22:48:39 +0100 Subject: [PATCH] run-tests: add support for running under coverage.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- .coveragerc | 5 +++++ __root__/run-tests | 10 +++++++++- __root__/setup.py | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..17cfb43 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[run] +source = clufter + +[report] +show_missing = True diff --git a/__root__/run-tests b/__root__/run-tests index 7e9d527..8d01a13 100755 --- a/__root__/run-tests +++ b/__root__/run-tests @@ -25,7 +25,7 @@ TAIL='2>&1 | sed \ -e "s/^\(Ran [1-9][0-9]*.*\)/${cyan}\1${stop}/"' if ${PYTHONEXEC} -c "import sys; sys.exit(sys.version_info[:2] < (2,7))"; then - CMD="${PYTHONEXEC} -m unittest" + CMD="-m unittest" else # pre-2.7 unittest doesn't offer test discovery, use external unittest2 CMD="unit2" @@ -34,6 +34,7 @@ DEBUG="env LOGLEVEL=WARNING" PGR=${PAGER:-less} VERBOSE=1 RUNCHECK=1 +COVERAGE=0 ACC= while [ $# -gt 0 ]; do case "$1" in @@ -46,6 +47,9 @@ while [ $# -gt 0 ]; do done exit ${ret} ;; + -c) + COVERAGE=1 + ;; -d) DEBUG= ;; @@ -71,6 +75,10 @@ while [ $# -gt 0 ]; do shift done +[ "${COVERAGE}" -eq 0 ] || CMD="coverage2 run ${CMD}" +[[ ! "${CMD}" =~ ^-m ]] || CMD="${PYTHONEXEC} ${CMD}" + + # "--verbose" game because of "Alternative Usage: unit2 discover [options]" [ -n "${ACC}" ] \ && { RUNCHECK=0; [ "${VERBOSE}" -eq 0 ] || ACC="--verbose ${ACC}"; } \ diff --git a/__root__/setup.py b/__root__/setup.py index 8f67aab..7b0486f 100644 --- a/__root__/setup.py +++ b/__root__/setup.py @@ -681,7 +681,8 @@ def cond_require(package, *packages, **preferred): include_package_data=False, extras_require={ - 'test': cond_require('unittest2', unittest='runner') + 'test': cond_require('unittest2', unittest='runner'), + 'coverage': ('coverage', ), }, # TODO: uncomment this when ready for tests