From 0824a570ec517d3dad95c2bf2bf053e43f14405d Mon Sep 17 00:00:00 2001 From: Pete Vander Giessen Date: Tue, 5 Nov 2019 15:36:24 +0000 Subject: [PATCH] Clean up tox.ini a bit Remove some of the redundancy in tox.ini. Fixed some lint issues that weren't caught before due to gaps in the linting coverage. I think that there's more work to be done here, but this does make things better than they were before. Change-Id: I82487dbb9366f3de16b25615bd081b6315671655 --- tools/init/tests/test_question.py | 3 +- tools/update_path.py | 19 +++-------- tox.ini | 57 +++++++++---------------------- 3 files changed, 23 insertions(+), 56 deletions(-) diff --git a/tools/init/tests/test_question.py b/tools/init/tests/test_question.py index e2fc36a..d00f491 100644 --- a/tools/init/tests/test_question.py +++ b/tools/init/tests/test_question.py @@ -7,8 +7,7 @@ import mock # TODO: drop in test runner and get rid of this line. sys.path.append(os.getcwd()) # noqa -from init.questions.question import (Question, InvalidQuestion, InvalidAnswer, - AnswerNotImplemented) +from init.questions.question import (Question, InvalidQuestion, InvalidAnswer) ############################################################################## diff --git a/tools/update_path.py b/tools/update_path.py index fe1dc2b..5091570 100755 --- a/tools/update_path.py +++ b/tools/update_path.py @@ -17,30 +17,20 @@ import os import shutil import sys + LD_LIBRARY_PATH = ( '$SNAP/lib', '$SNAP/lib/$SNAPCRAFT_ARCH_TRIPLET', '$SNAP/usr/lib', '$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET', - '$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio', -# '/snap/core18/current/lib', -# '/snap/core18/current/lib/$SNAPCRAFT_ARCH_TRIPLET', -# '/snap/core18/current/lib/systemd', -# '/snap/core18/current/usr/lib', -# '/snap/core18/current/var/lib', -# '/snap/core18/current/usr/lib/$SNAPCRAFT_ARCH_TRIPLET', -) + '$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio',) PATH = ( '$SNAP/usr/sbin', '$SNAP/usr/bin', '$SNAP/sbin', '$SNAP/bin', -# '/snap/core18/current/bin', -# '/snap/core18/current/usr/sbin', -# '/snap/core18/current/usr/bin', -# '/snap/core18/current/sbin', - '$PATH' -) + '$PATH') + def main(): """Replace PATH and LD_LIBRARY_PATH with lists above. @@ -81,5 +71,6 @@ def main(): print('File updated! Please manually inspect the changes ' 'and commit them via git.') + if __name__ == '__main__': main() diff --git a/tox.ini b/tox.ini index c860e52..7a0aa86 100644 --- a/tox.ini +++ b/tox.ini @@ -5,19 +5,22 @@ skipsdist = True [testenv] basepython=python3 install_command = pip install {opts} {packages} +deps = -r{toxinidir}/test-requirements.txt setenv = PATH = /snap/bin:{env:PATH} -passenv = HOME TERM +passenv = HOME TERM DISTRO whitelist_externals = sudo /snap/bin/snapcraft +commands = + {toxinidir}/tools/basic_setup.sh + flake8 {toxinidir}/tests/ + {toxinidir}/tests/test_basic.py [testenv:snap] # Testing environment for the gerrit gate. Named 'snap' to conform to # the requirements of the snap friendly job that we inherit from in # .zuul.yaml. -basepython=python3 -deps = -r{toxinidir}/test-requirements.txt commands = {toxinidir}/tools/lxd_build.sh flake8 {toxinidir}/tests/ @@ -33,62 +36,40 @@ commands = # use the "snap" environment above. Beware that you will wind up with # a lot of things installed, including potentially the locally built # version of MicroStack! -deps = -r{toxinidir}/test-requirements.txt setenv = - PATH = /snap/bin:{env:PATH} MULTIPASS=true + commands = {toxinidir}/tools/multipass_build.sh flake8 {toxinidir}/tests/ {toxinidir}/tests/test_basic.py [testenv:basic] -# Just run basic_test.sh, with multipass support. -deps = -r{toxinidir}/test-requirements.txt +# Run basic tests, with default distro. setenv = MULTIPASS=true -commands = - {toxinidir}/tools/basic_setup.sh - flake8 {toxinidir}/tests/ - {toxinidir}/tests/test_basic.py - -[testenv:eoan] -# Just run basic_test.sh, with multipass support, on eoan. -# TODO: refactor so that there isn't so much copypasta here and below. -deps = -r{toxinidir}/test-requirements.txt +[testenv:xenial] +# Run basic tests, under xenial. setenv = MULTIPASS=true - DISTRO=eoan - -commands = - {toxinidir}/tools/basic_setup.sh - flake8 {toxinidir}/tests/ - {toxinidir}/tests/test_basic.py + DISTRO=xenial [testenv:disco] -# Just run basic_test.sh, with multipass support, on disco. -deps = -r{toxinidir}/test-requirements.txt +# Run basic tests, under disco. setenv = MULTIPASS=true DISTRO=disco -[testenv:xenial] -# Just run basic_test.sh, with multipass support, on xenial. -deps = -r{toxinidir}/test-requirements.txt +[testenv:eoan] +# Run basic tests, under eoan. setenv = MULTIPASS=true - DISTRO=xenial - -commands = - {toxinidir}/tools/basic_setup.sh - flake8 {toxinidir}/tests/ - {toxinidir}/tests/test_basic.py + DISTRO=eoan [testenv:cluster] # Test out clustering! # Requires multipass. -deps = -r{toxinidir}/test-requirements.txt setenv = MULTIPASS=true @@ -98,21 +79,17 @@ commands = {toxinidir}/tests/test_cluster.py [testenv:build] -# Just run basic_test.sh, with multipass support. -deps = -r{toxinidir}/test-requirements.txt +# Just build the snap, using multipass. setenv = MULTIPASS=true commands = - flake8 {toxinidir}/tests/ - flake8 {toxinidir}/tools/init/init - flake8 {toxinidir}/tools/cluster/cluster {toxinidir}/tools/multipass_build.sh [testenv:lint] -deps = -r{toxinidir}/test-requirements.txt commands = flake8 {toxinidir}/tests/ + flake8 {toxinidir}/tools/ flake8 {toxinidir}/tools/init/init/ flake8 {toxinidir}/tools/launch/launch/ flake8 {toxinidir}/tools/cluster/cluster/