Chandan Singh pushed to branch chandan/toxify at BuildStream / buildstream
Commits:
-
daa4c755
by Chandan Singh at 2018-12-29T02:25:57Z
-
6101bab4
by Chandan Singh at 2018-12-29T02:34:07Z
-
d3d0894b
by Chandan Singh at 2018-12-29T02:36:14Z
-
e0d5710c
by Tristan Van Berkom at 2018-12-29T02:38:31Z
-
63ce0e4a
by Chandan Singh at 2018-12-29T03:01:42Z
12 changed files:
- .gitignore
- .gitlab-ci.yml
- CONTRIBUTING.rst
- MANIFEST.in
- + dev-requirements.in
- dev-requirements.txt
- + plugin-requirements.in
- + plugin-requirements.txt
- + requirements.in
- + requirements.txt
- setup.py
- + tox.ini
Changes:
... | ... | @@ -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
|
... | ... | @@ -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:
|
... | ... | @@ -1468,58 +1468,113 @@ regenerate them locally in order to build the docs. |
1468 | 1468 |
|
1469 | 1469 |
Testing
|
1470 | 1470 |
-------
|
1471 |
-BuildStream uses pytest for regression tests and testing out
|
|
1472 |
-the behavior of newly added components.
|
|
1471 |
+BuildStream uses `tox <https://tox.readthedocs.org/>`_ as a frontend to run the
|
|
1472 |
+tests which are implemented using `pytest <https://pytest.org/>`_. We use
|
|
1473 |
+pytest for regression tests and testing out the behavior of newly added
|
|
1474 |
+components.
|
|
1473 | 1475 |
|
1474 | 1476 |
The elaborate documentation for pytest can be found here: http://doc.pytest.org/en/latest/contents.html
|
1475 | 1477 |
|
1476 | 1478 |
Don't get lost in the docs if you don't need to, follow existing examples instead.
|
1477 | 1479 |
|
1478 | 1480 |
|
1481 |
+Installing build dependencies
|
|
1482 |
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
1483 |
+Some of BuildStream's dependencies have non-python build dependencies. When
|
|
1484 |
+running tests with ``tox``, you will first need to install these dependencies.
|
|
1485 |
+Exact steps to install these will depend on your oprtation systemm. Commands
|
|
1486 |
+for installing them for some common distributions are lised below.
|
|
1487 |
+ |
|
1488 |
+For Fedora-based systems::
|
|
1489 |
+ |
|
1490 |
+ dnf install gcc pkg-config python3-devel cairo-gobject-devel glib2-devel gobject-introspection-devel
|
|
1491 |
+ |
|
1492 |
+ |
|
1493 |
+For Debian-based systems::
|
|
1494 |
+ |
|
1495 |
+ apt install gcc pkg-config python3-dev libcairo2-dev libgirepository1.0-dev
|
|
1496 |
+ |
|
1497 |
+ |
|
1479 | 1498 |
Running tests
|
1480 | 1499 |
~~~~~~~~~~~~~
|
1481 |
-To run the tests, just type::
|
|
1500 |
+To run the tests, simply navigate to the toplevel directory of your BuildStream
|
|
1501 |
+checkout and run::
|
|
1502 |
+ |
|
1503 |
+ tox
|
|
1504 |
+ |
|
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::
|
|
1509 |
+ |
|
1510 |
+ tox -e py37
|
|
1482 | 1511 |
|
1483 |
- ./setup.py test
|
|
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::
|
|
1484 | 1515 |
|
1485 |
-At the toplevel.
|
|
1516 |
+ tox -- -s
|
|
1486 | 1517 |
|
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::
|
|
1518 |
+.. tip::
|
|
1490 | 1519 |
|
1491 |
- ./setup.py test --addopts -s
|
|
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 |
+ By default, we do not allow use of site packages in our ``tox``
|
|
1558 |
+ confguration to enable running the tests in an isolated environment.
|
|
1559 |
+ If you need to enable use of site packages for whatever reason, you can
|
|
1560 |
+ do so by passing the ``--sitepackages`` option to ``tox``. Also, you will
|
|
1561 |
+ not need to install any of the build dependencies mentioned above if you
|
|
1562 |
+ use this approach.
|
|
1563 |
+ |
|
1564 |
+.. note::
|
|
1565 |
+ |
|
1566 |
+ While using ``tox`` is practical for developers running tests in
|
|
1567 |
+ more predictable execution environments, it is still possible to
|
|
1568 |
+ execute the test suite against a specific installation environment
|
|
1569 |
+ using pytest directly::
|
|
1570 |
+ |
|
1571 |
+ ./setup.py test
|
|
1572 |
+ |
|
1573 |
+ Specific options can be passed to ``pytest`` using the ``--addopts``
|
|
1574 |
+ option::
|
|
1575 |
+ |
|
1576 |
+ ./setup.py test --addopts 'tests/frontend/buildtrack.py::test_build_track'
|
|
1577 |
+ |
|
1523 | 1578 |
|
1524 | 1579 |
Adding tests
|
1525 | 1580 |
~~~~~~~~~~~~
|
... | ... | @@ -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 |
|
... | ... | @@ -31,7 +32,12 @@ include .pylintrc |
31 | 32 |
recursive-include buildstream/_protos *.proto
|
32 | 33 |
|
33 | 34 |
# Requirements files
|
35 |
+include requirements.in
|
|
36 |
+include requirements.txt
|
|
37 |
+include dev-requirements.in
|
|
34 | 38 |
include dev-requirements.txt
|
39 |
+include plugin-requirements.in
|
|
40 |
+include plugin-requirements.txt
|
|
35 | 41 |
|
36 | 42 |
# Versioneer
|
37 | 43 |
include versioneer.py
|
1 |
+coverage == 4.4.0
|
|
2 |
+pep8
|
|
3 |
+pylint
|
|
4 |
+pytest >= 3.9
|
|
5 |
+pytest-cov >= 2.5.0
|
|
6 |
+pytest-datafiles >= 2.0
|
|
7 |
+pytest-env
|
|
8 |
+pytest-pep8
|
|
9 |
+pytest-pylint
|
|
10 |
+pytest-xdist
|
|
11 |
+pytest-timeout
|
|
12 |
+pyftpdlib
|
1 |
-coverage == 4.4.0
|
|
2 |
-pep8
|
|
3 |
-pylint
|
|
4 |
-pytest >= 3.9
|
|
5 |
-pytest-cov >= 2.5.0
|
|
6 |
-pytest-datafiles >= 2.0
|
|
7 |
-pytest-env
|
|
8 |
-pytest-pep8
|
|
9 |
-pytest-pylint
|
|
10 |
-pytest-xdist
|
|
11 |
-pytest-timeout
|
|
12 |
-pyftpdlib
|
|
1 |
+coverage==4.4
|
|
2 |
+pep8==1.7.1
|
|
3 |
+pylint==2.2.2
|
|
4 |
+pytest==4.0.2
|
|
5 |
+pytest-cov==2.6.0
|
|
6 |
+pytest-datafiles==2.0
|
|
7 |
+pytest-env==0.6.2
|
|
8 |
+pytest-pep8==1.0.6
|
|
9 |
+pytest-pylint==0.13.0
|
|
10 |
+pytest-xdist==1.25.0
|
|
11 |
+pytest-timeout==1.3.3
|
|
12 |
+pyftpdlib==1.5.4
|
|
13 |
+## The following requirements were added by pip freeze:
|
|
14 |
+apipkg==1.5
|
|
15 |
+astroid==2.1.0
|
|
16 |
+atomicwrites==1.2.1
|
|
17 |
+attrs==18.2.0
|
|
18 |
+execnet==1.5.0
|
|
19 |
+isort==4.3.4
|
|
20 |
+lazy-object-proxy==1.3.1
|
|
21 |
+mccabe==0.6.1
|
|
22 |
+more-itertools==5.0.0
|
|
23 |
+pluggy==0.8.0
|
|
24 |
+py==1.7.0
|
|
25 |
+pytest-cache==1.0
|
|
26 |
+pytest-forked==0.2
|
|
27 |
+six==1.12.0
|
|
28 |
+typed-ast==1.1.1
|
|
29 |
+wrapt==1.10.11
|
1 |
+arpy
|
|
2 |
+PyGObject
|
1 |
+arpy==1.1.1
|
|
2 |
+PyGObject==3.30.4
|
|
3 |
+## The following requirements were added by pip freeze:
|
|
4 |
+pycairo==1.18.0
|
1 |
+Click
|
|
2 |
+grpcio >= 1.10
|
|
3 |
+jinja2 >= 2.10
|
|
4 |
+pluginbase
|
|
5 |
+protobuf >= 3.5
|
|
6 |
+psutil
|
|
7 |
+# According to ruamel.yaml's PyPI page, we are suppose to use
|
|
8 |
+# "<=0.15" in production until 0.15 becomes API stable.
|
|
9 |
+# However we need ruamel.yaml 0.15.41 or greater for Python 3.7.
|
|
10 |
+# We know that ruamel.yaml 0.15.52 breaks API in a way that
|
|
11 |
+# is incompatible with BuildStream.
|
|
12 |
+#
|
|
13 |
+# See issues #571 and #790.
|
|
14 |
+ruamel.yaml >= 0.15.41, < 0.15.52
|
|
15 |
+setuptools
|
1 |
+Click==7.0
|
|
2 |
+grpcio==1.17.1
|
|
3 |
+pluginbase==0.7
|
|
4 |
+protobuf==3.6.1
|
|
5 |
+psutil==5.4.8
|
|
6 |
+# According to ruamel.yaml's PyPI page, we are suppose to use
|
|
7 |
+# "<=0.15" in production until 0.15 becomes API stable.
|
|
8 |
+# However we need ruamel.yaml 0.15.41 or greater for Python 3.7.
|
|
9 |
+# We know that ruamel.yaml 0.15.52 breaks API in a way that
|
|
10 |
+# is incompatible with BuildStream.
|
|
11 |
+#
|
|
12 |
+# See issues #571 and #790.
|
|
13 |
+ruamel.yaml==0.15.51
|
|
14 |
+setuptools==39.0.1
|
|
15 |
+## The following requirements were added by pip freeze:
|
|
16 |
+Jinja2==2.10
|
|
17 |
+MarkupSafe==1.1.0
|
|
18 |
+six==1.12.0
|
... | ... | @@ -270,9 +270,12 @@ def get_cmdclass(): |
270 | 270 |
#####################################################
|
271 | 271 |
# Gather requirements #
|
272 | 272 |
#####################################################
|
273 |
-with open('dev-requirements.txt') as dev_reqs:
|
|
273 |
+with open('dev-requirements.in') as dev_reqs:
|
|
274 | 274 |
dev_requires = dev_reqs.read().splitlines()
|
275 | 275 |
|
276 |
+with open('requirements.in') as install_reqs:
|
|
277 |
+ install_requires = install_reqs.read().splitlines()
|
|
278 |
+ |
|
276 | 279 |
#####################################################
|
277 | 280 |
# Prepare package description from README #
|
278 | 281 |
#####################################################
|
... | ... | @@ -334,23 +337,7 @@ setup(name='BuildStream', |
334 | 337 |
os.path.join('buildstream', 'data', 'bst')
|
335 | 338 |
])
|
336 | 339 |
],
|
337 |
- install_requires=[
|
|
338 |
- 'setuptools',
|
|
339 |
- 'psutil',
|
|
340 |
- # According to ruamel.yaml's PyPI page, we are suppose to use
|
|
341 |
- # "<=0.15" in production until 0.15 becomes API stable.
|
|
342 |
- # However we need ruamel.yaml 0.15.41 or greater for Python 3.7.
|
|
343 |
- # We know that ruamel.yaml 0.15.52 breaks API in a way that
|
|
344 |
- # is incompatible with BuildStream.
|
|
345 |
- #
|
|
346 |
- # See issues #571 and #790.
|
|
347 |
- 'ruamel.yaml >= 0.15.41, < 0.15.52',
|
|
348 |
- 'pluginbase',
|
|
349 |
- 'Click >= 7.0',
|
|
350 |
- 'jinja2 >= 2.10',
|
|
351 |
- 'protobuf >= 3.5',
|
|
352 |
- 'grpcio >= 1.10',
|
|
353 |
- ],
|
|
340 |
+ install_requires=install_requires,
|
|
354 | 341 |
entry_points=bst_install_entry_points,
|
355 | 342 |
tests_require=dev_requires,
|
356 | 343 |
zip_safe=False)
|
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
|