Switch the coverage tox target to stestr
Use coverage+stestr for the cover tox target. With this change, testrepository is not required anymore. Change-Id: Ia294ee8003ccc10104f68777bea6921ff97bacef
This commit is contained in:
parent
b23abe2f96
commit
6f66893c2a
@ -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=([^\.]+\.)+
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user