... |
... |
@@ -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
|
~~~~~~~~~~~~
|