Merge "Switch the coverage tox target to stestr"

This commit is contained in:
Zuul 2018-07-12 00:09:19 +00:00 committed by Gerrit Code Review
commit 8716202480
4 changed files with 23 additions and 14 deletions

View File

@ -1,8 +0,0 @@
[DEFAULT]
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
${PYTHON:-python} -m subunit.run discover $DISCOVER_DIRECTORY $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list
group_regex=([^\.]+\.)+

View File

@ -146,7 +146,6 @@ stestr==1.0.0
stevedore==1.20.0
Tempita==0.5.2
tenacity==4.9.0
testrepository==0.0.20
testresources==2.0.0
testscenarios==0.4
testtools==2.2.0

View File

@ -22,15 +22,24 @@ show_diff () {
diff -U 0 $1 $2 | sed 1,2d
}
package_name=${PACKAGE_NAME:-sahara}
export PYTHON="coverage run --source ${package_name} --parallel-mode"
run_coverage () {
find . -type f -name "*.pyc" -delete && coverage erase && \
stestr run "$*"
coverage combine
}
# Stash uncommitted changes, checkout master and save coverage report
uncommitted=$(git status --porcelain | grep -v "^??")
[[ -n $uncommitted ]] && git stash > /dev/null
git checkout HEAD^
baseline_report=$(mktemp -t sahara_coverageXXXXXXX)
find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*"
run_coverage "$*"
coverage report > $baseline_report
baseline_missing=$(awk 'END { print $3 }' $baseline_report)
baseline_missing=$(awk '/^TOTAL/ { print $3 }' $baseline_report)
# Checkout back and unstash uncommitted changes (if any)
git checkout -
@ -38,9 +47,12 @@ git checkout -
# Generate and save coverage report
current_report=$(mktemp -t sahara_coverageXXXXXXX)
find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*"
run_coverage "$*"
coverage report > $current_report
current_missing=$(awk 'END { print $3 }' $current_report)
current_missing=$(awk '/^TOTAL/ { print $3 }' $current_report)
coverage html -d cover
coverage xml -o cover/coverage.xml
# Show coverage details
allowed_missing=$((baseline_missing+ALLOWED_EXTRA_MISSING))
@ -49,7 +61,10 @@ echo "Allowed to introduce missing lines : ${ALLOWED_EXTRA_MISSING}"
echo "Missing lines in master : ${baseline_missing}"
echo "Missing lines in proposed change : ${current_missing}"
if [ $allowed_missing -gt $current_missing ];
if [ -z "$current_missing" ]; then
echo "No coverage found!"
exit_code=1
elif [ $allowed_missing -gt $current_missing ];
then
if [ $baseline_missing -lt $current_missing ];
then
@ -66,4 +81,5 @@ else
fi
rm $baseline_report $current_report
exit $exit_code

View File

@ -17,6 +17,8 @@ passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
[testenv:cover]
basepython = python3
setenv =
PACKAGE_NAME=sahara
commands = {toxinidir}/tools/cover.sh {posargs}
[testenv:debug-py27]