forked from pycket/pycket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis.sh
executable file
·280 lines (236 loc) · 6.66 KB
/
travis.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#/bin/sh
#
# utah or northwestern for prerelease, racket for stable
DLHOST=utah
RACKET_VERSION=current
COVERAGE_TESTSUITE='test'
#
set -e
_help() {
cat <<EOF
$0 <command>
command is one of
prepare Do anything necessary to allow installation
install Install direct prerequisites
test <what> Test (may include building, testing, coverage)
tests Run pytest tests
coverage Run pytest coverage report and upload
translate Translate pycket with jit
translate_nojit_and_racket_tests
Translate pycket without jit and run racket test
EOF
}
_time_gnu() {
export TIME="%e"
(/usr/bin/time "$@" 3>&2 2>&1 1>&3) 2>/dev/null
}
_time_bsd() {
(/usr/bin/time -p "$@" 3>&2 2>&1 1>&3) 2>/dev/null | \
grep '^real' | \
awk '{ print $2; }'
}
_time_builtin() {
#
# so there's no /usr/bin/time.
# lets hope we have a bash/zsh/csh which has a time builtin thats knows -p
#
(time -p "$@" >/dev/null) 2>&1 | \
grep '^real' | \
awk '{ print $2; }'
}
export LANG=C LC_ALL=C
# config
if type timeout >/dev/null 2>/dev/null; then
TIMEOUT=timeout
else
# hope..
TIMEOUT=gtimeout
fi
if [ ! -e /usr/bin/time ]; then # oh travis...
TIME_IT=_time_builtin
elif /usr/bin/time --version 2>/dev/null >/dev/null; then
TIME_IT=_time_gnu
else
TIME_IT=_time_bsd
fi
############### test targets ################################
do_tests() {
py.test -n 3 --duration 20 pycket
}
do_coverage() {
set +e
# PyPy's pytest modifications clash with recent pytest-cov/coverage releases
# So remove them on the CI.
rm -rf ../pypy/*pytest*
py.test --assert=plain -n 3 -k "$COVERAGE_TESTSUITE" --cov . --cov-report=term pycket
codecov --no-fail -X gcov
set -e
echo '>> Testing whether coverage is over 80%'
coverage report -i --fail-under=80 --omit='pycket/test/*','*__init__*'
}
do_translate() {
../pypy/rpython/bin/rpython -Ojit --batch targetpycket.py
do_performance_smoke
}
do_performance_smoke() {
_smoke() {
RATIO=$1
shift
echo "> $1"
raco make $1 >/dev/null
RACKET_TIME=$($TIME_IT racket "$@")
echo " Racket took $RACKET_TIME"
TARGET_TIME=$(awk "BEGIN { print ${RATIO} * ${RACKET_TIME}; }" )
KILLME_TIME=$(awk "BEGIN { print ${TARGET_TIME} * 5; }")
racket -l pycket/expand $1 2>/dev/null >/dev/null
# $TIMEOUT -k$KILLME_TIME $KILLME_TIME ./pycket-c "$@"
PYCKET_TIME=$($TIME_IT ./pycket-c "$@")
echo " Pycket took $PYCKET_TIME (should be < $TARGET_TIME)"
[ "OK" = "$(awk "BEGIN { print ($PYCKET_TIME < $TARGET_TIME ? \"OK\" : \"NO\"); }")" ]
}
echo ; echo ">> Performance smoke test" ; echo
echo ">>> Preparing racket files to not skew test"
expand_rkt yes
echo ">>> Smoke"
_smoke 1.5 pycket/test/fannkuch-redux.rkt 10
_smoke 0.7 pycket/test/triangle.rkt
_smoke 1.8 pycket/test/earley.rkt
_smoke 2.0 pycket/test/nucleic2.rkt
_smoke 2.5 pycket/test/nqueens.rkt
_smoke 2.5 pycket/test/treerec.rkt
_smoke 0.5 pycket/test/hashtable-benchmark.rkt
echo ; echo ">> Smoke cleared" ; echo
}
do_translate_nojit_and_racket_tests() {
../pypy/rpython/bin/rpython --batch targetpycket.py
../pypy/pytest.py pycket/test/racket-tests.py
}
############################################################
install_deps() {
pip install pytest-xdist || pip install --user pytest-xdist
if [ $TEST_TYPE = 'coverage' ]; then
pip install codecov pytest-cov || pip install codecov pytest-cov
fi
}
_activate_pypyenv() {
if [ -f ~/virtualenv/pypy/bin/activate ]; then
deactivate || true
source ~/virtualenv/pypy/bin/activate
fi
}
install_pypy() {
# PYPY_PAK=pypy-c-jit-latest-linux64.tar.bz2
# PYPY_URL=http://buildbot.pypy.org/nightly/release-4.0.x/pypy-c-jit-latest-linux64.tar.bz2
PYPY_PAK=pypy-4.0.0-linux64.tar.bz2
PYPY_URL=https://bitbucket.org/pypy/pypy/downloads/$PYPY_PAK
wget $PYPY_URL
tar xjf $PYPY_PAK
# ln -s pypy-c-*-linux64 pypy-c
ln -s pypy-4.0.0-linux64 pypy-c
pip install --upgrade virtualenv
virtualenv --no-wheel --no-setuptools -p pypy-c/bin/pypy ~/virtualenv/pypy
# fix virtualenv...
rm ~/virtualenv/pypy/bin/libpypy-c.so
cp pypy-c/bin/libpypy-c.so ~/virtualenv/pypy/bin/libpypy-c.so
_activate_pypyenv
}
install_racket() {
###
# Get and install Racket
###
## Debian
# sudo add-apt-repository -y ppa:plt/racket
# sudo apt-get update
# sudo apt-get install -qq racket
if [ "$(lsb_release -s -i)" = 'Debian' ]; then
OS_PART=i386-linux-wheezy
else
OS_PART=x86_64-linux-precise
fi
case "$DLHOST" in
utah)
INSTALLER=racket-$RACKET_VERSION-$OS_PART.sh
URL=http://www.cs.utah.edu/plt/snapshots/current/installers/$INSTALLER
;;
northwestern)
INSTALLER=racket-test-$RACKET_VERSION-$OS_PART.sh
URL=http://plt.eecs.northwestern.edu/snapshots/current/installers/$INSTALLER
;;
racket)
INSTALLER=racket-$RACKET_VERSION-$OS_PART.sh
URL=http://mirror.racket-lang.org/installers/$RACKET_VERSION/$INSTALLER
;;
*) exit 1;;
esac
wget $URL
sh $INSTALLER --in-place --dest racket
}
fetch_pypy() {
###
# Prepare pypy
###
wget https://bitbucket.org/pypy/pypy/get/default.tar.bz2 -O `pwd`/../pypy.tar.bz2 || \
wget https://bitbucket.org/pypy/pypy/get/default.tar.bz2 -O `pwd`/../pypy.tar.bz2
tar -xf `pwd`/../pypy.tar.bz2 -C `pwd`/../
mv ../pypy-pypy* ../pypy
}
prepare_racket() {
raco pkg install -t dir pycket/pycket-lang/
}
expand_rkt() {
if [ $# -gt 0 ]; then
ALL=$1
shift
else
ALL="no"
fi
BASE_MODULES=$(racket -e '(displayln (path->string (path-only (collection-file-path "base.rkt" "racket"))))')
if [ $ALL != "no" ]; then
SYNTAX_MODULES=$(racket -e '(displayln (path->string (path-only (collection-file-path "wrap-modbeg.rkt" "syntax"))))')
fi
find $BASE_MODULES $SYNTAX_MODULES -type f -name \*.rkt -print0 | \
while IFS= read -r -d '' F; do
if [ ! -f "$F.json" ]; then
printf "%s" .
racket -l pycket/expand $F 2>/dev/null >/dev/null || true
fi
done
}
############################################################
if [ $# -lt 1 ]; then
echo "Missing command"
_help
exit 1
fi
COMMAND="$1"
shift
_activate_pypyenv
case "$COMMAND" in
prepare)
echo "Preparing dependencies"
install_pypy
install_racket
install_deps
;;
install)
echo "Preparing pypy and racket"
fetch_pypy
prepare_racket
;;
test)
export PYTHONPATH=$PYTHONPATH:../pypy:pycket
if [ -z "$1" ]; then
echo "Please tell what to test, see .travis.yml"
_help
exit 1
else
TEST_TYPE="$1"
shift
fi
echo "Running $TEST_TYPE"
do_$TEST_TYPE
;;
*)
_help
;;
esac