Projet

Général

Profil

0001-jenkins-switch-to-tox-for-running-tests-15974.patch

Frédéric Péters, 22 mai 2017 12:13

Télécharger (3,54 ko)

Voir les différences:

Subject: [PATCH] jenkins: switch to tox for running tests (#15974)

 getlasso.sh | 20 ++++++++++++++++++++
 jenkins.sh  | 16 +++-------------
 pylint.sh   | 16 ++++++++++++++++
 tox.ini     | 30 ++++++++++++++++++++++++++++++
 4 files changed, 69 insertions(+), 13 deletions(-)
 create mode 100755 getlasso.sh
 create mode 100755 pylint.sh
 create mode 100644 tox.ini
getlasso.sh
1
#!/bin/sh
2

  
3
# Get venv site-packages path
4
DSTDIR=`python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'`
5

  
6
# Get not venv site-packages path
7
# Remove first path (assuming that is the venv path)
8
NONPATH=`echo $PATH | sed 's/^[^:]*://'`
9
SRCDIR=`PATH=$NONPATH python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())'`
10

  
11
# Clean up
12
rm -f $DSTDIR/lasso.*
13
rm -f $DSTDIR/_lasso.*
14

  
15
# Link
16
ln -sv $SRCDIR/lasso.py $DSTDIR
17
ln -sv $SRCDIR/_lasso.* $DSTDIR
18

  
19
exit 0
20

  
jenkins.sh
2 2

  
3 3
set -e
4 4

  
5
rm -f pylint.out
5 6
rm -f coverage.xml
6 7
rm -f test_results.xml
7 8

  
8
export PIP_USE_WHEEL=no
9
pip install --upgrade 'pip<8'
10
pip install --upgrade pylint pylint-django
11
pip install --upgrade pytest pytest-django pytest-cov WebTest django-webtest 'setuptools<34'
12
pip install --upgrade -r requirements.txt
13
pip install --upgrade django-mellon 'django<1.9'
14

  
15
PYTHONPATH=$(pwd):$PYTHONPATH DJANGO_SETTINGS_MODULE=chrono.settings CHRONO_SETTINGS_FILE=tests/settings.py \
16
	py.test --junitxml=test_results.xml --cov-report xml --cov=chrono/ --cov-config .coveragerc tests/
17

  
18
test -f pylint.out && cp pylint.out pylint.out.prev
19
(pylint -f parseable --rcfile /var/lib/jenkins/pylint.django.rc chrono | tee pylint.out) || /bin/true
20
test -f pylint.out.prev && (diff pylint.out.prev pylint.out | grep '^[><]' | grep .py) || /bin/true
9
pip install --upgrade tox
10
tox -rv
pylint.sh
1
#!/bin/sh
2

  
3
set -e -x
4
env
5
if [ -f /var/lib/jenkins/pylint.django.rc ]; then
6
	PYLINT_RC=/var/lib/jenkins/pylint.django.rc
7
elif [ -f pylint.django.rc ]; then
8
	PYLINT_RC=pylint.django.rc
9
else
10
	echo No pylint RC found
11
	exit 0
12
fi
13

  
14
test -f pylint.out && cp pylint.out pylint.out.prev
15
pylint -f parseable --rcfile ${PYLINT_RC} "$@" | tee pylint.out || /bin/true
16
test -f pylint.out.prev && (diff pylint.out.prev pylint.out | grep '^[><]' | grep .py) || /bin/true
tox.ini
1
[tox]
2
envlist = coverage-django18-pylint,coverage-django111
3
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/chrono/
4

  
5
[testenv]
6
usedevelop =
7
  coverage: True
8
  nocoverage: False
9
setenv =
10
  DJANGO_SETTINGS_MODULE=chrono.settings
11
  CHRONO_SETTINGS_FILE=tests/settings.py
12
  coverage: COVERAGE=--junitxml=test_results.xml --cov-report xml --cov=chrono/
13
deps =
14
  django18: django>=1.8,<1.9
15
  django111: django>=1.11,<1.12
16
  pytest-cov
17
  pytest-django
18
  pytest
19
  pytest-capturelog
20
  WebTest
21
  mock
22
  httmock
23
  pylint
24
  pylint-django
25
  django-webtest
26
  django-mellon
27
commands =
28
  ./getlasso.sh
29
  py.test {env:COVERAGE:} {posargs:tests/}
30
  pylint: ./pylint.sh chrono/
0
-