Merge pull request #525 from moreati/coverage_report_always

Generate coverage report even if some tests fail
pull/530/head
dw 6 years ago committed by GitHub
commit ea83a1b677
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -435,6 +435,9 @@ Core Library
meant an extra roundtrip and ~20KiB of data was wasted for any context that meant an extra roundtrip and ~20KiB of data was wasted for any context that
imported :mod:`mitogen.parent`. imported :mod:`mitogen.parent`.
* `#523 <https://github.com/dw/mitogen/issues/523>` : the test suite didn't
generate a code coverage report if any test failed.
Thanks! Thanks!
~~~~~~~ ~~~~~~~

@ -1,11 +1,27 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# From https://unix.stackexchange.com/a/432145
# Return the maximum of one or more integer arguments
max() {
local max number
max="$1"
for number in "${@:2}"; do
if ((number > max)); then
max="$number"
fi
done
printf '%d\n' "$max"
}
echo '----- ulimits -----' echo '----- ulimits -----'
ulimit -a ulimit -a
echo '-------------------' echo '-------------------'
echo echo
set -o errexit # Don't use errexit, so coverage report is still generated when tests fail
set -o pipefail set -o pipefail
if [ ! "$UNIT2" ]; then if [ ! "$UNIT2" ]; then
@ -27,6 +43,7 @@ fi
--pattern '*_test.py' \ --pattern '*_test.py' \
"$@" "$@"
fi fi
MITOGEN_TEST_STATUS=$?
} }
# Second run appends. This is since 'discover' treats subdirs as packages and # Second run appends. This is since 'discover' treats subdirs as packages and
@ -47,7 +64,11 @@ fi
--pattern '*_test.py' \ --pattern '*_test.py' \
"$@" "$@"
fi fi
ANSIBLE_TEST_STATUS=$?
} }
[ "$NOCOVERAGE" ] || coverage html [ "$NOCOVERAGE" ] || coverage html
[ "$NOCOVERAGE" ] || echo coverage report is at "file://$(pwd)/htmlcov/index.html" [ "$NOCOVERAGE" ] || echo coverage report is at "file://$(pwd)/htmlcov/index.html"
# Exit with a non-zero status if any test run did so
exit "$(max $MITOGEN_TEST_STATUS $ANSIBLE_TEST_STATUS)"

Loading…
Cancel
Save