[Notes] [Git][BuildStream/buildstream][chandan/toxify] 4 commits: Add tox.ini to enable running tests using tox



Title: GitLab

Chandan Singh pushed to branch chandan/toxify at BuildStream / buildstream

Commits:

5 changed files:

Changes:

  • .gitignore
    ... ... @@ -17,6 +17,7 @@ tmp
    17 17
     .cache
    
    18 18
     .pytest_cache/
    
    19 19
     *.bst/
    
    20
    +.tox
    
    20 21
     
    
    21 22
     # Pycache, in case buildstream is ran directly from within the source
    
    22 23
     # tree
    

  • .gitlab-ci.yml
    ... ... @@ -13,7 +13,7 @@ stages:
    13 13
     variables:
    
    14 14
       PYTEST_ADDOPTS: "--color=yes"
    
    15 15
       INTEGRATION_CACHE: "${CI_PROJECT_DIR}/cache/integration-cache"
    
    16
    -  TEST_COMMAND: 'python3 setup.py test --index-url invalid://uri --addopts --integration'
    
    16
    +  TEST_COMMAND: 'tox -- --color=yes --integration'
    
    17 17
     
    
    18 18
     #####################################################
    
    19 19
     #                  Prepare stage                    #
    
    ... ... @@ -67,10 +67,10 @@ source_dist:
    67 67
       # Diagnostics
    
    68 68
       - mount
    
    69 69
       - df -h
    
    70
    -
    
    71
    -  # Unpack
    
    72
    -  - cd dist && ./unpack.sh
    
    73
    -  - cd buildstream
    
    70
    +  # FIXME: this deps should ideally be provided by the testsuite images
    
    71
    +  - pip3 install tox
    
    72
    +  - |
    
    73
    +    bash -c '( apt-get update && apt-get install -y python3-dev gcc libcairo2-dev pkg-config libgirepository1.0-dev ) || ( dnf install -y gcc python3-devel gobject-introspection-devel glib2-devel cairo-gobject-devel )'
    
    74 74
     
    
    75 75
       script:
    
    76 76
       - useradd -Um buildstream
    
    ... ... @@ -83,7 +83,7 @@ source_dist:
    83 83
       after_script:
    
    84 84
       # Collect our reports
    
    85 85
       - mkdir -p ${COVERAGE_DIR}
    
    86
    -  - cp dist/buildstream/.coverage ${COVERAGE_DIR}/coverage."${CI_JOB_NAME}"
    
    86
    +  - cp .coverage ${COVERAGE_DIR}/coverage."${CI_JOB_NAME}"
    
    87 87
       except:
    
    88 88
       - schedules
    
    89 89
       artifacts:
    

  • CONTRIBUTING.rst
    ... ... @@ -1476,50 +1476,96 @@ The elaborate documentation for pytest can be found here: http://doc.pytest.org/
    1476 1476
     Don't get lost in the docs if you don't need to, follow existing examples instead.
    
    1477 1477
     
    
    1478 1478
     
    
    1479
    +Installing build dependencies
    
    1480
    +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    1481
    +Some of BuildStream's dependencies have non-python build dependencies, so in
    
    1482
    +order to be able to run BuildStream's tests, you will first need to install
    
    1483
    +these dependencies. Exact steps to install these will depend on your
    
    1484
    +oprtation systemm. Commands for installing them for some common distributions
    
    1485
    +are lised below.
    
    1486
    +
    
    1487
    +For Fedora-based systems::
    
    1488
    +
    
    1489
    +  dnf install gcc pkg-config python3-devel cairo-gobject-devel glib2-devel gobject-introspection-devel
    
    1490
    +
    
    1491
    +
    
    1492
    +For Debian-based systems::
    
    1493
    +
    
    1494
    +  apt install gcc pkg-config python3-dev libcairo2-dev libgirepository1.0-dev
    
    1495
    +
    
    1496
    +
    
    1479 1497
     Running tests
    
    1480 1498
     ~~~~~~~~~~~~~
    
    1481
    -To run the tests, just type::
    
    1499
    +We use `tox <https://tox.readthedocs.org/>`_ as a frontend run the tests which
    
    1500
    +are implemented using `pytest <https://pytest.org/>`_. To run the tests, simply
    
    1501
    +navigate to the toplevel directory of your buildstream checkout and run::
    
    1502
    +
    
    1503
    +  tox
    
    1482 1504
     
    
    1483
    -  ./setup.py test
    
    1505
    +By default, the test suite will be run against every supported python version
    
    1506
    +found on your host. If you have multiple python versions installed, you may
    
    1507
    +want to run tests against only one version and you can do that using the ``-e``
    
    1508
    +option when running tox::
    
    1484 1509
     
    
    1485
    -At the toplevel.
    
    1510
    +  tox -e py37
    
    1486 1511
     
    
    1487
    -When debugging a test, it can be desirable to see the stdout
    
    1488
    -and stderr generated by a test, to do this use the ``--addopts``
    
    1489
    -function to feed arguments to pytest as such::
    
    1512
    +The output of all failing tests will always be printed in the summary, but
    
    1513
    +if you want to observe the stdout and stderr generated by a passing test,
    
    1514
    +you can pass the ``-s`` option to pytest as such::
    
    1490 1515
     
    
    1491
    -  ./setup.py test --addopts -s
    
    1516
    +  tox -- -s
    
    1517
    +
    
    1518
    +.. tip::
    
    1519
    +
    
    1520
    +   The ``-s`` option is `a pytest option <https://docs.pytest.org/latest/usage.html>`_.
    
    1521
    +
    
    1522
    +   Any options specified before the ``--`` separator are consumed by ``tox``,
    
    1523
    +   and any options after the ``--`` separator will be passed along to pytest.
    
    1492 1524
     
    
    1493 1525
     You can always abort on the first failure by running::
    
    1494 1526
     
    
    1495
    -  ./setup.py test --addopts -x
    
    1527
    +  tox -- -x
    
    1496 1528
     
    
    1497 1529
     If you want to run a specific test or a group of tests, you
    
    1498 1530
     can specify a prefix to match. E.g. if you want to run all of
    
    1499 1531
     the frontend tests you can do::
    
    1500 1532
     
    
    1501
    -  ./setup.py test --addopts 'tests/frontend/'
    
    1533
    +  tox -- tests/frontend/
    
    1502 1534
     
    
    1503 1535
     Specific tests can be chosen by using the :: delimeter after the test module.
    
    1504 1536
     If you wanted to run the test_build_track test within frontend/buildtrack.py you could do::
    
    1505 1537
     
    
    1506
    -  ./setup.py test --addopts 'tests/frontend/buildtrack.py::test_build_track'
    
    1538
    +  tox -- tests/frontend/buildtrack.py::test_build_track
    
    1507 1539
     
    
    1508 1540
     We also have a set of slow integration tests that are disabled by
    
    1509 1541
     default - you will notice most of them marked with SKIP in the pytest
    
    1510 1542
     output. To run them, you can use::
    
    1511 1543
     
    
    1512
    -  ./setup.py test --addopts '--integration'
    
    1544
    +  tox -- --integration
    
    1513 1545
     
    
    1514 1546
     By default, buildstream also runs pylint on all files. Should you want
    
    1515 1547
     to run just pylint (these checks are a lot faster), you can do so
    
    1516 1548
     with::
    
    1517 1549
     
    
    1518
    -  ./setup.py test --addopts '-m pylint'
    
    1550
    +  tox -- -m pylint
    
    1519 1551
     
    
    1520 1552
     Alternatively, any IDE plugin that uses pytest should automatically
    
    1521 1553
     detect the ``.pylintrc`` in the project's root directory.
    
    1522 1554
     
    
    1555
    +.. note::
    
    1556
    +
    
    1557
    +   While using ``tox`` is practical for developers running tests in
    
    1558
    +   more predictable execution environments, it is still possible to
    
    1559
    +   execute the test suite against a specific installation environment
    
    1560
    +   using pytest directly::
    
    1561
    +
    
    1562
    +     ./setup.py test
    
    1563
    +
    
    1564
    +   Specific options can be passed to ``pytest`` using the ``--addopts``
    
    1565
    +   option::
    
    1566
    +
    
    1567
    +     ./setup.py test --addopts 'tests/frontend/buildtrack.py::test_build_track'
    
    1568
    +
    
    1523 1569
     
    
    1524 1570
     Adding tests
    
    1525 1571
     ~~~~~~~~~~~~
    

  • MANIFEST.in
    ... ... @@ -24,6 +24,7 @@ recursive-include doc/sessions *.run
    24 24
     # Tests
    
    25 25
     recursive-include tests *
    
    26 26
     include conftest.py
    
    27
    +include tox.ini
    
    27 28
     include .coveragerc
    
    28 29
     include .pylintrc
    
    29 30
     
    

  • tox.ini
    1
    +[tox]
    
    2
    +envlist = py35,py36,py37
    
    3
    +skip_missing_interpreters = true
    
    4
    +
    
    5
    +[testenv]
    
    6
    +commands = pytest {posargs}
    
    7
    +deps =
    
    8
    +    -rrequirements.txt
    
    9
    +    -rdev-requirements.txt
    
    10
    +    -rplugin-requirements.txt
    
    11
    +passenv =
    
    12
    +    GI_TYPELIB_PATH



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