Skip to content

Commit

Permalink
run-tests: add support for running under coverage.py
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Pokorný <[email protected]>
  • Loading branch information
jnpkrn committed Nov 27, 2015
1 parent 74fb0c6 commit 6eee65d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
source = clufter

[report]
show_missing = True
10 changes: 9 additions & 1 deletion __root__/run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -46,6 +47,9 @@ while [ $# -gt 0 ]; do
done
exit ${ret}
;;
-c)
COVERAGE=1
;;
-d)
DEBUG=
;;
Expand All @@ -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}"; } \
Expand Down
3 changes: 2 additions & 1 deletion __root__/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6eee65d

Please sign in to comment.