diff --git a/Makefile b/Makefile index 8ecbca45..37095d7d 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,12 @@ test_twisted_coverage: coverage html coverage report --show-missing +test_coverage: + -rm .coverage + tox -e py27twisted,py27asyncio,py34asyncio + coverage html + coverage report --show-missing + # test under asyncio test_asyncio: USE_ASYNCIO=1 python -m pytest -rsx diff --git a/doc/contribute.rst b/doc/contribute.rst index 5d3e1699..f5c37845 100644 --- a/doc/contribute.rst +++ b/doc/contribute.rst @@ -17,3 +17,13 @@ This means that you fork the repo, make changes to your fork, and then make a pu This `article on GitHub `_ gives more detailed information on how the process works. +Running the Tests +----------------- + +In order to run the unit-tests, we use `Tox `_ to build the various test-environments. To run them all, simply run ``tox`` from the top-level directory of the clone. + +For test-coverage, see the Makefile target ``test_coverage``, which deletes the coverage data and then runs the test suite with various tox test-environments before outputting HTML annotated coverage to ``./htmlcov/index.html`` and a coverage report to the terminal. + +There are two environment variables the tests use: ``USE_TWISTED=1`` or ``USE_ASYNCIO=1`` control whether to run unit-tests that are specific to one framework or the other. + +See ``tox.ini`` for details on how to run in the different environments diff --git a/tox.ini b/tox.ini index 80f52dce..fc3dc60f 100644 --- a/tox.ini +++ b/tox.ini @@ -69,9 +69,9 @@ commands = coverage --version {envbindir}/trial --version # XXX should probably add --branch - coverage run --source=autobahn --omit=*test* {envbindir}/trial autobahn - coverage report --show-missing - coverage html + # note: always doing --append so we can get coverage across all + # Python versions at once; see "make test_coverage" + coverage run --append --source=autobahn --omit=*test* {envbindir}/trial autobahn basepython = python2.7 install_command = pip install {packages} autobahn[twisted,serialization] setenv = @@ -82,7 +82,8 @@ setenv = commands = sh -c "which python" python -V - py.test autobahn/ + coverage --version + coverage run --append --source=autobahn --omit=*test* {envbindir}/py.test autobahn/ basepython = python2.7 install_command = pip install {packages} autobahn[asyncio,serialization] setenv = @@ -93,7 +94,8 @@ setenv = commands = sh -c "which python" python -V - py.test autobahn/ + coverage --version + coverage run --append --source=autobahn --omit=*test* {envbindir}/py.test autobahn/ basepython = python3.3 install_command = pip install {packages} autobahn[asyncio,serialization] setenv = @@ -104,7 +106,8 @@ setenv = commands = sh -c "which python" python -V - py.test autobahn/ + coverage --version + coverage run --append --source=autobahn --omit=*test* {envbindir}/py.test autobahn/ basepython = python3.4 install_command = pip install {packages} autobahn[asyncio,serialization] setenv = @@ -118,9 +121,11 @@ deps = commands = sh -c "which python" sh -c "which trial" + sh -c "which coverage" python -V - trial --version - trial autobahn + {envbindir}/trial --version + coverage --version + coverage run --append --source=autobahn --omit=*test* {envbindir}/trial autobahn/ basepython = pypy install_command = pip install {packages} autobahn[twisted,serialization] setenv = @@ -130,8 +135,11 @@ setenv = [testenv:pypy2asyncio] commands = sh -c "which python" + sh -c "which coverage" python -V - py.test autobahn/ + coverage --version + {envbindir}/py.test --version + coverage run --append --source=autobahn --omit=*test* {envbindir}/py.test autobahn/ basepython = pypy install_command = pip install {packages} autobahn[asyncio,serialization] setenv =