[Notes] [Git][BuildStream/buildstream][tristan/detox-tests] 2 commits: Support running test environments in parallel with `detox`



Title: GitLab

Tristan Van Berkom pushed to branch tristan/detox-tests at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • .gitignore
    ... ... @@ -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
    

  • .gitlab-ci.yml
    ... ... @@ -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
     #
    

  • CONTRIBUTING.rst
    ... ... @@ -1498,6 +1498,10 @@ option when running tox::
    1498 1498
     
    
    1499 1499
       tox -e py37
    
    1500 1500
     
    
    1501
    +If you do have multiple python versions installed and would like to test against
    
    1502
    +multiple versions, then we recommend using `detox <https://github.com/tox-dev/detox>`_,
    
    1503
    +just run it with the same arguments you would give `tox`.
    
    1504
    +
    
    1501 1505
     Linting is performed separately from testing. In order to run the linting step which
    
    1502 1506
     consists of running the ``pycodestyle`` and ``pylint`` tools, run the following::
    
    1503 1507
     
    
    ... ... @@ -1574,6 +1578,19 @@ can run ``tox`` with ``-r`` or ``--recreate`` option.
    1574 1578
          ./setup.py test --addopts 'tests/frontend/buildtrack.py::test_build_track'
    
    1575 1579
     
    
    1576 1580
     
    
    1581
    +Observing coverage
    
    1582
    +~~~~~~~~~~~~~~~~~~
    
    1583
    +Once you have run the tests using `tox` (or `detox`), some coverage reports will
    
    1584
    +have been left behind.
    
    1585
    +
    
    1586
    +To view the coverage report of the last test run, simply run::
    
    1587
    +
    
    1588
    +  tox -e coverage
    
    1589
    +
    
    1590
    +This will collate any reports from separate python environments that may be
    
    1591
    +under test before displaying the combined coverage.
    
    1592
    +
    
    1593
    +
    
    1577 1594
     Adding tests
    
    1578 1595
     ~~~~~~~~~~~~
    
    1579 1596
     Tests are found in the tests subdirectory, inside of which
    

  • tox.ini
    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} {toxinidir}
    
    16
    +    mkdir -p {toxinidir}/.coverage-reports
    
    17
    +    cp .coverage.{env:COVERAGE_PREFIX:}{envname} {toxinidir}/.coverage-reports
    
    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
    +changedir =
    
    31
    +    py{35,36,37}: {envdir}
    
    32
    +setenv =
    
    33
    +    py{35,36,37}: COVERAGE_FILE = .coverage.{env:COVERAGE_PREFIX:}{envname}
    
    34
    +whitelist_externals =
    
    35
    +    py{35,36,37}: cp mkdir
    
    36
    +
    
    37
    +#
    
    38
    +# Coverage reporting
    
    39
    +#
    
    40
    +[testenv:coverage]
    
    41
    +commands =
    
    42
    +    - coverage combine --rcfile={toxinidir}/.coveragerc -a {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
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]