summaryrefslogtreecommitdiff
path: root/tox.ini
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-01-08 14:22:58 -0500
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-01-09 14:51:14 -0500
commitf29a099580cd311517701da4bd125fa83c193f66 (patch)
treea213ed0d239634fab2c28ea75bbbb2eaa287c1a1 /tox.ini
parented8bc5bc7c0882c67ac925e4b042996f983ba3a5 (diff)
downloadbuildstream-f29a099580cd311517701da4bd125fa83c193f66.tar.gz
Support running test environments in parallel with `detox`
This patch namespaces the test temp directory and the output coverage report file with the name of the environment under test, such that separately run tests do not access the same files. When running tests without tox, directly through setup.py, then the tmp directory will still be `./tmp`. * .gitignore: Added new .coverage-reports/ directory * .gitlab-ci.yml: Rely on tox to combine and report coverage, only tell tox about the COVERAGE_PREFIX so that results can be namespaced by CI job name. This change also publishes the sources and final combined `.coverage` file in an output gitlab artifact for inspection, and lists some missing dependencies to the `coverage` job. * tox.ini: Add comments and refactor main [testenv] section so that other environments dont inherit too much unrelated cruft. Generate the coverate reports in the respective {envtmpdir} so that all per-process coverage files are prefixed with a full path, ensuring that concurrent runs don't mix reports and addressing concerns raised in #844. Also implemented new `tox -e coverage` environment to combine any found coverage and print a report. * .coveragerc: Omit .tox/ directory from coverage stats Fixes issue #844
Diffstat (limited to 'tox.ini')
-rw-r--r--tox.ini42
1 files changed, 41 insertions, 1 deletions
diff --git a/tox.ini b/tox.ini
index 3b6496d3f..abc13d03a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,9 +1,20 @@
+#
+# Tox global configuration
+#
[tox]
envlist = py35,py36,py37
skip_missing_interpreters = true
+#
+# Defaults for all environments
+#
+# Anything specified here is iherited by the sections
+#
[testenv]
-commands = pytest {posargs}
+commands =
+ pytest --basetemp {envtmpdir} {posargs}
+ mkdir -p .coverage-reports
+ mv {envtmpdir}/.coverage {toxinidir}/.coverage-reports/.coverage.{env:COVERAGE_PREFIX:}{envname}
deps =
-rrequirements/requirements.txt
-rrequirements/dev-requirements.txt
@@ -13,6 +24,32 @@ passenv =
GI_TYPELIB_PATH
INTEGRATION_CACHE
+#
+# These keys are not inherited by any other sections
+#
+setenv =
+ py{35,36,37}: COVERAGE_FILE = {envtmpdir}/.coverage
+whitelist_externals =
+ py{35,36,37}:
+ mv
+ mkdir
+
+#
+# Coverage reporting
+#
+[testenv:coverage]
+commands =
+ - coverage combine --rcfile={toxinidir}/.coveragerc {toxinidir}/.coverage-reports/
+ coverage report --rcfile={toxinidir}/.coveragerc -m
+deps =
+ -rrequirements/requirements.txt
+ -rrequirements/dev-requirements.txt
+setenv =
+ COVERAGE_FILE = {toxinidir}/.coverage-reports/.coverage
+
+#
+# Running linters
+#
[testenv:lint]
commands =
pycodestyle
@@ -22,6 +59,9 @@ deps =
-rrequirements/dev-requirements.txt
-rrequirements/plugin-requirements.txt
+#
+# Building documentation
+#
[testenv:docs]
commands =
make -C doc