Allow tox to support regexes for unit tests

This patch set adds a shell wrapper script to allow
tox to be used to run a subset of unit tests via regexes:

To run all unit tests, execute::

  $ tox -epy35

To run unit tests using a regex, execute::

  $ tox -epy35 -- <regex>

Change-Id: I2ba1e18226d686cb549a075e020ba02e24204829
This commit is contained in:
Felipe Monteiro 2018-10-17 20:40:32 +01:00
parent c20d714c61
commit ec34ed056f
3 changed files with 22 additions and 2 deletions

View File

@ -124,6 +124,17 @@ All Pegleg tests are nested under ``tests``.
Pegleg comes equipped with a number of `tox`_ targets for running unit tests,
as well as `pep8`_ and `Bandit`_ checks.
Unit Tests
----------
To run all unit tests, execute::
$ tox -epy35
To run unit tests using a regex, execute::
$ tox -epy35 -- <regex>
.. _Airship: https://airshipit.readthedocs.io
.. _Deckhand: https://airship-deckhand.readthedocs.io/
.. _Airship coding conventions: https://airshipit.readthedocs.io/en/latest/conventions.html

10
tools/gate/run-unit-tests.sh Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e
posargs=$@
if [ ${#posargs} -ge 1 ]; then
pytest -k ${posargs}
else
pytest
fi
set +e

View File

@ -18,8 +18,7 @@ whitelist_externals =
find
commands =
find . -type f -name "*.pyc" -delete
pytest \
{posargs}
{toxinidir}/tools/gate/run-unit-tests.sh '{posargs}'
[testenv:fmt]
basepython=python3