This repository has been archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
test
executable file
·69 lines (58 loc) · 1.74 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
set -eu
export TOP=$(readlink -f ${TOP:-.})
export SITEPACKAGES=${SITEPACKAGES:-.}
NCPU=$(getconf _NPROCESSORS_CONF)
if python -c 'import platform; exit(not(platform.python_implementation() == "PyPy"))'; then
PYPY=true
else
PYPY=false
fi
coverage-report() {
# reporting:
cd $TOP
coverage combine
python ./tests/testing/fix_coverage.py '/site-packages/' $TOP
unset COVERAGE_PROCESS_START
coverage combine
# for unknown reasons, I have to do the fixup again after stopping profiling to avoid stray test results
python ./tests/testing/fix_coverage.py '/site-packages/' $TOP
if ${CI:-false}; then
./CI/coverage
fi
coverage report --fail-under 90
coverage report --fail-under 100 venv_update.py pip_faster.py
}
fail() {
if ! $PYPY; then coverage-report; fi
echo '[31;1mFAIL[m'
}
trap fail ERR
if [ "$*" ]; then
set -- -n0 "$@"
else
# default arguments
set -- $TOP/tests $SITEPACKAGES/{venv_update,pip_faster}.py
fi
if "${CI:-false}"; then
# Under CI, we don't get to use all the CPU.
NCPU=$((NCPU > 5? NCPU/5 : 1))
fi
set -x
# unquoted is intentional. we want to expand words.
set -- ${PYTEST_OPTIONS:-} "$@"
if $PYPY; then
# coverage under pypy takes too dang long:
# https://bitbucket.org/pypy/pypy/issue/1871/10x-slower-than-cpython-under-coverage#comment-14404182
# pypy can oom on travis; let's use less workers
py.test -n $NCPU "$@"
else
# clean up anything left behind from before:
rm -f $TOP/.coverage $TOP/.coverage.*
# See: http://nedbatchelder.com/code/coverage/subprocess.html
export COVERAGE_PROCESS_START=$TOP/.coveragerc
# run the tests!
py.test -n $NCPU "$@"
coverage-report
fi
echo '[37;1;42mSUCCESS[m'