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