1 | #!/usr/bin/env bash
|
2 | CWD=`dirname $0`
|
3 | CWD=`cd "$APP_DIR";pwd`
|
4 | W="${CWD}/bin/whiskey"
|
5 | E="${CWD}/example"
|
6 | ANY_SUITE="--tests $E/test-skipped.js"
|
7 | echo $ANY_SUITE
|
8 |
|
9 | $W -g ./example/global-setup.js ${ANY_SUITE} >/tmp/output 2>&1
|
10 | if [ $? -ne 0 ]; then
|
11 | echo "-g/--global-setup-teardown must base its paths from the invoking CWD"
|
12 | exit 1
|
13 | fi
|
14 |
|
15 | $W --tests $E/global-teardown.js >/tmp/output 2>&1
|
16 | if [ $? -ne 0 ]; then
|
17 | echo "A test suite without any tests should not break Whiskey."
|
18 | exit 1
|
19 | fi
|
20 | grep "globalTearDown was here" /tmp/output >/dev/null 2>&1
|
21 | if [ $? -ne 1 ]; then
|
22 | echo "Expected globalTearDown to be ignored."
|
23 | exit 1
|
24 | fi
|
25 |
|
26 | $W --tests $E/global-setup.js >/tmp/output 2>&1
|
27 | if [ $? -ne 0 ]; then
|
28 | echo "A test suite without any tests should not break Whiskey."
|
29 | exit 1
|
30 | fi
|
31 | grep "globalSetUp was here" /tmp/output >/dev/null 2>&1
|
32 | if [ $? -ne 1 ]; then
|
33 | echo "Expected globalSetUp to be ignored."
|
34 | exit 1
|
35 | fi
|
36 |
|
37 | $W -g $E/local-teardown.js ${ANY_SUITE} >/tmp/output 2>&1
|
38 | if [ $? -ne 0 ]; then
|
39 | echo "A file with a 'localTearDown' procedure should not kill Whiskey"
|
40 | exit 1
|
41 | fi
|
42 | grep "globalTearDown was here" /tmp/output >/dev/null 2>&1
|
43 | if [ $? -ne 1 ]; then
|
44 | echo "Expected localTearDown to have been ignored."
|
45 | exit 1
|
46 | fi
|
47 |
|
48 | $W -g $E/global-teardown-with-exception.js ${ANY_SUITE} >/tmp/output 2>&1
|
49 | if [ $? -ne 0 ]; then
|
50 | echo "Exceptions raised in globalTearDown should not kill Whiskey run."
|
51 | exit 1
|
52 | fi
|
53 |
|
54 | $W -g $E/global-teardown.js ${ANY_SUITE} >/tmp/output 2>&1
|
55 | if [ $? -ne 0 ]; then
|
56 | echo "Expected invokation of global teardown to not harm Whiskey."
|
57 | exit 1
|
58 | fi
|
59 | grep "globalTearDown was here" /tmp/output >/dev/null 2>&1
|
60 | if [ $? -ne 0 ]; then
|
61 | echo "Expected globalTearDown to have been invoked."
|
62 | exit 1
|
63 | fi
|
64 |
|
65 | $W -g $E/global-setup-with-failed-assertion.js ${ANY_SUITE}
|
66 | if [ $? -eq 0 ]; then
|
67 | echo "An assertion failure inside a global setup procedure should cause a test failure."
|
68 | exit 1
|
69 | fi
|
70 |
|
71 | $W -g $E/global-setup-with-exception.js ${ANY_SUITE}
|
72 | if [ $? -eq 0 ]; then
|
73 | echo "An exception inside a global setup procedure should cause a test failure."
|
74 | exit 1
|
75 | fi
|
76 |
|
77 | $W -g $E/local-setup.js ${ANY_SUITE} >/tmp/output 2>&1
|
78 | if [ $? -ne 0 ]; then
|
79 | echo "Expected invokation of global setup to not harm Whiskey."
|
80 | exit 1
|
81 | fi
|
82 | grep "globalSetUp was here" /tmp/output >/dev/null 2>&1
|
83 | if [ $? -ne 1 ]; then
|
84 | echo "Expected localSetUp to have been ignored."
|
85 | exit 1
|
86 | fi
|
87 |
|
88 | $W -g $E/global-setup.js ${ANY_SUITE} >/tmp/output 2>&1
|
89 | if [ $? -ne 0 ]; then
|
90 | echo "Expected invokation of global setup to not harm Whiskey."
|
91 | exit 1
|
92 | fi
|
93 | grep "globalSetUp was here" /tmp/output >/dev/null 2>&1
|
94 | if [ $? -ne 0 ]; then
|
95 | echo "Expected globalSetUp to have been invoked."
|
96 | exit 1
|
97 | fi
|
98 |
|
99 | $W -g ${ANY_SUITE}
|
100 | if [ $? -eq 0 ]; then
|
101 | echo "Missing parameter should cause whiskey to fail."
|
102 | exit 1
|
103 | fi
|
104 |
|
105 | $W --global-setup-teardown ${ANY_SUITE}
|
106 | if [ $? -eq 0 ]; then
|
107 | echo "Missing parameter should cause whiskey to fail."
|
108 | exit 1
|
109 | fi
|
110 |
|
111 | $W -g $E/empty-global-setup-teardown.js ${ANY_SUITE}
|
112 | if [ $? -ne 0 ]; then
|
113 | echo "An empty global setup/teardown file should be syntactically correct."
|
114 | echo "Also, a file used as such, but which doesn't export the appropriate"
|
115 | echo "procedures (globalSetUp or globalTearDown) should behave the same way."
|
116 | exit 1
|
117 | fi
|
118 |
|
119 | $W --global-setup-teardown $E/empty-global-setup-teardown.js ${ANY_SUITE}
|
120 | if [ $? -ne 0 ]; then
|
121 | echo "An empty global setup/teardown file should be syntactically correct."
|
122 | echo "Also, a file used as such, but which doesn't export the appropriate"
|
123 | echo "procedures (globalSetUp or globalTearDown) should behave the same way."
|
124 | exit 1
|
125 | fi
|
126 |
|
127 | $W -g $E/malformed-javascript-source.js ${ANY_SUITE}
|
128 | if [ $? -eq 0 ]; then
|
129 | echo "A malformed source should cause Whiskey to die early."
|
130 | exit 1
|
131 | fi
|
132 |
|
133 | START=$(date +%s)
|
134 | $W -m 2 --independent-tests "$E/test-long-running-1.js $E/test-long-running-2.js"
|
135 | if [ $? -ne 0 ]; then
|
136 | echo "long-running tests should pass"
|
137 | exit 1
|
138 | fi
|
139 | END=$(date +%s)
|
140 | DIFF=$(( $END - $START ))
|
141 | if [ $DIFF -ge 7 ]; then
|
142 | echo "Total test execution time should be less than 6 seconds (assuming code hasn't been changed.)"
|
143 | exit 1
|
144 | fi
|
145 |
|
146 | $W --independent-tests "$E/test-long-running-1.js $E/test-long-running-2.js $E/test-failure.js"
|
147 | if [ $? -ne 2 ]; then
|
148 | echo "2 tests should fail when running tests independently."
|
149 | exit 1
|
150 | fi
|
151 |
|
152 | $W --tests "$E/test-success.js"
|
153 |
|
154 | if [ $? -ne 0 ]; then
|
155 | echo "tests should pass"
|
156 | exit 1
|
157 | fi
|
158 |
|
159 | $W --tests "$E/test-failure.js"
|
160 |
|
161 | if [ $? -ne 2 ]; then
|
162 | echo "2 tests should fail"
|
163 | exit 1
|
164 | fi
|
165 |
|
166 | $W --failfast --timeout 500 \
|
167 | --tests --concurrency 100 "$E/test-failure.js $E/test-timeout.js"
|
168 |
|
169 | if [ $? -ne 1 ]; then
|
170 | echo "1 test should fail"
|
171 | exit 1
|
172 | fi
|
173 |
|
174 | $W --failfast --timeout 500 \
|
175 | --tests "$E/test-timeout.js $E/test-failure.js $E/test-timeout.js"
|
176 |
|
177 | if [ $? -ne 1 ]; then
|
178 | echo "1 test should fail"
|
179 | exit 1
|
180 | fi
|
181 |
|
182 | $W --timeout 1000 --tests "$E/test-timeout.js"
|
183 |
|
184 | if [ ! $? -eq 1 ]; then
|
185 | echo "test should time out"
|
186 | exit 1
|
187 | fi
|
188 |
|
189 | $W --timeout 1000 --tests "$E/test-timeout-blocking.js"
|
190 |
|
191 | if [ ! $? -eq 1 ]; then
|
192 | echo "test should time out"
|
193 | exit 1
|
194 | fi
|
195 |
|
196 | $W --tests "$E/test-setup-and-teardown.js"
|
197 |
|
198 | if [ $? -ne 0 ]; then
|
199 | echo "test should pass"
|
200 | exit 1
|
201 | fi
|
202 |
|
203 |
|
204 | $W --tests "$E/test-inexistent.js"
|
205 |
|
206 | if [ $? -ne 1 ]; then
|
207 | echo "1 test should fail"
|
208 | exit 1
|
209 | fi
|
210 |
|
211 | $W --tests "$E/test-setup-fail.js"
|
212 |
|
213 | if [ $? -ne 3 ]; then
|
214 | echo "3 tests should fail"
|
215 | exit 1
|
216 | fi
|
217 |
|
218 |
|
219 | $W --tests "example/test-success.js"
|
220 |
|
221 | if [ $? -ne 0 ]; then
|
222 | echo "tests should pass."
|
223 | exit 1
|
224 | fi
|
225 |
|
226 |
|
227 | $W --tests "$E/test-success.js $E/test-failure.js"
|
228 |
|
229 | if [ ! $? -gt 0 ]; then
|
230 | echo "2 tests should fail"
|
231 | exit 1
|
232 | fi
|
233 |
|
234 |
|
235 | FOLDER_EXISTS=0
|
236 | rm -rf $E/test-123456
|
237 |
|
238 | $W --test-init-file "$E/init.js" --tests "$E/test-success.js"
|
239 |
|
240 | if [ -d $E/test-123456 ]; then
|
241 | FOLDER_EXISTS=1
|
242 | fi
|
243 |
|
244 | rm -rf $E/test-123456
|
245 |
|
246 | if [ $? -ne 0 ] || [ ${FOLDER_EXISTS} -ne 1 ]; then
|
247 | echo ${FOLDER_EXISTS}
|
248 | echo "test should pass m"
|
249 | exit 1
|
250 | fi
|
251 |
|
252 |
|
253 | $W --tests "$E/test-uncaught.js"
|
254 |
|
255 | if [ $? -ne 5 ]; then
|
256 | echo "5 tests should fail"
|
257 | exit 1
|
258 | fi
|
259 |
|
260 |
|
261 | $W --tests "$E/test-chdir.js"
|
262 |
|
263 | if [ $? -ne 1 ]; then
|
264 | echo "1 test should fail"
|
265 | exit 1
|
266 | fi
|
267 |
|
268 | $W --tests "$E/test-chdir.js" --chdir "$E/"
|
269 |
|
270 | if [ $? -ne 0 ]; then
|
271 | echo "tests should pass y"
|
272 | exit 1
|
273 | fi
|
274 |
|
275 |
|
276 | $W --test-init-file "$E/init-test.js" --tests "$E/test-init-function.js"
|
277 |
|
278 | if [ $? -ne 0 ]; then
|
279 | echo "tests should pass x"
|
280 | exit 1
|
281 | fi
|
282 |
|
283 |
|
284 | $W --timeout 2000 --test-init-file "$E/init-timeout.js" --tests "$E/test-failure.js"
|
285 |
|
286 | if [ $? -ne 1 ]; then
|
287 | echo "1 test should fail (callback in init function is not called)"
|
288 | exit 1
|
289 | fi
|
290 |
|
291 |
|
292 | $W --timeout 1000 --tests "$E/test-setup-timeout.js" --chdir "$E/"
|
293 |
|
294 | if [ $? -ne 1 ]; then
|
295 | echo "1 test should fail (setUp timeout)"
|
296 | exit 1
|
297 | fi
|
298 |
|
299 |
|
300 | $W --timeout 2000 --tests "$E/test-teardown-timeout.js" --chdir "$E/"
|
301 |
|
302 | if [ $? -ne 2 ]; then
|
303 | echo "1 test should fail (tearDown timeout)"
|
304 | exit 1
|
305 | fi
|
306 |
|
307 | $W --timeout 2000 --tests "$E/test-custom-assert-functions.js"
|
308 |
|
309 | if [ $? -ne 2 ]; then
|
310 | echo "2 tests should fail"
|
311 | exit 1
|
312 | fi
|
313 |
|
314 | $W --timeout 2000 \
|
315 | --tests "$E/test-custom-assert-functions.js" \
|
316 | --custom-assert-module "$E/custom-assert-functions.js"
|
317 |
|
318 | if [ $? -ne 1 ]; then
|
319 | echo "1 test should fail"
|
320 | exit 1
|
321 | fi
|
322 |
|
323 | "$E/test-stdout-and-stderr-is-captured-on-timeout.js"
|
324 |
|
325 | if [ $? -ne 0 ]; then
|
326 | echo "test file stdout and stderr was not properly captured during test timeout"
|
327 | exit 1
|
328 | fi
|
329 |
|
330 |
|
331 |
|
332 | "$E/test-succeeded-tests-are-reported-on-timeout.js"
|
333 |
|
334 | if [ $? -ne 0 ]; then
|
335 | echo "succeeded tests were not reported properly upon a test file timeout"
|
336 | exit 1
|
337 | fi
|
338 |
|
339 |
|
340 | if [ "$(which jscoverage)" ]; then
|
341 | "$E/test-jscoverage.js"
|
342 |
|
343 | if [ $? -ne 0 ]; then
|
344 | echo "coverage does not work properly"
|
345 | exit 1
|
346 | fi
|
347 | else
|
348 | echo 'jscoverage not installed, skipping coverage tests'
|
349 | fi
|
350 |
|
351 |
|
352 |
|
353 | $W --timeout 1000 \
|
354 | --tests "$E/test-timeout-after-finish.js"
|
355 |
|
356 | if [ $? -ne 1 ]; then
|
357 | echo "1 test should timeout"
|
358 | exit 1
|
359 | fi
|
360 |
|
361 |
|
362 | "$E/test-leaks.js"
|
363 |
|
364 | if [ $? -ne 0 ]; then
|
365 | echo "scope leaks were not reported properly"
|
366 | exit 1
|
367 | fi
|
368 |
|
369 |
|
370 | $W --timeout 1000 \
|
371 | --tests "$E/test-no-test-functions.js"
|
372 |
|
373 | if [ $? -ne 0 ]; then
|
374 | echo "test didn't exit with zero exit code"
|
375 | exit 1
|
376 | fi
|
377 |
|
378 | $W --timeout 1000 \
|
379 | --tests "$E/test-skipped.js"
|
380 |
|
381 | if [ $? -ne 0 ]; then
|
382 | echo "test didn't exit with zero exit code"
|
383 | exit 1
|
384 | fi
|
385 |
|
386 | $W --timeout 1000 \
|
387 | --tests "$E/test-custom-assert-methods.js"
|
388 |
|
389 | if [ $? -ne 0 ]; then
|
390 | echo "test didn't exit with zero exit code"
|
391 | exit 1
|
392 | fi
|
393 |
|
394 |
|
395 | $W --timeout 1000 \
|
396 | --tests "example.test-failure.test_one_is_not*"
|
397 |
|
398 | if [ $? -ne 1 ]; then
|
399 | echo "test didn't exit with 1 exit code"
|
400 | exit 1
|
401 | fi
|
402 |
|
403 | $W --timeout 1000 \
|
404 | --tests "$E/test-getFilePathAndPattern.js"
|
405 |
|
406 | if [ $? -ne 0 ]; then
|
407 | echo "test didn't exit with zero exit code"
|
408 | exit 1
|
409 | fi
|
410 |
|
411 | $W --timeout 1000 \
|
412 | --tests "$E/test-spyon.js"
|
413 |
|
414 | if [ $? -ne 0 ]; then
|
415 | echo "Test didn't exit with zero exit code."
|
416 | exit 1
|
417 | fi
|
418 |
|
419 | $W --timeout 1000 \
|
420 | --tests "$E/test-bdd.js"
|
421 |
|
422 | if [ $? -ne 0 ]; then
|
423 | echo "BDD test didn't exit with zero exit code."
|
424 | exit 1
|
425 | fi
|
426 |
|
427 | $W --timeout 1000 \
|
428 | --tests "$E/test-bdd-failures.js"
|
429 |
|
430 | if [ $? -ne 4 ]; then
|
431 | echo "BDD failure test didn't fail as expected."
|
432 | exit 1
|
433 | fi
|
434 |
|
435 | $W --tests "$E/test-throw-string.js"
|
436 |
|
437 | if [ $? -ne 2 ]; then
|
438 | echo "2 tests should have failed"
|
439 | exit 1
|
440 | fi
|
441 |
|
442 | echo ""
|
443 | echo "* * * Whiskey test suite PASSED. * * *"
|
444 | exit 0
|