forked from pycket/pycket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
travis.sh
executable file
·326 lines (272 loc) · 8.27 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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
#/bin/sh
#
# utah or northwestern for prerelease, racket for stable
DLHOST=utah
#DLHOST=northwestern
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
GREEN=$(tput setaf 2)
NO_ATTRIB=$(tput sgr0)
RIGHT_SIDE=$(tput cols)
print_console() {
printf '%s%*s%s\n' "$GREEN" $RIGHT_SIDE "[$1]" "$NO_ATTRIB"
}
############### test targets ################################
do_old_tests() {
./pypy-c ../pypy/pytest.py pycket --ignore=pycket/test/test_entry_point.py
}
do_new_tests_without_expander_linklet() {
./pypy-c ../pypy/pytest.py pycket --new --ignore=pycket/test/test_old_entry_point.py
}
do_new_tests_using_expander_linklet() {
./pypy-c ../pypy/pytest.py pycket --new --use-expander --ignore=pycket/test/test_old_entry_point.py
}
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 -X gcov search
set -e
echo '>> Testing whether coverage is over 80%'
coverage report -i --fail-under=80 --omit='pycket/test/*','*__init__*'
}
do_translate_pycket_c() {
print_console do_translate
./pypy-c ../pypy/rpython/bin/rpython --batch -Ojit --translation-jit_opencoder_model=big targetpycket.py
#do_performance_smoke
}
do_translate_pycket_c_linklets() {
print_console do_translate_linklets
./pypy-c ../pypy/rpython/bin/rpython --batch -Ojit --translation-jit_opencoder_model=big targetpycket.py --linklets
}
# 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 1.5 pycket/test/hashtable-benchmark.rkt
# echo ; echo ">> Smoke cleared" ; echo
# }
do_translate_nojit() {
print_console do_translate_nojit
./pypy-c ../pypy/rpython/bin/rpython --batch targetpycket.py
}
do_translate_nojit_linklets() {
print_console do_translate_nojit_linklets
./pypy-c ../pypy/rpython/bin/rpython --batch targetpycket.py --linklets
}
do_linklets_load_racket_base() {
print_console translating_with_linklets
./pypy-c ../pypy/rpython/bin/rpython --batch -Ojit --translation-jit_opencoder_model=big targetpycket.py --linklets
print_console loading_racket_base
./pycket-c-linklets --verbose 2 --collects /home/travis/build/pycket/pycket/racket/collects/ -c -I racket/base -e 1
}
############################################################
install_deps() {
print_console install_deps
pip install -I pytest-xdist || pip install -I --user pytest-xdist
if [ "$TEST_TYPE" = 'coverage' ]; then
pip install -I codecov pytest-cov || pip install -I codecov pytest-cov
fi
}
_activate_pypyenv() {
if [ -f ~/virtualenv/pypy/bin/activate ]; then
#deactivate 2>&1 >/dev/null || true
source ~/virtualenv/pypy/bin/activate
fi
}
install_pypy() {
PYPY_V=pypy2-v6.0.0-linux64
PYPY_PAK=$PYPY_V.tar.bz2
PYPY_URL=https://bitbucket.org/pypy/pypy/downloads/$PYPY_PAK
print_console "Acquiring pypy binary : "
wget $PYPY_URL
tar xjf $PYPY_PAK
ln -s $PYPY_V/bin/pypy pypy-c
#pip install -I --upgrade virtualenv
#virtualenv --no-wheel --no-setuptools --no-pip -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
}
fetch_racket() {
print_console "Fetching the latest Racket"
git clone https://github.com/racket/racket.git
}
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() {
print_console "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() {
## SET UP THE ENV VARS TO ACCESS RACKET LIBS
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
print_console "Missing command"
_help
exit 1
fi
COMMAND="$1"
shift
_activate_pypyenv
case "$COMMAND" in
prepare)
print_console "Preparing dependencies : "
install_pypy
#fetch_racket ####### FIXME
install_racket
install_deps
;;
install)
print_console "Fetching pypy and racket : "
fetch_pypy
prepare_racket ###### FIXME
;;
test)
export PYTHONPATH=$PYTHONPATH:../pypy:pycket
cp ../pypy/pytest.ini . 2>&1 >/dev/null || true
if [ -z "$1" ]; then
print_console "Please tell what to test, see .travis.yml"
_help
exit 1
else
TEST_TYPE="$1"
shift
fi
print_console "Running $TEST_TYPE"
do_$TEST_TYPE
;;
*)
_help
;;
esac