UNPKG

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