jenkins: switch to tox for running tests (#15974)

This commit is contained in:
Frédéric Péters 2017-04-24 13:58:51 +02:00
parent 8818a38827
commit 70a99cadd0
4 changed files with 69 additions and 13 deletions

20
getlasso.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
# Get venv site-packages path
DSTDIR=`python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'`
# Get not venv site-packages path
# Remove first path (assuming that is the venv path)
NONPATH=`echo $PATH | sed 's/^[^:]*://'`
SRCDIR=`PATH=$NONPATH python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'`
# Clean up
rm -f $DSTDIR/lasso.*
rm -f $DSTDIR/_lasso.*
# Link
ln -sv $SRCDIR/lasso.py $DSTDIR
ln -sv $SRCDIR/_lasso.* $DSTDIR
exit 0

View File

@ -2,19 +2,9 @@
set -e
rm -f pylint.out
rm -f coverage.xml
rm -f test_results.xml
export PIP_USE_WHEEL=no
pip install --upgrade 'pip<8'
pip install --upgrade pylint pylint-django
pip install --upgrade pytest pytest-django pytest-cov WebTest django-webtest 'setuptools<34'
pip install --upgrade -r requirements.txt
pip install --upgrade django-mellon 'django<1.9'
PYTHONPATH=$(pwd):$PYTHONPATH DJANGO_SETTINGS_MODULE=chrono.settings CHRONO_SETTINGS_FILE=tests/settings.py \
py.test --junitxml=test_results.xml --cov-report xml --cov=chrono/ --cov-config .coveragerc tests/
test -f pylint.out && cp pylint.out pylint.out.prev
(pylint -f parseable --rcfile /var/lib/jenkins/pylint.django.rc chrono | tee pylint.out) || /bin/true
test -f pylint.out.prev && (diff pylint.out.prev pylint.out | grep '^[><]' | grep .py) || /bin/true
pip install --upgrade tox
tox -rv

16
pylint.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
set -e -x
env
if [ -f /var/lib/jenkins/pylint.django.rc ]; then
PYLINT_RC=/var/lib/jenkins/pylint.django.rc
elif [ -f pylint.django.rc ]; then
PYLINT_RC=pylint.django.rc
else
echo No pylint RC found
exit 0
fi
test -f pylint.out && cp pylint.out pylint.out.prev
pylint -f parseable --rcfile ${PYLINT_RC} "$@" | tee pylint.out || /bin/true
test -f pylint.out.prev && (diff pylint.out.prev pylint.out | grep '^[><]' | grep .py) || /bin/true

30
tox.ini Normal file
View File

@ -0,0 +1,30 @@
[tox]
envlist = coverage-django18-pylint,coverage-django111
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/chrono/
[testenv]
usedevelop =
coverage: True
nocoverage: False
setenv =
DJANGO_SETTINGS_MODULE=chrono.settings
CHRONO_SETTINGS_FILE=tests/settings.py
coverage: COVERAGE=--junitxml=test_results.xml --cov-report xml --cov=chrono/
deps =
django18: django>=1.8,<1.9
django111: django>=1.11,<1.12
pytest-cov
pytest-django
pytest
pytest-capturelog
WebTest
mock
httmock
pylint
pylint-django
django-webtest
django-mellon
commands =
./getlasso.sh
py.test {env:COVERAGE:} {posargs:tests/}
pylint: ./pylint.sh chrono/