diff --git a/ci.sh b/ci.sh index f808decdae..5729f99381 100755 --- a/ci.sh +++ b/ci.sh @@ -10,6 +10,7 @@ export PYRIGHT_PYTHON_IGNORE_WARNINGS=1 echo "::group::Environment" uname -a env | sort +date echo "::endgroup::" # Curl's built-in retry system is not very robust; it gives up on lots of @@ -126,9 +127,34 @@ else # support subprocess spawning with coverage.py echo "import coverage; coverage.process_startup()" | tee -a "$INSTALLDIR/../sitecustomize.py" + # set the location of .coveragerc for multi-process coverage to work + COVERAGE_PROCESS_START=$(pwd)/../pyproject.toml + + PYTEST_CMD="pytest -r a -p trio._tests.pytest_plugin --junitxml=../test-results.xml --run-slow --verbose --durations=10 $flags ${INSTALLDIR}" + + RUN_TESTS="coverage run --rcfile=../pyproject.toml -m $PYTEST_CMD" + + # timeout can be changed with an environment variable, but if empty or unset + # default to 9m to not hit 10m limit + if [ -z "$TESTS_TIMEOUT" ]; then + TESTS_TIMEOUT=7m + fi + + # if available, timeout coverage/pytest with SIGINT before the CI runner kills it, to + # get in-progress data and print out the slowest tests + if type timeout > /dev/null; then + RUN_TESTS="timeout --signal=INT $TESTS_TIMEOUT $RUN_TESTS" + elif type gtimeout > /dev/null; then + RUN_TESTS="gtimeout --signal=INT $TESTS_TIMEOUT $RUN_TESTS" + fi + + # print datetime + date + echo "::endgroup::" echo "::group:: Run Tests" - if COVERAGE_PROCESS_START=$(pwd)/../pyproject.toml coverage run --rcfile=../pyproject.toml -m pytest -r a -p trio._tests.pytest_plugin --junitxml=../test-results.xml --run-slow ${INSTALLDIR} --verbose --durations=10 $flags; then + + if $RUN_TESTS; then PASSED=true else PASSED=false