summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-07-12 00:09:19 +0000
committerGerrit Code Review <review@openstack.org>2018-07-12 00:09:19 +0000
commit8716202480f640848ba8afae5b45c44c8511dd29 (patch)
treeb4bfadd96120fc2a5b012daaa036dd3acd7b1c26
parent1b9cd66f860c4cc3c4df3a46e6fa4b7c3192e018 (diff)
parent6f66893c2abb490971c4bc651ac1c6ce6c3b6753 (diff)
Merge "Switch the coverage tox target to stestr"
-rwxr-xr-x.testr.conf8
-rw-r--r--lower-constraints.txt1
-rwxr-xr-xtools/cover.sh26
-rw-r--r--tox.ini2
4 files changed, 23 insertions, 14 deletions
diff --git a/.testr.conf b/.testr.conf
deleted file mode 100755
index 077512e..0000000
--- a/.testr.conf
+++ /dev/null
@@ -1,8 +0,0 @@
1[DEFAULT]
2test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
3 OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
4 OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
5 ${PYTHON:-python} -m subunit.run discover $DISCOVER_DIRECTORY $LISTOPT $IDOPTION
6test_id_option=--load-list $IDFILE
7test_list_option=--list
8group_regex=([^\.]+\.)+
diff --git a/lower-constraints.txt b/lower-constraints.txt
index eec2ba4..bd9e814 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -146,7 +146,6 @@ stestr==1.0.0
146stevedore==1.20.0 146stevedore==1.20.0
147Tempita==0.5.2 147Tempita==0.5.2
148tenacity==4.9.0 148tenacity==4.9.0
149testrepository==0.0.20
150testresources==2.0.0 149testresources==2.0.0
151testscenarios==0.4 150testscenarios==0.4
152testtools==2.2.0 151testtools==2.2.0
diff --git a/tools/cover.sh b/tools/cover.sh
index 9b24e7d..ac3ddbf 100755
--- a/tools/cover.sh
+++ b/tools/cover.sh
@@ -22,15 +22,24 @@ show_diff () {
22 diff -U 0 $1 $2 | sed 1,2d 22 diff -U 0 $1 $2 | sed 1,2d
23} 23}
24 24
25package_name=${PACKAGE_NAME:-sahara}
26export PYTHON="coverage run --source ${package_name} --parallel-mode"
27
28run_coverage () {
29 find . -type f -name "*.pyc" -delete && coverage erase && \
30 stestr run "$*"
31 coverage combine
32}
33
25# Stash uncommitted changes, checkout master and save coverage report 34# Stash uncommitted changes, checkout master and save coverage report
26uncommitted=$(git status --porcelain | grep -v "^??") 35uncommitted=$(git status --porcelain | grep -v "^??")
27[[ -n $uncommitted ]] && git stash > /dev/null 36[[ -n $uncommitted ]] && git stash > /dev/null
28git checkout HEAD^ 37git checkout HEAD^
29 38
30baseline_report=$(mktemp -t sahara_coverageXXXXXXX) 39baseline_report=$(mktemp -t sahara_coverageXXXXXXX)
31find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*" 40run_coverage "$*"
32coverage report > $baseline_report 41coverage report > $baseline_report
33baseline_missing=$(awk 'END { print $3 }' $baseline_report) 42baseline_missing=$(awk '/^TOTAL/ { print $3 }' $baseline_report)
34 43
35# Checkout back and unstash uncommitted changes (if any) 44# Checkout back and unstash uncommitted changes (if any)
36git checkout - 45git checkout -
@@ -38,9 +47,12 @@ git checkout -
38 47
39# Generate and save coverage report 48# Generate and save coverage report
40current_report=$(mktemp -t sahara_coverageXXXXXXX) 49current_report=$(mktemp -t sahara_coverageXXXXXXX)
41find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*" 50run_coverage "$*"
42coverage report > $current_report 51coverage report > $current_report
43current_missing=$(awk 'END { print $3 }' $current_report) 52current_missing=$(awk '/^TOTAL/ { print $3 }' $current_report)
53
54coverage html -d cover
55coverage xml -o cover/coverage.xml
44 56
45# Show coverage details 57# Show coverage details
46allowed_missing=$((baseline_missing+ALLOWED_EXTRA_MISSING)) 58allowed_missing=$((baseline_missing+ALLOWED_EXTRA_MISSING))
@@ -49,7 +61,10 @@ echo "Allowed to introduce missing lines : ${ALLOWED_EXTRA_MISSING}"
49echo "Missing lines in master : ${baseline_missing}" 61echo "Missing lines in master : ${baseline_missing}"
50echo "Missing lines in proposed change : ${current_missing}" 62echo "Missing lines in proposed change : ${current_missing}"
51 63
52if [ $allowed_missing -gt $current_missing ]; 64if [ -z "$current_missing" ]; then
65 echo "No coverage found!"
66 exit_code=1
67elif [ $allowed_missing -gt $current_missing ];
53then 68then
54 if [ $baseline_missing -lt $current_missing ]; 69 if [ $baseline_missing -lt $current_missing ];
55 then 70 then
@@ -66,4 +81,5 @@ else
66fi 81fi
67 82
68rm $baseline_report $current_report 83rm $baseline_report $current_report
84
69exit $exit_code 85exit $exit_code
diff --git a/tox.ini b/tox.ini
index e9ff9ae..25aed17 100644
--- a/tox.ini
+++ b/tox.ini
@@ -17,6 +17,8 @@ passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
17 17
18[testenv:cover] 18[testenv:cover]
19basepython = python3 19basepython = python3
20setenv =
21 PACKAGE_NAME=sahara
20commands = {toxinidir}/tools/cover.sh {posargs} 22commands = {toxinidir}/tools/cover.sh {posargs}
21 23
22[testenv:debug-py27] 24[testenv:debug-py27]