Skip to content

Commit d9d9138

Browse files
committed
Nicer tests output
1 parent 37ea3bd commit d9d9138

File tree

3 files changed

+101
-48
lines changed

3 files changed

+101
-48
lines changed

test/index.sh

Lines changed: 99 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,148 +13,201 @@ function test {
1313
return $status
1414
}
1515

16+
function showTestResult {
17+
if [ $1 -eq 0 ]; then
18+
echo "OK"
19+
else
20+
echo "Failed"
21+
fi
22+
}
23+
1624
MOCHA_VERSION=`mocha --version`
1725
echo "You're running tests with mocha version $MOCHA_VERSION"
1826
echo ""
1927

2028
echo 'TESTCASE: native (json) reporter'
2129
test test/reporter-native-json/index.sh
22-
echo $?
30+
showTestResult $?
31+
2332
echo 'TESTCASE: native (tap) reporter'
2433
test test/reporter-native-tap/index.sh
25-
echo $?
34+
showTestResult $?
35+
2636
echo 'TESTCASE: custom (teamcity) reporter'
2737
test test/reporter-custom-teamcity/index.sh
28-
echo $?
38+
showTestResult $?
39+
2940
echo 'TESTCASE: custom (jenkins) reporter'
3041
test test/reporter-custom-jenkins/index.sh
31-
echo $?
42+
showTestResult $?
43+
3244
echo 'TESTCASE: custom (mochawesome) reporter'
3345
test test/reporter-custom-mochawesome/index.sh
34-
echo $?
46+
showTestResult $?
47+
3548
echo 'TESTCASE: custom (allure) reporter'
3649
test test/reporter-custom-allure/index.sh
37-
echo $?
50+
showTestResult $?
51+
3852
echo 'TESTCASE: cli target'
3953
test test/cli-target/index.sh
40-
echo $?
54+
showTestResult $?
55+
4156
echo 'TESTCASE: pwd-based reporter'
4257
test test/reporter-pwd/index.sh
43-
echo $?
58+
showTestResult $?
59+
4460
echo 'TESTCASE: reporter emits events as soon as they come from subprocess'
4561
test test/reporter-log/index.js
46-
echo $?
62+
showTestResult $?
63+
4764
echo 'TESTCASE: parallel'
4865
test test/parallel/parallel.sh
49-
echo $?
66+
showTestResult $?
67+
5068
echo 'TESTCASE: parallel order'
5169
test test/parallel-order/index.js
52-
echo $?
70+
showTestResult $?
71+
5372
echo 'TESTCASE: max parallel tests'
5473
test test/max-parallel/index.sh
55-
echo $?
74+
showTestResult $?
75+
5676
echo 'TESTCASE: max parallel equal 1'
5777
test test/max-parallel-1/index.sh
58-
echo $?
78+
showTestResult $?
79+
5980
echo 'TESTCASE: max parallel tests with empty ones'
6081
test test/max-parallel-empty/index.sh
61-
echo $?
82+
showTestResult $?
83+
6284
echo 'TESTCASE: only tests run'
6385
test test/only-tests-run/index.js
64-
echo $?
86+
showTestResult $?
87+
6588
echo 'TESTCASE: nesting'
6689
test test/nesting/nesting.sh
67-
echo $?
90+
showTestResult $?
91+
6892
echo 'TESTCASE: describe inside describe'
6993
test test/describe-inside-describe/index.js
70-
echo $?
94+
showTestResult $?
95+
7196
echo 'TESTCASE: missing test'
7297
test test/missing-test/index.js
73-
echo $?
98+
showTestResult $?
99+
74100
echo 'TESTCASE: console logs'
75101
test test/console-log-inject/index.js
76-
echo $?
102+
showTestResult $?
103+
77104
echo 'TESTCASE: global hooks'
78105
test test/global-hooks/index.sh
79-
echo $?
106+
showTestResult $?
107+
80108
echo 'TESTCASE: global hooks with required files'
81109
test test/global-hooks-require/index.sh
82-
echo $?
110+
showTestResult $?
111+
83112
echo 'TESTCASE: global hooks with directory as a tests source'
84113
test test/global-hooks-directory/index.sh
85-
echo $?
114+
showTestResult $?
115+
86116
echo 'TESTCASE: --recursive option if no target is set'
87117
test test/recursive-no-target/index.js
88-
echo $?
118+
showTestResult $?
119+
89120
echo 'TESTCASE: total time'
90121
test test/total-time/index.js
91-
echo $?
122+
showTestResult $?
123+
92124
echo 'TESTCASE: timeouts exit code'
93125
test test/timeouts-exit-code/index.sh
94-
echo $?
126+
showTestResult $?
127+
95128
echo 'TESTCASE: no timeouts'
96129
test test/no-timeouts/index.sh
97-
echo $?
130+
showTestResult $?
131+
98132
echo 'TESTCASE: js compilers support'
99133
test test/js-compilers/index.sh
100-
echo $?
134+
showTestResult $?
135+
101136
echo 'TESTCASE: js compilers with files support'
102137
test test/js-compilers-1/index.sh
103-
echo $?
138+
showTestResult $?
139+
104140
echo 'TESTCASE: js compilers with --require support'
105141
test test/js-compilers-2/index.sh
106-
echo $?
142+
showTestResult $?
143+
107144
echo 'TESTCASE: reporter with options'
108145
test test/reporter-options/index.sh
109-
echo $?
146+
showTestResult $?
147+
110148
echo 'TESTCASE: mocha.opts'
111149
test test/mocha-opts/index.sh
112-
echo $?
150+
showTestResult $?
151+
113152
echo 'TESTCASE: syntax errors'
114153
test test/syntax-errors/index.js
115-
echo $?
154+
showTestResult $?
155+
116156
echo 'TESTCASE: --require option support'
117157
test test/require-option/index.sh
118-
echo $?
158+
showTestResult $?
159+
119160
echo 'TESTCASE: run programmatically (base API)'
120161
test test/run-programmatically/callback/index.js
121-
echo $?
162+
showTestResult $?
163+
122164
echo 'TESTCASE: run programmatically (reporter.done is called)'
123165
test test/run-programmatically/reporter-done/index.js
124-
echo $?
166+
showTestResult $?
167+
125168
echo 'TESTCASE: --no-exit option support'
126169
test test/reporter-end-no-exit/index.js
127-
echo $?
170+
showTestResult $?
171+
128172
echo 'TESTCASE: node add-on'
129173
test test/node-addon/index.sh
130-
echo $?
174+
showTestResult $?
175+
131176
echo 'TESTCASE: skip-suite'
132177
test test/skip-suite/index.sh
133-
echo $?
178+
showTestResult $?
179+
134180
echo 'TESTCASE: skip-test'
135181
test test/skip-test/index.sh
136-
echo $?
182+
showTestResult $?
183+
137184
echo 'TESTCASE: --delay option support'
138185
test test/delay/index.js
139-
echo $?
186+
showTestResult $?
187+
140188
echo 'TESTCASE: --retries option support'
141189
test test/retries/index.js
142-
echo $?
190+
showTestResult $?
191+
143192
echo 'TESTCASE: --exit option support'
144193
test test/exit/index.js
145-
echo $?
194+
showTestResult $?
195+
146196
echo 'TESTCASE: --retries plus all tests fail'
147197
test test/retries-all-fail/index.js
148-
echo $?
198+
showTestResult $?
199+
149200
echo 'TESTCASE: --retries and --bail should work well together'
150201
test test/bail-and-retries/index.js
151-
echo $?
202+
showTestResult $?
203+
152204
echo 'TESTCASE: subprocess exits before sending an end message'
153205
test test/no-subprocess-end/index.js
154-
echo $?
206+
showTestResult $?
207+
155208
echo 'TESTCASE: unhandled rejections should not force subprocess to exit'
156209
test test/q-promises/index.js
157-
echo $?
210+
showTestResult $?
158211

159212
echo "Passes: $PASSES Failes: $FAILES"
160213

test/parallel/parallel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ OUTPUT=$(dist/bin/cli.js -R spec test/parallel/tests --timeout 10000 --slow 1000
66

77
TIMESTAMP_FINISH="$(date +%s)"
88
TIMESTAMP_DIFF=`expr $TIMESTAMP_FINISH - $TIMESTAMP_START`
9-
echo "Tests running time was $TIMESTAMP_DIFF seconds"
109

1110
if [[ $TIMESTAMP_DIFF -lt 10 ]]; then
1211
exit 0
1312
else
13+
echo "Tests running time was $TIMESTAMP_DIFF seconds"
1414
exit 1
1515
fi

test/timeouts-exit-code/index.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ MOCHA_STATUS_CODE=$?
99
# currently mocha exits with 2 if 2 tests failed, 3 if 3 tests failed etc
1010
# though it's a strange behaviour, mocha-parallel-tests behaviour should be the same
1111
if [ $MPT_STATUS_CODE -eq $MOCHA_STATUS_CODE ]; then
12-
echo "Timeout status code is the same as in mocha"
12+
exit 0
1313
else
1414
echo "Timeout status code is not valid: $MPT_STATUS_CODE (actual) vs $MOCHA_STATUS_CODE (expected)"
1515
exit 1

0 commit comments

Comments
 (0)