UNPKG

7.49 kBapplication/x-shView Raw
1#!/usr/bin/env bash
2CWD=`dirname $0`
3CWD=`cd "$APP_DIR";pwd`
4
5START=$(date +%s)
6"${CWD}/bin/whiskey" -m 2 --independent-tests "${CWD}/example/test-long-running-1.js ${CWD}/example/test-long-running-2.js"
7if [ $? -ne 0 ]; then
8 echo "long-running tests should pass"
9 exit 1
10fi
11END=$(date +%s)
12DIFF=$(( $END - $START ))
13if [ $DIFF -ge 7 ]; then
14 echo "Total test execution time should be less than 6 seconds (assuming code hasn't been changed.)"
15 exit 1
16fi
17
18"${CWD}/bin/whiskey" --independent-tests "${CWD}/example/test-long-running-1.js ${CWD}/example/test-long-running-2.js ${CWD}/example/test-failure.js"
19if [ $? -ne 2 ]; then
20 echo "2 tests should fail when running tests independently."
21 exit 1
22fi
23
24"${CWD}/bin/whiskey" --tests "${CWD}/example/test-success.js"
25
26if [ $? -ne 0 ]; then
27 echo "tests should pass"
28 exit 1
29fi
30
31"${CWD}/bin/whiskey" --tests "${CWD}/example/test-failure.js"
32
33if [ $? -ne 2 ]; then
34 echo "2 tests should fail"
35 exit 1
36fi
37
38"${CWD}/bin/whiskey" --failfast --timeout 500 \
39 --tests --concurrency 100 "${CWD}/example/test-failure.js ${CWD}/example/test-timeout.js"
40
41if [ $? -ne 1 ]; then
42 echo "1 test should fail"
43 exit 1
44fi
45
46"${CWD}/bin/whiskey" --failfast --timeout 500 \
47 --tests "${CWD}/example/test-timeout.js ${CWD}/example/test-failure.js ${CWD}/example/test-timeout.js"
48
49if [ $? -ne 1 ]; then
50 echo "1 test should fail"
51 exit 1
52fi
53
54"${CWD}/bin/whiskey" --timeout 1000 --tests "${CWD}/example/test-timeout.js"
55
56if [ ! $? -eq 1 ]; then
57 echo "test should time out"
58 exit 1
59fi
60
61"${CWD}/bin/whiskey" --timeout 1000 --tests "${CWD}/example/test-timeout-blocking.js"
62
63if [ ! $? -eq 1 ]; then
64 echo "test should time out"
65 exit 1
66fi
67
68"${CWD}/bin/whiskey" --tests "${CWD}/example/test-setup-and-teardown.js"
69
70if [ $? -ne 0 ]; then
71 echo "test should pass"
72 exit 1
73fi
74
75# Test file does not exist
76"${CWD}/bin/whiskey" --tests "${CWD}/example/test-inexistent.js"
77
78if [ $? -ne 1 ]; then
79 echo "1 test should fail"
80 exit 1
81fi
82
83"${CWD}/bin/whiskey" --tests "${CWD}/example/test-setup-fail.js"
84
85if [ $? -ne 3 ]; then
86 echo "3 tests should fail"
87 exit 1
88fi
89
90# Test relative path
91"${CWD}/bin/whiskey" --tests "example/test-success.js"
92
93if [ $? -ne 0 ]; then
94 echo "tests should pass."
95 exit 1
96fi
97
98# Test multiple files
99"${CWD}/bin/whiskey" --tests "${CWD}/example/test-success.js ${CWD}/example/test-failure.js"
100
101if [ ! $? -gt 0 ]; then
102 echo "2 tests should fail"
103 exit 1
104fi
105
106# Test test init file
107FOLDER_EXISTS=0
108rm -rf ${CWD}/example/test-123456
109
110"${CWD}/bin/whiskey" --test-init-file "${CWD}/example/init.js" --tests "${CWD}/example/test-success.js"
111
112if [ -d ${CWD}/example/test-123456 ]; then
113 FOLDER_EXISTS=1
114fi
115
116rm -rf ${CWD}/example/test-123456
117
118if [ $? -ne 0 ] || [ ${FOLDER_EXISTS} -ne 1 ]; then
119 echo ${FOLDER_EXISTS}
120 echo "test should pass m"
121 exit 1
122fi
123
124# test uncaught exceptions
125"${CWD}/bin/whiskey" --tests "${CWD}/example/test-uncaught.js"
126
127if [ $? -ne 5 ]; then
128 echo "5 tests should fail"
129 exit 1
130fi
131
132# Test chdir
133"${CWD}/bin/whiskey" --tests "${CWD}/example/test-chdir.js"
134
135if [ $? -ne 1 ]; then
136 echo "1 test should fail"
137 exit 1
138fi
139
140"${CWD}/bin/whiskey" --tests "${CWD}/example/test-chdir.js" --chdir "${CWD}/example/"
141
142if [ $? -ne 0 ]; then
143 echo "tests should pass y"
144 exit 1
145fi
146
147# Test per test init function
148"${CWD}/bin/whiskey" --test-init-file "${CWD}/example/init-test.js" --tests "${CWD}/example/test-init-function.js"
149
150if [ $? -ne 0 ]; then
151 echo "tests should pass x"
152 exit 1
153fi
154
155# Test init function timeout (callback in init function is not called)
156"${CWD}/bin/whiskey" --timeout 2000 --test-init-file "${CWD}/example/init-timeout.js" --tests "${CWD}/example/test-failure.js"
157
158if [ $? -ne 1 ]; then
159 echo "1 test should fail (callback in init function is not called)"
160 exit 1
161fi
162
163# Test setUp function timeout (setUp function .finish() is not called)
164"${CWD}/bin/whiskey" --timeout 1000 --tests "${CWD}/example/test-setup-timeout.js" --chdir "${CWD}/example/"
165
166if [ $? -ne 1 ]; then
167 echo "1 test should fail (setUp timeout)"
168 exit 1
169fi
170
171# Test tearDown function timeout (tearDown function .finish() is not called)
172"${CWD}/bin/whiskey" --timeout 2000 --tests "${CWD}/example/test-teardown-timeout.js" --chdir "${CWD}/example/"
173
174if [ $? -ne 2 ]; then
175 echo "1 test should fail (tearDown timeout)"
176 exit 1
177fi
178
179"${CWD}/bin/whiskey" --timeout 2000 --tests "${CWD}/example/test-custom-assert-functions.js"
180
181if [ $? -ne 2 ]; then
182 echo "2 tests should fail"
183 exit 1
184fi
185
186"${CWD}/bin/whiskey" --timeout 2000 \
187 --tests "${CWD}/example/test-custom-assert-functions.js" \
188 --custom-assert-module "${CWD}/example/custom-assert-functions.js"
189
190if [ $? -ne 1 ]; then
191 echo "1 test should fail"
192 exit 1
193fi
194
195"${CWD}/example/test-stdout-and-stderr-is-captured-on-timeout.js"
196
197if [ $? -ne 0 ]; then
198 echo "test file stdout and stderr was not properly captured during test timeout"
199 exit 1
200fi
201
202# Verify that when a test file timeout the tests which haven't time out are
203# reported properly
204"${CWD}/example/test-succeeded-tests-are-reported-on-timeout.js"
205
206if [ $? -ne 0 ]; then
207 echo "succeeded tests were not reported properly upon a test file timeout"
208 exit 1
209fi
210
211# Verify that coverage works properly
212if [ "$(which jscoverage)" ]; then
213 "${CWD}/example/test-jscoverage.js"
214
215 if [ $? -ne 0 ]; then
216 echo "coverage does not work properly"
217 exit 1
218 fi
219else
220 echo 'jscoverage not installed, skipping coverage tests'
221fi
222
223# Make sure that the child which blocks after call .finish() is killed and
224# timeout properly reported
225"${CWD}/bin/whiskey" --timeout 1000 \
226 --tests "${CWD}/example/test-timeout-after-finish.js"
227
228if [ $? -ne 1 ]; then
229 echo "1 test should timeout"
230 exit 1
231fi
232
233# Scope leaks test (sequential and parallel mode)
234"${CWD}/example/test-leaks.js"
235
236if [ $? -ne 0 ]; then
237 echo "scope leaks were not reported properly"
238 exit 1
239fi
240
241# No test function is exported, it should quit immediately
242"${CWD}/bin/whiskey" --timeout 1000 \
243 --tests "${CWD}/example/test-no-test-functions.js"
244
245if [ $? -ne 0 ]; then
246 echo "test didn't exit with zero exit code"
247 exit 1
248fi
249
250"${CWD}/bin/whiskey" --timeout 1000 \
251 --tests "${CWD}/example/test-skipped.js"
252
253if [ $? -ne 0 ]; then
254 echo "test didn't exit with zero exit code"
255 exit 1
256fi
257
258"${CWD}/bin/whiskey" --timeout 1000 \
259 --tests "${CWD}/example/test-custom-assert-methods.js"
260
261if [ $? -ne 0 ]; then
262 echo "test didn't exit with zero exit code"
263 exit 1
264fi
265
266# Test pattern name matching
267"${CWD}/bin/whiskey" --timeout 1000 \
268 --tests "example.test-failure.test_one_is_not*"
269
270if [ $? -ne 1 ]; then
271 echo "test didn't exit with 1 exit code"
272 exit 1
273fi
274
275"${CWD}/bin/whiskey" --timeout 1000 \
276 --tests "${CWD}/example/test-getFilePathAndPattern.js"
277
278if [ $? -ne 0 ]; then
279 echo "test didn't exit with zero exit code"
280 exit 1
281fi
282
283"${CWD}/bin/whiskey" --timeout 1000 \
284 --tests "${CWD}/example/test-spyon.js"
285
286if [ $? -ne 0 ]; then
287 echo "Test didn't exit with zero exit code."
288 exit 1
289fi
290
291"${CWD}/bin/whiskey" --timeout 1000 \
292--tests "${CWD}/example/test-bdd.js"
293
294if [ $? -ne 0 ]; then
295 echo "BDD test didn't exit with zero exit code."
296 exit 1
297fi
298
299"${CWD}/bin/whiskey" --timeout 1000 \
300--tests "${CWD}/example/test-bdd-failures.js"
301
302if [ $? -ne 4 ]; then
303 echo "BDD failure test didn't fail as expected."
304 exit 1
305fi
306
307
308echo ""
309echo "* * * Whiskey test suite PASSED. * * *"
310exit 0