Check the test-suite specific coverage file, and upload it earlier in the process

This commit is contained in:
Calen Pennington
2019-07-24 13:13:30 -04:00
parent f3daa42340
commit fdd212248a
2 changed files with 9 additions and 6 deletions

View File

@@ -331,12 +331,14 @@ def coverage():
report_dir = Env.REPORT_DIR
rcfile = Env.PYTHON_COVERAGERC
if not (report_dir / '.coverage').isfile():
combined_report_file = report_dir / '{}.coverage'.format(os.environ.get('TEST_SUITE', ''))
if not combined_report_file.isfile():
# This may be that the coverage files were generated using -p,
# try to combine them to the one file that we need.
sh(u"coverage combine --rcfile={}".format(rcfile))
if not os.path.getsize(report_dir / '.coverage') > 50:
if not os.path.getsize(combined_report_file) > 50:
# Check if the .coverage data file is larger than the base file,
# because coverage combine will always at least make the "empty" data
# file even when there isn't any data to be combined.

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -e
set -x
# This script generates coverage and diff cover reports, and optionally
# reports this data to codecov.io. The following environment variables must be
@@ -14,6 +15,10 @@ source scripts/jenkins-common.sh
# Get the diff coverage and html reports for unit tests
paver coverage -b $TARGET_BRANCH
if [[ -n "$PYTEST_CONTEXTS" ]]; then
paver upload_coverage_to_s3
fi
# Test for the CodeCov API token
if [ -z $CODE_COV_TOKEN ]; then
echo "codecov.io API token not set."
@@ -27,7 +32,3 @@ fi
# JUnit test reporter will fail the build
# if it thinks test results are old
touch `find . -name *.xml` || true
if [[ -n "$PYTEST_CONTEXTS" ]]; then
paver upload_coverage_to_s3
fi