tox: generate only one coverage and junit file (#32961)

This commit is contained in:
Benjamin Dauvergne 2019-05-10 10:22:42 +02:00
parent b7d0c63b6b
commit 20e0f61b6b
4 changed files with 27 additions and 41 deletions

17
Jenkinsfile vendored
View File

@ -10,20 +10,23 @@ pipeline {
stage('Unit Tests') {
steps {
sh "mkdir ${env.TMPDIR}"
sh './jenkins.sh'
sh """
virtualenv -p python3 ${env.TMPDIR}/venv/
. ${env.TMPDIR}/venv/bin/activate
${env.TMPDIR}/venv/bin/pip install tox
PGPORT=`python -c 'import struct; import socket; s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'` pg_virtualenv -o fsync=off ${env.TMPDIR}/venv/bin/tox -rv"""
}
post {
always {
script {
utils = new Utils()
utils.publish_coverage('coverage-*.xml')
utils.publish_coverage_native(
'index.html', 'htmlcov-coverage-dj18-authentic-pg', 'Coverage a2')
utils.publish_coverage_native(
'index.html', 'htmlcov-coverage-dj18-rbac-pg', , 'Coverage rbac')
utils.publish_coverage('coverage.xml')
utils.publish_coverage_native('index.html')
utils.publish_pylint('pylint.out')
sh './merge-junit-results.py junit-*.xml >junit.xml'
sh 'rm junit-*.xml'
}
junit 'junit-*.xml'
junit 'junit.xml'
}
}
}

View File

@ -1,14 +0,0 @@
#!/bin/bash
set -e
for DIRECTORY in "htmlcov" "htmlcov-coverage-dj18-authentic-pg" "htmlcov-coverage-dj18-rbac-pg" "venv"
do
if [ -d "$DIRECTORY" ]; then
rm -r $DIRECTORY
fi
done
virtualenv venv
venv/bin/pip install tox
PGPORT=`python -c 'import struct; import socket; s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'` pg_virtualenv -o fsync=off venv/bin/tox -rv

View File

@ -3,8 +3,6 @@
# Corey Goldberg, Dec 2012
#
from __future__ import print_function
import os
import sys
import xml.etree.ElementTree as ET
@ -42,6 +40,9 @@ def merge_results(xml_files):
tests += int(test_suite.attrib['tests'])
errors += int(test_suite.attrib['errors'])
time += float(test_suite.attrib['time'])
name = test_suite.attrib.get('name', '')
for child in test_suite.getchildren():
child.attrib['classname'] = '%s-%s' % (name, child.attrib.get('classname', ''))
cases.append(test_suite.getchildren())
new_root = ET.Element('testsuite')

32
tox.ini
View File

@ -8,21 +8,28 @@ toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/authentic/
envlist = py27-coverage-{dj18,dj111}-authentic-{pg,sqlite}-{oldldap,},py27-coverage-{dj18,dj111}-rbac-{pg,sqlite}
[testenv]
# django.contrib.auth is not tested it does not work with our templates
whitelist_externals =
/bin/mv
setenv =
AUTHENTIC2_SETTINGS_FILE=tests/settings.py
BRANCH_NAME={env:BRANCH_NAME:}
sqlite: DB_ENGINE=django.db.backends.sqlite3
pg: DB_ENGINE=django.db.backends.postgresql_psycopg2
coverage: COVERAGE=--junitxml=junit-{envname}.xml --cov-report xml --cov-report html --cov=src/ --cov-config .coveragerc
authentic: DJANGO_SETTINGS_MODULE=authentic2.settings
rbac: DJANGO_SETTINGS_MODULE=django_rbac.test_settings
authentic: TESTS=tests/
authentic-oldldap: TESTS=tests/test_ldap.py
rbac: TESTS=tests_rbac/
sqlite: DB_ENGINE=django.db.backends.sqlite3
pg: DB_ENGINE=django.db.backends.postgresql_psycopg2
JUNIT={tty::-o junit_suite_name={envname} --junit-xml=junit-{envname}.xml}
coverage: COVERAGE=--cov=src --cov-branch --cov-append --cov-report xml --cov-report html
fast: FAST=--nomigrations
reusedb: REUSEDB=--reuse-db
A2_TESTS=tests
oldldap: A2_TESTS=tests/test_ldap.py
# support for pg_virtualenv
PGPORT={env:PGPORT:}
PGHOST={env:PGHOST:}
PGUSER={env:PGUSER:}
@ -60,18 +67,7 @@ deps =
oldldap: python-ldap<3
commands =
./getlasso.sh
authentic: py.test {env:FAST:} {env:REUSEDB:} {env:COVERAGE:} {posargs:{env:A2_TESTS:tests/} --random-group}
rbac: py.test {env:FAST:} {env:REUSEDB:} {env:COVERAGE:} {posargs:tests_rbac/}
coverage: mv coverage.xml coverage-{envname}.xml
coverage-dj18-authentic-pg: mv htmlcov htmlcov-coverage-dj18-authentic-pg
coverage-dj18-rbac-pg: mv htmlcov htmlcov-coverage-dj18-rbac-pg
coverage-dj18-authentic-pg: ./pylint.sh src/authentic2/
[testenv:check]
deps = prospector[with_pyroma]
commands = python -m compileall -fq {toxinidir}/src
prospector --with-tool pyroma {toxinidir}/src
rbac,authentic: py.test {env:FAST:} {env:REUSEDB:} {env:COVERAGE:} {env:JUNIT:} {posargs:{env:TESTS} --random-group}
[pytest]
filterwarnings =