Measure coverage for parallel processes

This commit is contained in:
Alexander Todorov 2018-02-15 14:46:37 +02:00 committed by Brian C. Lane
parent af8c193b52
commit 91cebe7b67
3 changed files with 23 additions and 4 deletions

View File

@ -1,4 +1,11 @@
# http://nedbatchelder.com/code/coverage/config.html
[run]
concurrency = multiprocessing
parallel = True
branch = True
[report]
include = src/*
[paths]
source = .

View File

@ -5,6 +5,8 @@ PKGNAME = lorax
VERSION = $(shell awk '/Version:/ { print $$2 }' $(PKGNAME).spec)
RELEASE = $(shell awk '/Release:/ { print $$2 }' $(PKGNAME).spec | sed -e 's|%.*$$||g')
TAG = lorax-$(VERSION)-$(RELEASE)
PW_DIR ?= $(shell pwd)
USER_SITE_PACKAGES ?= $(shell sudo $(PYTHON) -m site --user-site)
default: all
@ -28,11 +30,13 @@ check:
# /api/docs/ tests require we have the documentation already built
test: docs
@echo "*** Running tests ***"
sudo PYTHONPATH=$(PYTHONPATH):./src/ $(PYTHON) -m nose -v --with-coverage --cover-erase --cover-branches \
--cover-package=pylorax --cover-inclusive \
./src/pylorax/ ./tests/pylorax/
sudo mkdir -p $(USER_SITE_PACKAGES)
sudo cp ./tests/usercustomize.py $(USER_SITE_PACKAGES)
sudo COVERAGE_PROCESS_START=$(PW_DIR)/.coveragerc PYTHONPATH=$(PYTHONPATH):./src/ \
$(PYTHON) -m nose -v ./src/pylorax/ ./tests/pylorax/
sudo rm -rf $(USER_SITE_PACKAGES)
coverage combine
coverage report -m
[ -f "/usr/bin/coveralls" ] && [ -n "$(COVERALLS_REPO_TOKEN)" ] && coveralls || echo

8
tests/usercustomize.py Normal file
View File

@ -0,0 +1,8 @@
# Enable Python coverage for subprocesses. See:
# http://nedbatchelder.com/code/coverage/subprocess.html
try:
import coverage
coverage.process_startup()
except ImportError:
pass