forked from LMFDB/lmfdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·62 lines (53 loc) · 1.8 KB
/
test.sh
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
#!/usr/bin/env bash
# This script runs nosetests for the whole project.
# It also generates a coverage report when the "coverage" module is installed.
# including a HTML report
# Note: to run the tests, sage must be in your path. If necessary do
# export PATH=$PATH:/path/to/sage
# To run it, first install or upgrade "nose", "unittest2" "coverage" and "pyflakes".
# e.g. $ pip install --user -U nose coverage unittest2 pyflakes
# or inside the Sage environment: $ easy_install -U nose
# $ easy_install -U coverage
# $ easy_install -U unittest2
# $ easy_install -U pyflakes
# Second, call it in three ways, either
# $ ./test.sh to test all
# or
# $ ./test.sh coverage
# to test all and report test coverage
# or (for example)
# $ ./test.sh lmfdb/knowledge
# to test only a part of LMFDB
cd `dirname "$0"`
# get rid of all cached .pyc files!
find . -name '*.pyc' -delete
WHAT=''
COVER=''
if [[ "$1" == "coverage" ]]; then
rm -rf lmfdb/cover
COVER='--with-coverage --cover-erase --cover-package=lmfdb --cover-html'
else
WHAT="$@"
fi
echo "Running pyflakes..."
read PYFLAKES_ERRCNT < <(find . | grep "\.py$" | xargs pyflakes 2>&1 | tee /dev/stderr | grep "py:" -c)
if [[ $PYFLAKES_ERRCNT > 0 ]]; then
echo "WARNING: pyflakes reported $PYFLAKES_ERRCNT error(s)"
else
echo "pyflakes is happy"
fi
ARGS='-v -s --testmatch="(?:^|\/)[Tt]est_"'
SAGE_COMMAND=$SAGE
if [[ "$SAGE_COMMAND" == "" ]]; then
SAGE_COMMAND=sage
fi
echo "Using Sage command $SAGE_COMMAND"
if [[ -n $WHAT ]]; then
eval "$SAGE_COMMAND -sh -c 'nosetests $ARGS $WHAT $COVER'"
else
cd lmfdb
eval "$SAGE_COMMAND -sh -c 'nosetests $ARGS $COVER'"
fi
if [[ $PYFLAKES_ERRCNT > 0 ]]; then
printf "\nWARNING: pyflakes reported $PYFLAKES_ERRCNT error(s)\n"
fi