-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
318 lines (269 loc) · 6.41 KB
/
run
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
#!/usr/bin/env bash
# Default Python Versions
# shellcheck source=bin/default_pythons
source "bin/default_pythons"
testAirflow() {
export SLUGIFY_USES_TEXT_UNIDECODE="yes"
compile "airflow"
assertCaptured "apache-airflow==1.10.2"
assertCapturedSuccess
}
testPipenv() {
compile "pipenv"
assertCapturedSuccess
}
testPipenvLock() {
compile "pipenv-lock"
assertCapturedSuccess
}
testPipenvVersion() {
compile "pipenv-version"
assertCaptured $DEFAULT_PYTHON_VERSION
assertCapturedSuccess
}
testPipenvVersion2() {
compile "pipenv-version2"
assertCaptured $LATEST_27
assertCapturedSuccess
}
testPipenvFullVersion() {
compile "pipenv-full-version"
assertCaptured "3.6.3"
assertCapturedSuccess
}
testNoRequirements() {
compile "no-requirements"
assertCapturedError
}
testCollectstatic() {
compile "collectstatic"
assertCaptured "collectstatic"
}
testGEOS() {
export BUILD_WITH_GEO_LIBRARIES=1
compile "geos"
assertCaptured "geos"
assertCapturedSuccess
}
testNLTK() {
# NOTE: This is a RuntimeWarning emitted by Python 3's runpy.py script
# which is what is used when you call `python -m <module>`. This is due to
# how nltk imports things. It's not actually an error, but it would probably
# be bad to silence in Production.
export PYTHONWARNINGS="ignore::RuntimeWarning"
compile "nltk"
assertCaptured "[nltk_data] Downloading package city_database" "STD_ERR"
assertCapturedSuccess
}
testSetupPy() {
compile "setup-py"
assertCaptured "maya"
assertCapturedSuccess
}
testStandardRequirements() {
compile "requirements-standard"
assertCaptured "requests"
assertCapturedSuccess
}
testPsycopg2() {
compile "psycopg2"
assertCaptured "psycopg2"
assertCapturedSuccess
}
testCffi() {
compile "cffi"
assertCaptured "cffi"
assertCapturedSuccess
}
testPylibmc() {
compile "pylibmc"
assertCaptured "pylibmc"
assertCapturedSuccess
}
testPythonDefault() {
updateVersion "pythonDefault" $DEFAULT_PYTHON_VERSION
compile "pythonDefault"
assertCaptured $DEFAULT_PYTHON_VERSION
assertNotCaptured "security update"
assertCapturedSuccess
}
testPython2() {
updateVersion "python2" $LATEST_27
echo $LATEST_27 > "runtime.txt"
compile "python2"
assertCaptured $LATEST_27
assertNotCaptured "security update"
assertCapturedSuccess
}
testPython2_warn() {
compile "python2_warn"
assertCaptured "python-2.7.15"
assertCaptured "security update!"
assertCapturedSuccess
}
testPython2_fail() {
compile "python2_fail"
assertCaptured "Aborting"
assertCapturedError
}
testPython3_4() {
if [[ $STACK != "cedar-14" ]]; then
updateVersion "python3_4" $LATEST_34
compile "python3_4"
assertCaptured $LATEST_34
assertNotCaptured "security update"
assertCapturedSuccess
fi
}
testPython3_4_warn() {
compile "python3_4_warn"
if [[ $STACK = "cedar-14" ]]; then
assertCaptured "python-3.4.0"
assertCaptured "security update!"
assertCapturedSuccess
else
assertCapturedError
fi
}
testPython3_4_fail() {
compile "python3_4_fail"
assertCaptured "Aborting"
assertCapturedError
}
testPython3_5() {
if [[ $STACK != "cedar-14" ]]; then
updateVersion "python3_5" $LATEST_35
compile "python3_5"
assertCaptured $LATEST_35
assertNotCaptured "security update"
assertCapturedSuccess
fi
}
testPython3_5_warn() {
compile "python3_5_warn"
if [[ $STACK = "cedar-14" ]]; then
assertCaptured "python-3.5.3"
assertCaptured "security update!"
assertCapturedError
else
assertCapturedError
fi
}
testPython3_5_fail() {
compile "python3_5_fail"
assertCaptured "Aborting"
assertCapturedError
}
testPython3_6() {
updateVersion "python3_6" $LATEST_36
compile "python3_6"
assertCaptured $LATEST_36
assertNotCaptured "security update"
assertCapturedSuccess
}
testPython3_6_warn() {
compile "python3_6_warn"
assertCaptured "python-3.6.7"
assertCaptured "security update!"
assertCapturedSuccess
}
testPython3_6_fail() {
compile "python3_6_fail"
assertCaptured "Aborting"
assertCapturedError
}
testPython3_7() {
updateVersion "python3_7" $LATEST_37
compile "python3_7"
if [[ $STACK = "cedar-14" ]]; then
assertCapturedError
else
assertNotCaptured "security update"
assertCaptured $LATEST_37
assertCapturedSuccess
fi
}
testPython3_7_warn() {
compile "python3_7_warn"
if [[ $STACK = "cedar-14" ]]; then
assertCapturedError
else
assertCaptured "python-3.7.1"
assertCaptured "security update!"
assertCapturedSuccess
fi
}
testPython3_7_fail() {
compile "python3_7_fail"
assertCaptured "Aborting"
assertCapturedError
}
testGitEgg() {
compile "git-egg"
assertCaptured "requests"
assertCapturedSuccess
}
testSmartRequirements() {
local cache_dir="$(mktmpdir)"
compile "requirements-standard" "$cache_dir"
assertFile "requests" ".heroku/python/requirements-declared.txt"
assertCapturedSuccess
compile "psycopg2" "$cache_dir"
assertCaptured "Uninstalling requests"
assertFile "psycopg2" ".heroku/python/requirements-declared.txt"
assertCapturedSuccess
}
testStackChange() {
local cache_dir="$(mktmpdir)"
mkdir -p "${cache_dir}/.heroku"
echo "different-stack" > "${cache_dir}/.heroku/python-stack"
compile "requirements-standard" "$cache_dir"
assertCaptured "clearing cache"
assertFile "$STACK" ".heroku/python-stack"
assertCapturedSuccess
}
pushd $(dirname 0) >/dev/null
popd >/dev/null
source $(pwd)/test/utils
mktmpdir() {
dir=$(mktemp -t testXXXXX)
rm -rf $dir
mkdir $dir
echo $dir
}
detect() {
capture $(pwd)/bin/detect $(pwd)/test/fixtures/$1
}
compile_dir=""
default_process_types_cleanup() {
file="/tmp/default_process_types"
if [ -f "$file" ]; then
rm "$file"
fi
}
compile() {
default_process_types_cleanup
bp_dir=$(mktmpdir)
compile_dir=$(mktmpdir)
cp -a $(pwd)/* ${bp_dir}
cp -a ${bp_dir}/test/fixtures/$1/. ${compile_dir}
capture ${bp_dir}/bin/compile ${compile_dir} ${2:-$(mktmpdir)} $3
}
compileDir() {
default_process_types_cleanup
local bp_dir=$(mktmpdir)
local compile_dir=${1:-$(mktmpdir)}
local cache_dir=${2:-$(mktmpdir)}
local env_dir=$3
cp -a $(pwd)/* ${bp_dir}
capture ${bp_dir}/bin/compile ${compile_dir} ${cache_dir} ${env_dir}
}
release() {
bp_dir=$(mktmpdir)
cp -a $(pwd)/* ${bp_dir}
capture ${bp_dir}/bin/release ${bp_dir}/test/fixtures/$1
}
assertFile() {
assertEquals "$1" "$(cat ${compile_dir}/$2)"
}
source $(pwd)/test/shunit2