diff --git a/.gitignore b/.gitignore index 19649a37..05b13b69 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ docs/build/ .vagrant .gitreview devtools/*.conf +.tox diff --git a/Makefile b/Makefile index 24b830d9..992446aa 100644 --- a/Makefile +++ b/Makefile @@ -79,20 +79,11 @@ test: test2 test3 @echo "All tests are finished for python 2&3" test2: - coverage2 erase - PYTHONPATH=.:plugins/builder/.:plugins/cli/.:cli/.:www/lib coverage2 run \ - --source . -m nose tests/test_builder tests/test_cli tests/test_lib \ - tests/test_plugins/test*builder.py tests/test_plugins/test*cli.py - coverage2 report - coverage2 html + tox -e py2 @echo Full coverage report at file://${CURDIR}/htmlcov/py2/index.html test3: - coverage3 erase --rcfile .coveragerc3 - PYTHONPATH=hub/.:plugins/hub/.:plugins/builder/.:plugins/cli/.:cli/.:www/lib coverage3 run \ - --rcfile .coveragerc3 --source . -m nose - coverage3 report --rcfile .coveragerc3 - coverage3 html --rcfile .coveragerc3 + tox -e py3 @echo Full coverage report at file://${CURDIR}/htmlcov/py3/index.html test-tarball: @@ -136,7 +127,7 @@ pypi-upload: twine upload dist/* flake8: - flake8 + tox -e flake8 tag:: git tag -a $(TAG) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..83107c75 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +-e . +Cheetah;python_version < '3.0' +Cheetah3;python_version >= '3.0' +psycopg2-binary;python_version >= '3.0' +python-multilib +python-qpid-proton +rpm-py-installer diff --git a/test-requirements.txt b/test-requirements.txt index 7cba63da..f73ab635 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,6 +1,8 @@ +-e . flake8 flake8-import-order mock<=2.0.0 requests-mock coverage nose +unittest2;python_version < '3.0' diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..1e07fd35 --- /dev/null +++ b/tox.ini @@ -0,0 +1,55 @@ +[tox] +envlist = flake8,py2,py3 + +[testenv:flake8] +deps = + flake8 +# On EL6, pip would get us a flake8 that doesn't work with python2.6. The next +# two lines let us use an RPM-based version from EPEL if it is installed +sitepackages = true +whitelist_externals = flake8 +# These two lines just speed things up by avoiding unnecessary setup +skip_install=true +usedevelop=true +commands = + flake8 --exclude=.tox + +[testenv] +deps = + -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +# We need to access python-rpm, at least, and potentially more on EL6 +sitepackages = true +# If rpm's python bindings are missing, don't continue +# Also, because coverage might be installed system-wide and it serves as our +# entry point, let's make sure it's installed in the virtualenv. +commands_pre = + {envbindir}/python -c "import rpm" + pip install -I coverage + +[testenv:py3] +setenv = + PYTHONPATH=hub/.:plugins/hub/.:plugins/builder/.:plugins/cli/.:cli/.:www/lib +commands_pre = + {[testenv]commands_pre} + {envbindir}/coverage3 erase --rcfile .coveragerc3 +commands = + {envbindir}/coverage3 run --rcfile .coveragerc3 --source . -m nose + {envbindir}/coverage3 report --rcfile .coveragerc3 + {envbindir}/coverage3 html -d {toxinidir}/htmlcov/py3 --rcfile .coveragerc3 + +[testenv:py2] +setenv = + PYTHONPATH=.:plugins/builder/.:plugins/cli/.:cli/.:www/lib +commands_pre = + {[testenv]commands_pre} + {envbindir}/coverage2 erase +commands = + {envbindir}/coverage2 run --source . -m nose \ + tests/test_builder tests/test_cli \ + tests/test_plugins/test_runroot_builder.py \ + tests/test_plugins/test_save_failed_tree_builder.py \ + tests/test_plugins/test_runroot_cli.py \ + tests/test_plugins/test_save_failed_tree_cli.py + {envbindir}/coverage2 report + {envbindir}/coverage2 html -d {toxinidir}/htmlcov/py3