From 421cdd642f7e7711eca29d061307ff57c7d5c9e4 Mon Sep 17 00:00:00 2001 From: Billy Olsen Date: Tue, 15 Mar 2016 20:08:42 -0700 Subject: [PATCH] Use tox in Makefile targets Modify the Makefile to point at the appropriate tox targets so that tox and Make output can be equivalent. This involves mapping the lint target to the pep8 target and the test target to the py27 target. Add tox support to the charm. Change-Id: I7c8078ebaac1bcfbc9993330127182ffe85a2220 --- .gitignore | 3 +++ .testr.conf | 8 ++++++++ Makefile | 6 +++--- requirements.txt | 11 +++++++++++ test-requirements.txt | 8 ++++++++ tox.ini | 29 +++++++++++++++++++++++++++++ 6 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 .testr.conf create mode 100644 requirements.txt create mode 100644 test-requirements.txt create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 5cbdd88..f9c671b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ bin .coverage +.testrepository +.tox *.sw[nop] +*.py[oc] diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 0000000..801646b --- /dev/null +++ b/.testr.conf @@ -0,0 +1,8 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ + OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ + OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ + ${PYTHON:-python} -m subunit.run discover -t ./ ./unit_tests $LISTOPT $IDOPTION + +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/Makefile b/Makefile index d6c3358..c05df85 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,11 @@ PYTHON := /usr/bin/env python lint: - @flake8 --exclude hooks/charmhelpers hooks unit_tests - @charm proof + @tox -e pep8 test: - @$(PYTHON) /usr/bin/nosetests --nologcapture --with-coverage unit_tests + @echo Starting unit tests... + @tox -e py27 functional_test: @echo Starting amulet deployment tests... diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..426002d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +PyYAML>=3.1.0 +simplejson>=2.2.0 +netifaces>=0.10.4 +netaddr>=0.7.12,!=0.7.16 +Jinja2>=2.6 # BSD License (3 clause) +six>=1.9.0 +dnspython>=1.12.0 +psutil>=1.1.1,<2.0.0 diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..3af44d7 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,8 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +coverage>=3.6 +mock>=1.2 +flake8>=2.2.4,<=2.4.1 +os-testr>=0.4.1 +charm-tools diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..e8bf7cf --- /dev/null +++ b/tox.ini @@ -0,0 +1,29 @@ +[tox] +envlist = pep8,py27 +skipsdist = True + +[testenv] +setenv = VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 +install_command = + pip install --allow-unverified python-apt {opts} {packages} +commands = ostestr {posargs} + +[testenv:py27] +basepython = python2.7 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +[testenv:pep8] +basepython = python2.7 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = flake8 {posargs} hooks unit_tests tests + charm proof + +[testenv:venv] +commands = {posargs} + +[flake8] +ignore = E402,E226 +exclude = hooks/charmhelpers