Browse Source

Improve tox.ini to easy developer's life

This patch is mainly porting from nova repository:

Adds:
1.tools/flake8wrap.sh
  Will let developer use 'tox -epep8 -- -HEAD' to testing changes files
2.tools/pretty_tox.sh
  Give pretty test trace when doing unit/functional testing.

Change-Id: Icedb4ed8b50532531e18784a1584fe63c5a9e017
changes/47/241147/1
Eli Qiao 7 years ago
parent
commit
d802877e6e
  1. 1
      test-requirements.txt
  2. 20
      tools/flake8wrap.sh
  3. 16
      tools/pretty_tox.sh
  4. 12
      tox.ini

1
test-requirements.txt

@ -12,6 +12,7 @@ hacking<0.11,>=0.10.0 # Apache-2.0
mock>=1.2
oslosphinx>=2.5.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0
os-testr>=0.4.1
python-subunit>=0.0.18
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
testrepository>=0.0.18

20
tools/flake8wrap.sh

@ -0,0 +1,20 @@
#!/bin/sh
#
# A simple wrapper around flake8 which makes it possible
# to ask it to only verify files changed in the current
# git HEAD patch.
#
# Intended to be invoked via tox:
#
# tox -epep8 -- -HEAD
#
if test "x$1" = "x-HEAD" ; then
shift
files=$(git diff --name-only HEAD~1 | tr '\n' ' ')
echo "Running flake8 on ${files}"
diff -u --from-file /dev/null ${files} | flake8 --max-complexity 10 --diff "$@"
else
echo "Running flake8 on all files"
exec flake8 --max-complexity 10 "$@"
fi

16
tools/pretty_tox.sh

@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -o pipefail
TESTRARGS=$1
# --until-failure is not compatible with --subunit see:
#
# https://bugs.launchpad.net/testrepository/+bug/1411804
#
# this work around exists until that is addressed
if [[ "$TESTARGS" =~ "until-failure" ]]; then
python setup.py testr --slowest --testr-args="$TESTRARGS"
else
python setup.py testr --slowest --testr-args="--subunit $TESTRARGS" | subunit-trace -f
fi

12
tox.ini

@ -6,15 +6,16 @@ skipsdist = True
[testenv]
usedevelop = True
install_command = pip install -U {opts} {packages}
whitelist_externals = find
whitelist_externals = bash
find
setenv =
VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
commands =
find . -type f -name "*.pyc" -delete
python setup.py testr --slowest --testr-args='{posargs}'
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
bash tools/pretty_tox.sh '{posargs}'
[testenv:functional]
sitepackages = True
@ -22,11 +23,14 @@ setenv = OS_TEST_PATH=./magnum/tests/functional
OS_TEST_TIMEOUT=7200
deps =
{[testenv]deps}
commands =
find . -type f -name "*.pyc" -delete
bash tools/pretty_tox.sh '{posargs}'
[testenv:pep8]
commands =
doc8 -e .rst specs/ doc/source/ contrib/ CONTRIBUTING.rst HACKING.rst README.rst
flake8 --max-complexity 10 {posargs}
bash tools/flake8wrap.sh {posargs}
[testenv:venv]
commands = {posargs}

Loading…
Cancel
Save