From c2b458ae148b85bd5b8ec4f22452fb2a23fb50e3 Mon Sep 17 00:00:00 2001 From: Camille Rodriguez Date: Tue, 27 Aug 2019 09:58:41 -0400 Subject: [PATCH] Avoid pollution and false positives with tox.ini - added mising test-requirements.txt file - updated testenv build to build in a tmp folder outside of src - removing sitepackages in tox.ini to avoid test env pollution - skip_missing_interpreters in tox.ini set to False to avoid false positives by skipping missing interpreters. Change-Id: I7985b07bb215ad43403a3e581197d5e139b603ac --- test-requirements.txt | 2 ++ tox.ini | 51 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 test-requirements.txt diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..095ec9c --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +flake8>=2.2.4,<=2.4.1 +os-testr>=0.4.1 diff --git a/tox.ini b/tox.ini index 2bc1c5f..560d986 100644 --- a/tox.ini +++ b/tox.ini @@ -1,28 +1,71 @@ [tox] skipsdist = True envlist = pep8,build +toxworkdir = /tmp/tox +# NOTE(beisner): Avoid build/test env pollution by not enabling sitepackages. +sitepackages = False +# NOTE(beisner): Avoid false positives by not skipping missing interpreters. +skip_missing_interpreters = False [testenv] -basepython = python2.7 +basepython = python3 setenv = VIRTUAL_ENV={envdir} PYTHONHASHSEED=0 TERM=linux - JUJU_REPOSITORY={toxinidir}/build + JUJU_REPOSITORY={envdir}/tmp/build passenv = http_proxy https_proxy install_command = pip install {opts} {packages} deps = -r{toxinidir}/requirements.txt -whitelist_externals = /bin/true +whitelist_externals = /bin/true /bin/echo /bin/mkdir /bin/ln [testenv:build] +# ``charm build`` refuses to output to a subdirectory to the source tree +# The gate check will look for and validate the built artifacts in the source +# tree. +# Build the artifats under /tmp and link back to source directory to alleviate. commands = - charm-build --log-level DEBUG -o {toxinidir}/build . + /bin/echo 'WARNING: *build* target is for testing only.' + /bin/mkdir -p {envdir}/tmp + charm-build --log-level DEBUG -o {envdir}/tmp/build . + /bin/ln -s {envdir}/tmp/build/builds {envdir}/tmp/build/trusty + /bin/ln -s {envdir}/tmp/build {toxinidir}/build [testenv:venv] basepython = python3 commands = {posargs} +[testenv:py27] +basepython = python2.7 +deps = -r{toxinidir}/test-requirements.txt +# TODO: Need to write unit tests then remove the following command. +commands = /bin/true + +[testenv:py34] +basepython = python3.4 +deps = -r{toxinidir}/test-requirements.txt +# TODO: Need to write unit tests then remove the following command. +commands = /bin/true + +[testenv:py35] +basepython = python3.5 +deps = -r{toxinidir}/test-requirements.txt +# TODO: Need to write unit tests then remove the following command. +commands = /bin/true + +[testenv:py36] +basepython = python3.6 +deps = -r{toxinidir}/test-requirements.txt +# TODO: Need to write unit tests then remove the following command. +commands = /bin/true + +[testenv:py37] +basepython = python3.7 +deps = -r{toxinidir}/test-requirements.txt +# TODO: Need to write unit tests then remove the following command. +commands = /bin/true + [testenv:pep8] basepython = python3 commands = /bin/true