diff --git a/.evergreen/combine-coverage.sh b/.evergreen/combine-coverage.sh new file mode 100644 index 000000000..6ffa88ee9 --- /dev/null +++ b/.evergreen/combine-coverage.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Coverage combine merges (and removes) all the coverage files and +# generates a new .coverage file in the current directory. + +set -o xtrace # Write all commands first to stderr +set -o errexit # Exit the script with error if any of the commands fail + +. .evergreen/utils.sh + +if [ -z "$PYTHON_BINARY" ]; then + PYTHON_BINARY=$(find_python3) +fi + +createvirtualenv "$PYTHON_BINARY" covenv +# coverage 7.3 dropped support for Python 3.7, keep in sync with run-tests.sh +pip install -q "coverage<7.3" + +pip list +ls -la coverage/ + +python -m coverage combine coverage/coverage.* +python -m coverage html -d htmlcov diff --git a/.evergreen/config.yml b/.evergreen/config.yml index c3340211a..bcd8846bd 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -131,12 +131,7 @@ functions: working_dir: "src" script: | ${PREPARE_SHELL} - set -o xtrace - # Coverage combine merges (and removes) all the coverage files and - # generates a new .coverage file in the current directory. - ls -la coverage/ - /opt/python/3.7/bin/python3 -m coverage combine coverage/coverage.* - /opt/python/3.7/bin/python3 -m coverage html -d htmlcov + bash .evergreen/combine-coverage.sh # Upload the resulting html coverage report. - command: shell.exec params: diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index 9ae5c78cc..3e23a2549 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -258,7 +258,8 @@ python -c 'import sys; print(sys.version)' # Only cover CPython. PyPy reports suspiciously low coverage. PYTHON_IMPL=$($PYTHON -c "import platform; print(platform.python_implementation())") if [ -n "$COVERAGE" ] && [ "$PYTHON_IMPL" = "CPython" ]; then - python -m pip install pytest-cov "coverage" + # coverage 7.3 dropped support for Python 3.7, keep in sync with combine-coverage.sh. + python -m pip install pytest-cov "coverage<7.3" TEST_ARGS="$TEST_ARGS --cov pymongo --cov-branch --cov-report term-missing:skip-covered" fi