Tristan Van Berkom pushed to branch master at BuildStream / buildstream
Commits:
- 
f29a0995
by Tristan Van Berkom at 2019-01-09T19:51:14Z
 - 
d364ad02
by Tristan Van Berkom at 2019-01-09T19:52:22Z
 - 
1e352434
by Tristan Van Berkom at 2019-01-09T20:36:06Z
 
5 changed files:
Changes:
| ... | ... | @@ -9,6 +9,8 @@ omit = | 
| 9 | 9 | 
   # Omit generated code
 | 
| 10 | 10 | 
   */buildstream/_protos/*
 | 
| 11 | 11 | 
   */.eggs/*
 | 
| 12 | 
+  # Omit .tox directory
 | 
|
| 13 | 
+  */.tox/*
 | 
|
| 12 | 14 | 
 | 
| 13 | 15 | 
 [report]
 | 
| 14 | 16 | 
 show_missing = True
 | 
| ... | ... | @@ -13,11 +13,12 @@ tests/**/*.pyc | 
| 13 | 13 | 
 integration-cache/
 | 
| 14 | 14 | 
 tmp
 | 
| 15 | 15 | 
 .coverage
 | 
| 16 | 
+.coverage-reports/
 | 
|
| 16 | 17 | 
 .coverage.*
 | 
| 17 | 18 | 
 .cache
 | 
| 18 | 19 | 
 .pytest_cache/
 | 
| 19 | 20 | 
 *.bst/
 | 
| 20 | 
-.tox
 | 
|
| 21 | 
+.tox/
 | 
|
| 21 | 22 | 
 | 
| 22 | 23 | 
 # Pycache, in case buildstream is ran directly from within the source
 | 
| 23 | 24 | 
 # tree
 | 
| ... | ... | @@ -13,6 +13,7 @@ variables: | 
| 13 | 13 | 
   PYTEST_ADDOPTS: "--color=yes"
 | 
| 14 | 14 | 
   INTEGRATION_CACHE: "${CI_PROJECT_DIR}/cache/integration-cache"
 | 
| 15 | 15 | 
   TEST_COMMAND: "tox -- --color=yes --integration"
 | 
| 16 | 
+  COVERAGE_PREFIX: "${CI_JOB_NAME}."
 | 
|
| 16 | 17 | 
 | 
| 17 | 18 | 
 | 
| 18 | 19 | 
 #####################################################
 | 
| ... | ... | @@ -24,9 +25,6 @@ variables: | 
| 24 | 25 | 
 .tests-template: &tests
 | 
| 25 | 26 | 
   stage: test
 | 
| 26 | 27 | 
 | 
| 27 | 
-  variables:
 | 
|
| 28 | 
-    COVERAGE_DIR: coverage-linux
 | 
|
| 29 | 
-  | 
|
| 30 | 28 | 
   before_script:
 | 
| 31 | 29 | 
   # Diagnostics
 | 
| 32 | 30 | 
   - mount
 | 
| ... | ... | @@ -40,14 +38,11 @@ variables: | 
| 40 | 38 | 
   - su buildstream -c "${TEST_COMMAND}"
 | 
| 41 | 39 | 
 | 
| 42 | 40 | 
   after_script:
 | 
| 43 | 
-  # Collect our reports
 | 
|
| 44 | 
-  - mkdir -p ${COVERAGE_DIR}
 | 
|
| 45 | 
-  - cp .coverage ${COVERAGE_DIR}/coverage."${CI_JOB_NAME}"
 | 
|
| 46 | 41 | 
   except:
 | 
| 47 | 42 | 
   - schedules
 | 
| 48 | 43 | 
   artifacts:
 | 
| 49 | 44 | 
     paths:
 | 
| 50 | 
-    - ${COVERAGE_DIR}
 | 
|
| 45 | 
+    - .coverage-reports
 | 
|
| 51 | 46 | 
 | 
| 52 | 47 | 
 tests-debian-9:
 | 
| 53 | 48 | 
   image: buildstream/testsuite-debian:9-5da27168-32c47d1c
 | 
| ... | ... | @@ -83,7 +78,6 @@ tests-unix: | 
| 83 | 78 | 
   <<: *tests
 | 
| 84 | 79 | 
   variables:
 | 
| 85 | 80 | 
     BST_FORCE_BACKEND: "unix"
 | 
| 86 | 
-    COVERAGE_DIR: coverage-unix
 | 
|
| 87 | 81 | 
 | 
| 88 | 82 | 
   script:
 | 
| 89 | 83 | 
 | 
| ... | ... | @@ -239,22 +233,22 @@ coverage: | 
| 239 | 233 | 
   stage: post
 | 
| 240 | 234 | 
   coverage: '/TOTAL +\d+ +\d+ +(\d+\.\d+)%/'
 | 
| 241 | 235 | 
   script:
 | 
| 242 | 
-    - pip3 install -r requirements/requirements.txt -r requirements/dev-requirements.txt
 | 
|
| 243 | 
-    - pip3 install --no-index .
 | 
|
| 244 | 
-    - mkdir report
 | 
|
| 245 | 
-    - cd report
 | 
|
| 246 | 
-    - cp ../coverage-unix/coverage.* .
 | 
|
| 247 | 
-    - cp ../coverage-linux/coverage.* .
 | 
|
| 248 | 
-    - ls coverage.*
 | 
|
| 249 | 
-    - coverage combine --rcfile=../.coveragerc -a coverage.*
 | 
|
| 250 | 
-    - coverage report --rcfile=../.coveragerc -m
 | 
|
| 236 | 
+    - cp -a .coverage-reports/ ./coverage-sources
 | 
|
| 237 | 
+    - tox -e coverage
 | 
|
| 238 | 
+    - cp -a .coverage-reports/ ./coverage-report
 | 
|
| 251 | 239 | 
   dependencies:
 | 
| 252 | 240 | 
   - tests-debian-9
 | 
| 253 | 241 | 
   - tests-fedora-27
 | 
| 254 | 242 | 
   - tests-fedora-28
 | 
| 243 | 
+  - tests-fedora-missing-deps
 | 
|
| 244 | 
+  - tests-ubuntu-18.04
 | 
|
| 255 | 245 | 
   - tests-unix
 | 
| 256 | 246 | 
   except:
 | 
| 257 | 247 | 
   - schedules
 | 
| 248 | 
+  artifacts:
 | 
|
| 249 | 
+    paths:
 | 
|
| 250 | 
+    - coverage-sources/
 | 
|
| 251 | 
+    - coverage-report/
 | 
|
| 258 | 252 | 
 | 
| 259 | 253 | 
 # Deploy, only for merges which land on master branch.
 | 
| 260 | 254 | 
 #
 | 
| ... | ... | @@ -1498,6 +1498,13 @@ option when running tox:: | 
| 1498 | 1498 | 
 | 
| 1499 | 1499 | 
   tox -e py37
 | 
| 1500 | 1500 | 
 | 
| 1501 | 
+If you would like to test and lint at the same time, or if you do have multiple
 | 
|
| 1502 | 
+python versions installed and would like to test against multiple versions, then
 | 
|
| 1503 | 
+we recommend using `detox <https://github.com/tox-dev/detox>`_, just run it with
 | 
|
| 1504 | 
+the same arguments you would give `tox`::
 | 
|
| 1505 | 
+  | 
|
| 1506 | 
+  detox -e lint,py36,py37
 | 
|
| 1507 | 
+  | 
|
| 1501 | 1508 | 
 Linting is performed separately from testing. In order to run the linting step which
 | 
| 1502 | 1509 | 
 consists of running the ``pycodestyle`` and ``pylint`` tools, run the following::
 | 
| 1503 | 1510 | 
 | 
| ... | ... | @@ -1574,6 +1581,19 @@ can run ``tox`` with ``-r`` or ``--recreate`` option. | 
| 1574 | 1581 | 
      ./setup.py test --addopts 'tests/frontend/buildtrack.py::test_build_track'
 | 
| 1575 | 1582 | 
 | 
| 1576 | 1583 | 
 | 
| 1584 | 
+Observing coverage
 | 
|
| 1585 | 
+~~~~~~~~~~~~~~~~~~
 | 
|
| 1586 | 
+Once you have run the tests using `tox` (or `detox`), some coverage reports will
 | 
|
| 1587 | 
+have been left behind.
 | 
|
| 1588 | 
+  | 
|
| 1589 | 
+To view the coverage report of the last test run, simply run::
 | 
|
| 1590 | 
+  | 
|
| 1591 | 
+  tox -e coverage
 | 
|
| 1592 | 
+  | 
|
| 1593 | 
+This will collate any reports from separate python environments that may be
 | 
|
| 1594 | 
+under test before displaying the combined coverage.
 | 
|
| 1595 | 
+  | 
|
| 1596 | 
+  | 
|
| 1577 | 1597 | 
 Adding tests
 | 
| 1578 | 1598 | 
 ~~~~~~~~~~~~
 | 
| 1579 | 1599 | 
 Tests are found in the tests subdirectory, inside of which
 | 
| 1 | 
+#
 | 
|
| 2 | 
+# Tox global configuration
 | 
|
| 3 | 
+#
 | 
|
| 1 | 4 | 
 [tox]
 | 
| 2 | 5 | 
 envlist = py35,py36,py37
 | 
| 3 | 6 | 
 skip_missing_interpreters = true
 | 
| 4 | 7 | 
 | 
| 8 | 
+#
 | 
|
| 9 | 
+# Defaults for all environments
 | 
|
| 10 | 
+#
 | 
|
| 11 | 
+# Anything specified here is iherited by the sections
 | 
|
| 12 | 
+#
 | 
|
| 5 | 13 | 
 [testenv]
 | 
| 6 | 
-commands = pytest {posargs}
 | 
|
| 14 | 
+commands =
 | 
|
| 15 | 
+    pytest --basetemp {envtmpdir} {posargs}
 | 
|
| 16 | 
+    mkdir -p .coverage-reports
 | 
|
| 17 | 
+    mv {envtmpdir}/.coverage {toxinidir}/.coverage-reports/.coverage.{env:COVERAGE_PREFIX:}{envname}
 | 
|
| 7 | 18 | 
 deps =
 | 
| 8 | 19 | 
     -rrequirements/requirements.txt
 | 
| 9 | 20 | 
     -rrequirements/dev-requirements.txt
 | 
| ... | ... | @@ -13,6 +24,32 @@ passenv = | 
| 13 | 24 | 
     GI_TYPELIB_PATH
 | 
| 14 | 25 | 
     INTEGRATION_CACHE
 | 
| 15 | 26 | 
 | 
| 27 | 
+#
 | 
|
| 28 | 
+# These keys are not inherited by any other sections
 | 
|
| 29 | 
+#
 | 
|
| 30 | 
+setenv =
 | 
|
| 31 | 
+    py{35,36,37}: COVERAGE_FILE = {envtmpdir}/.coverage
 | 
|
| 32 | 
+whitelist_externals =
 | 
|
| 33 | 
+    py{35,36,37}:
 | 
|
| 34 | 
+        mv
 | 
|
| 35 | 
+        mkdir
 | 
|
| 36 | 
+  | 
|
| 37 | 
+#
 | 
|
| 38 | 
+# Coverage reporting
 | 
|
| 39 | 
+#
 | 
|
| 40 | 
+[testenv:coverage]
 | 
|
| 41 | 
+commands =
 | 
|
| 42 | 
+    - coverage combine --rcfile={toxinidir}/.coveragerc {toxinidir}/.coverage-reports/
 | 
|
| 43 | 
+    coverage report --rcfile={toxinidir}/.coveragerc -m
 | 
|
| 44 | 
+deps =
 | 
|
| 45 | 
+    -rrequirements/requirements.txt
 | 
|
| 46 | 
+    -rrequirements/dev-requirements.txt
 | 
|
| 47 | 
+setenv =
 | 
|
| 48 | 
+    COVERAGE_FILE = {toxinidir}/.coverage-reports/.coverage
 | 
|
| 49 | 
+  | 
|
| 50 | 
+#
 | 
|
| 51 | 
+# Running linters
 | 
|
| 52 | 
+#
 | 
|
| 16 | 53 | 
 [testenv:lint]
 | 
| 17 | 54 | 
 commands =
 | 
| 18 | 55 | 
     pycodestyle
 | 
| ... | ... | @@ -22,6 +59,9 @@ deps = | 
| 22 | 59 | 
     -rrequirements/dev-requirements.txt
 | 
| 23 | 60 | 
     -rrequirements/plugin-requirements.txt
 | 
| 24 | 61 | 
 | 
| 62 | 
+#
 | 
|
| 63 | 
+# Building documentation
 | 
|
| 64 | 
+#
 | 
|
| 25 | 65 | 
 [testenv:docs]
 | 
| 26 | 66 | 
 commands =
 | 
| 27 | 67 | 
     make -C doc
 | 
