summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Goins <paul.goins@canonical.com>2019-03-01 11:12:24 +0100
committerPaul Goins <paul.goins@canonical.com>2019-03-01 14:38:55 +0100
commit14507e4ea72c7729c019c652e9cab9ede61dcf15 (patch)
tree7a4d8b464645e2f4c95d8f77bf15041f9ee056b1
parenta39788cb95056c7ccb1cabf0f09a3a264ace3722 (diff)
Added tox environment for gathering coverage
This technique was borrowed from the tox "cover" environment in openstack/nova's tox.ini. This leverages the fact that stestr lets you override the python executable via the PYTHON environment variable. Doing this allows us to easily generate coverage for our unit tests. An important caveat is that this does not provide any coverage for tests via zaza, amulet, etc. It is purely focused on the unit tests. Note that this replaces the previous .coveragerc; coverage configuration is instead pulled from tox.ini. Change-Id: Iadfc6d9775269a9ede7bd35c5c455342696ffce9
Notes
Notes (review): Verified+1: Canonical CI <uosci-testing-bot@ubuntu.com> Code-Review+2: James Page <james.page@canonical.com> Workflow+1: James Page <james.page@canonical.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 04 Mar 2019 09:47:35 +0000 Reviewed-on: https://review.openstack.org/640303 Project: openstack/charm-cinder-backup Branch: refs/heads/master
-rw-r--r--.coveragerc6
-rw-r--r--.zuul.yaml1
-rw-r--r--tox.ini28
3 files changed, 29 insertions, 6 deletions
diff --git a/.coveragerc b/.coveragerc
deleted file mode 100644
index 3608a21..0000000
--- a/.coveragerc
+++ /dev/null
@@ -1,6 +0,0 @@
1[report]
2# Regexes for lines to exclude from consideration
3exclude_lines =
4 if __name__ == .__main__.:
5include=
6 hooks/cinder_*
diff --git a/.zuul.yaml b/.zuul.yaml
index 7051aee..dc27661 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -1,3 +1,4 @@
1- project: 1- project:
2 templates: 2 templates:
3 - python35-charm-jobs 3 - python35-charm-jobs
4 - openstack-cover-jobs
diff --git a/tox.ini b/tox.ini
index 1457901..7c2e71c 100644
--- a/tox.ini
+++ b/tox.ini
@@ -39,6 +39,34 @@ deps = -r{toxinidir}/requirements.txt
39commands = flake8 {posargs} hooks unit_tests tests actions lib 39commands = flake8 {posargs} hooks unit_tests tests actions lib
40 charm-proof 40 charm-proof
41 41
42[testenv:cover]
43# Technique based heavily upon
44# https://github.com/openstack/nova/blob/master/tox.ini
45basepython = python3
46deps = -r{toxinidir}/requirements.txt
47 -r{toxinidir}/test-requirements.txt
48setenv =
49 {[testenv]setenv}
50 PYTHON=coverage run
51commands =
52 coverage erase
53 ostestr {posargs}
54 coverage combine
55 coverage html -d cover
56 coverage xml -o cover/coverage.xml
57 coverage report
58
59[coverage:run]
60branch = True
61concurrency = multiprocessing
62parallel = True
63source =
64 .
65omit =
66 .tox/*
67 */charmhelpers/*
68 unit_tests/*
69
42[testenv:venv] 70[testenv:venv]
43basepython = python3 71basepython = python3
44commands = {posargs} 72commands = {posargs}