forked from arskom/spyne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
executable file
·199 lines (165 loc) · 5.41 KB
/
run_tests.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/bin/bash -x
#
# Sets up a Python testing environment from scratch. Mainly written for Jenkins.
#
# Requirements:
# A working build environment inside the container with OpenSSL, bzip2,
# libxml2 and libxsld development files. Only tested on Linux variants.
#
# Last time we looked, for ubuntu, that meant:
# $ sudo apt-get install build-essential libssl-dev lilbbz2-dev \
# libxml2-dev libxslt-dev
#
# Usage:
# Example:
#
# $ PYFLAV=cpy-3.3 ./run_tests.sh
#
# Variables:
# - PYFLAV: Defaults to 'cpy-2.7'. See other values below.
# - WORKSPACE: Defaults to $PWD. It's normally set by Jenkins.
# - MAKEOPTS: Defaults to '-j2'.
# - MONOVER: Defaults to '2.11.4'. Only relevant for ipy-* flavors.
#
# Jenkins guide:
# 1. Create a 'Multi configuration project'.
# 2. Set up stuff like git repo the usual way.
# 3. In the 'Configuration Matrix' section, create a user-defined axis named
# 'PYVER'. and set it to the Python versions you'd like to test, separated
# by whitespace. For example: '2.7 3.3'
# 4. Add a new "Execute Shell" build step and type in './run_tests.sh'.
# 5. Add a new "Publish JUnit test report" post-build action and type in
# 'test_result.*.xml'
# 6. Add a new "Publish Cobertura Coverage Report" post-build action and type
# in 'coverage.xml'. Install the "Cobertura Coverage Report" plug-in if you
# don't see this option.
# 7. Have fun!
#
# Sanitization
[ -z "$PYFLAV" ] && PYFLAV=cpy-2.7;
[ -z "$MONOVER" ] && MONOVER=2.11.4;
[ -z "$WORKSPACE" ] && WORKSPACE="$PWD";
[ -z "$MAKEOPTS" ] && MAKEOPTS="-j2";
PYIMPL=(${PYFLAV//-/ });
PYVER=${PYIMPL[1]};
PYFLAV="${PYFLAV/-/}";
PYFLAV="${PYFLAV/./}";
if [ -z "$PYVER" ]; then
PYVER=${PYIMPL[0]};
PYIMPL=cpy;
PYFLAV=cpy${PYVER/./};
else
PYIMPL=${PYIMPL[0]};
fi
PYNAME=python$PYVER;
if [ -z "$FN" ]; then
declare -A URLS;
URLS["cpy26"]="2.6.9/Python-2.6.9.tgz";
URLS["cpy27"]="2.7.7/Python-2.7.7.tar.xz";
URLS["cpy33"]="3.3.5/Python-3.3.5.tar.xz";
URLS["cpy34"]="3.4.1/Python-3.4.1.tar.xz";
URLS["jyt25"]="2.5.3/jython-installer-2.5.3.jar";
URLS["jyt27"]="2.7-b2/jython-installer-2.7-b2.jar";
URLS["ipy27"]="ipy-2.7.4.zip";
FN="${URLS["$PYFLAV"]}";
if [ -z "$FN" ]; then
echo "Unknown Python version $PYFLAV";
exit 2;
fi;
fi;
# Initialization
IRONPYTHON_URL_BASE=https://github.com/IronLanguages/main/archive;
CPYTHON_URL_BASE=http://www.python.org/ftp/python;
JYTHON_URL_BASE=http://search.maven.org/remotecontent?filepath=org/python/jython-installer;
MAKE="make $MAKEOPTS";
# Set specific variables
if [ $PYIMPL == "cpy" ]; then
PREFIX="$(basename $(basename $FN .tgz) .tar.xz)";
elif [ $PYIMPL == "ipy" ]; then
PREFIX="$(basename $FN .zip)";
MONOPREFIX="$WORKSPACE/mono-$MONOVER"
XBUILD="$MONOPREFIX/bin/xbuild"
elif [ $PYIMPL == "jyt" ]; then
PYNAME=jython;
PREFIX="$(basename $FN .jar)";
fi;
# Set common variables
PYTHON="$WORKSPACE/$PREFIX/bin/$PYNAME";
EASY="$WORKSPACE/$PREFIX/bin/easy_install-$PYVER";
COVERAGE="$WORKSPACE/$PREFIX/bin/coverage-$PYVER";
COVERAGE2="$HOME/.local/bin/coverage-$PYVER"
# Set up requested python environment.
if [ $PYIMPL == 'cpy' ]; then
if [ ! -x "$PYTHON" ]; then
(
mkdir -p .data; cd .data;
wget -ct0 $CPYTHON_URL_BASE/$FN;
tar xf $(basename $FN);
cd "$PREFIX";
./configure --prefix="$WORKSPACE/$PREFIX" --with-pydebug;
$MAKE && make install;
);
fi;
elif [ $PYIMPL == 'jyt' ]; then
if [ ! -x "$PYTHON" ]; then
(
mkdir -p .data; cd .data;
FILE=$(basename $FN);
wget -O $FILE -ct0 "$JYTHON_URL_BASE/$FN";
java -jar $FILE -s -d "$WORKSPACE/$PREFIX"
);
fi
elif [ $PYIMPL == 'ipy' ]; then
# Set up Mono first
# See: http://www.mono-project.com/Compiling_Mono_From_Tarball
if [ ! -x "$XBUILD" ]; then
(
mkdir -p .data; cd .data;
wget -ct0 http://download.mono-project.com/sources/mono/mono-$MONOVER.tar.bz2
tar xf mono-$MONOVER.tar.bz2;
cd mono-$MONOVER;
./configure --prefix=$WORKSPACE/mono-$MONOVER;
$MAKE && make install;
);
fi
# Set up IronPython
# See: https://github.com/IronLanguages/main/wiki/Building#the-mono-runtime
if [ ! -x "$PYTHON" ]; then
(
mkdir -p .data; cd .data;
export PATH="$(dirname "$XBUILD"):$PATH"
wget -ct0 "$IRONPYTHON_URL_BASE/$FN";
unzip -q "$FN";
cd "main-$PREFIX";
$XBUILD /p:Configuration=Release Solutions/IronPython.sln || exit 1
mkdir -p "$(dirname "$PYTHON")";
echo 'mono "$PWD/bin/Release/ir.exe" "${@}"' > $PYTHON;
chmod +x $PYTHON;
) || exit 1;
fi;
fi;
# Set up distribute
if [ ! -x "$EASY" ]; then
(
mkdir -p .data; cd .data;
$PYTHON "$WORKSPACE"/bin/distribute_setup.py;
)
fi;
while read line; do $EASY $line; done < requirements/test_requirements.txt
if [ $PYIMPL == 'cpy' ]; then
# Set up coverage
if [ ! -x "$COVERAGE" ]; then
$EASY coverage
fi;
# Sometimes, easy_install works in mysterious ways...
if [ ! -x "$COVERAGE" ]; then
COVERAGE="$COVERAGE2"
fi;
# Run tests
bash -c "$COVERAGE run --source=spyne setup.py test; exit 0"
# Generate coverage report
$COVERAGE xml -i --omit=spyne/test/*;
else
# Run tests. No coverage in jython.
$PYTHON setup.py test;
fi;