test(cover): Report coverage even on tests failure

Useful to compare coverage changes when running the full test suite under Python 3 while
porting.
This commit is contained in:
Ross Patterson 2020-09-27 13:43:41 -07:00
parent df69ca8b5b
commit a6c50160e3
2 changed files with 14 additions and 3 deletions

View File

@ -17,8 +17,10 @@ PYTHON=python
export PYTHON
PYFLAKES=flake8
export PYFLAKES
VIRTUAL_ENV=./.tox/py27
SOURCES=src/allmydata static misc setup.py
APPNAME=tahoe-lafs
TEST_SUITE=allmydata
# Top-level, phony targets
@ -31,6 +33,17 @@ default:
## Run all tests and code reports
test: .tox
tox -p auto
.PHONY: test-venv-coverage
## Run all tests with coverage collection and reporting.
test-venv-coverage:
# Special handling for reporting coverage even when the test run fails
test_exit=
$(VIRTUAL_ENV)/bin/coverage run -m twisted.trial --rterrors --reporter=timing \
$(TEST_SUITE) || test_exit="$$?"
$(VIRTUAL_ENV)/bin/coverage combine
$(VIRTUAL_ENV)/bin/coverage xml || true
$(VIRTUAL_ENV)/bin/coverage report
if [ ! -z "$$test_exit" ]; then exit "$$test_exit"; fi
# This is necessary only if you want to automatically produce a new
# _version.py file from the current git history (without doing a build).

View File

@ -64,9 +64,7 @@ commands =
# measuring coverage is somewhat slower than not measuring coverage
# so only do it on request.
coverage: coverage run -m twisted.trial {env:TAHOE_LAFS_TRIAL_ARGS:--rterrors --reporter=timing} {posargs:{env:TEST_SUITE}}
coverage: coverage combine
coverage: coverage xml
coverage: make -e TEST_SUITE={posargs:{env:TEST_SUITE}} test-venv-coverage
[testenv:integration]