Skip to content

Commit

Permalink
Merge pull request #525 from moreati/coverage_report_always
Browse files Browse the repository at this point in the history
Generate coverage report even if some tests fail
  • Loading branch information
dw committed Feb 9, 2019
2 parents d763570 + e7d70b1 commit ea83a1b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,9 @@ Core Library
meant an extra roundtrip and ~20KiB of data was wasted for any context that
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!
~~~~~~~
Expand Down
23 changes: 22 additions & 1 deletion run_tests
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
#!/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 -----'
ulimit -a
echo '-------------------'
echo

set -o errexit
# Don't use errexit, so coverage report is still generated when tests fail
set -o pipefail

if [ ! "$UNIT2" ]; then
Expand All @@ -27,6 +43,7 @@ fi
--pattern '*_test.py' \
"$@"
fi
MITOGEN_TEST_STATUS=$?
}

# Second run appends. This is since 'discover' treats subdirs as packages and
Expand All @@ -47,7 +64,11 @@ fi
--pattern '*_test.py' \
"$@"
fi
ANSIBLE_TEST_STATUS=$?
}

[ "$NOCOVERAGE" ] || coverage 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)"

0 comments on commit ea83a1b

Please sign in to comment.