@@ -100,11 +100,64 @@ test_benchmark_jmh() {
100
100
fi
101
101
exit $RESPONSE_CODE
102
102
}
103
+
103
104
NC=' \033[0m'
104
105
GREEN=' \033[0;32m'
105
106
RED=' \033[0;31m'
107
+ TIMOUT=60
108
+
109
+ run_test_ci () {
110
+ # spawns the test to new process
111
+ local TEST_ARG=$@
112
+ local log_file=output_$$ .log
113
+ echo " running test $TEST_ARG "
114
+ $TEST_ARG & > $log_file &
115
+ local test_pid=$!
116
+ SECONDS=0
117
+ test_pulse_printer $! $TIMOUT $TEST_ARG &
118
+ local pulse_printer_pid=$!
119
+ local result
120
+
121
+ {
122
+ wait $test_pid 2> /dev/null
123
+ result=$?
124
+ kill $pulse_printer_pid && wait $pulse_printer_pid 2> /dev/null || true
125
+ } || return 1
126
+
127
+ DURATION=$SECONDS
128
+ if [ $result -eq 0 ]; then
129
+ echo -e " \n${GREEN} Test \" $TEST_ARG \" successful ($DURATION sec) $NC "
130
+ else
131
+ echo -e " \nLog:\n"
132
+ cat $log_file
133
+ echo -e " \n${RED} Test \" $TEST_ARG \" failed $NC ($DURATION sec) $NC "
134
+ fi
135
+ return $result
136
+ }
106
137
107
- function run_test() {
138
+ test_pulse_printer () {
139
+ # makes sure something is printed to stdout while test is running
140
+ local test_pid=$1
141
+ shift
142
+ local timeout=$1 # in minutes
143
+ shift
144
+ local count=0
145
+
146
+ # clear the line
147
+ echo -e " \n"
148
+
149
+ while [ $count -lt $timeout ]; do
150
+ count=$(( $count + 1 ))
151
+ echo -ne " Still running: \" $@ \" \r"
152
+ sleep 60
153
+ done
154
+
155
+ echo -e " \n${RED} Timeout (${timeout} minutes) reached. Terminating \" $@ \" ${NC} \n"
156
+ kill -9 $test_pid
157
+ }
158
+
159
+ run_test_local () {
160
+ # runs the tests locally
108
161
set +e
109
162
SECONDS=0
110
163
TEST_ARG=$@
@@ -113,10 +166,11 @@ function run_test() {
113
166
RESPONSE_CODE=$?
114
167
DURATION=$SECONDS
115
168
if [ $RESPONSE_CODE -eq 0 ]; then
116
- echo -e " ${GREEN} Test $TEST_ARG successful ($DURATION sec) $NC "
169
+ echo -e " ${GREEN} Test \" $TEST_ARG \" successful ($DURATION sec) $NC "
117
170
else
171
+ echo -e " \nLog:\n"
118
172
echo " $RES "
119
- echo -e " ${RED} Test $TEST_ARG failed $NC ($DURATION sec) $NC "
173
+ echo -e " ${RED} Test \" $TEST_ARG \" failed $NC ($DURATION sec) $NC "
120
174
exit $RESPONSE_CODE
121
175
fi
122
176
}
@@ -261,33 +315,40 @@ scala_junit_test_test_filter(){
261
315
done
262
316
}
263
317
264
- run_test bazel build test/...
265
- run_test bazel test test/...
266
- run_test bazel run test/src/main/scala/scala/test/twitter_scrooge:justscrooges
267
- run_test bazel run test:JavaBinary
268
- run_test bazel run test:JavaBinary2
269
- run_test bazel run test:MixJavaScalaLibBinary
270
- run_test bazel run test:MixJavaScalaSrcjarLibBinary
271
- run_test bazel run test:ScalaBinary
272
- run_test bazel run test:ScalaLibBinary
273
- run_test test_disappearing_class
274
- run_test find -L ./bazel-testlogs -iname " *.xml"
275
- run_test xmllint_test
276
- run_test test_build_is_identical
277
- run_test test_transitive_deps
278
- run_test test_scala_library_suite
279
- run_test test_repl
280
- run_test bazel run test:JavaOnlySources
281
- run_test test_benchmark_jmh
282
- run_test multiple_junit_suffixes
283
- run_test multiple_junit_prefixes
284
- run_test test_scala_junit_test_can_fail
285
- run_test junit_generates_xml_logs
286
- run_test multiple_junit_patterns
287
- run_test test_junit_test_must_have_prefix_or_suffix
288
- run_test test_junit_test_errors_when_no_tests_found
289
- run_test scala_library_jar_without_srcs_must_include_direct_file_resources
290
- run_test scala_library_jar_without_srcs_must_include_filegroup_resources
291
- run_test bazel run test/src/main/scala/scala/test/large_classpath:largeClasspath
292
- run_test scala_test_test_filters
293
- run_test scala_junit_test_test_filter
318
+
319
+ if [ " $1 " != " ci" ]; then
320
+ runner=" run_test_local"
321
+ else
322
+ runner=" run_test_ci"
323
+ fi
324
+
325
+ $runner bazel build test/...
326
+ $runner bazel test test/...
327
+ $runner bazel run test/src/main/scala/scala/test/twitter_scrooge:justscrooges
328
+ $runner bazel run test:JavaBinary
329
+ $runner bazel run test:JavaBinary2
330
+ $runner bazel run test:MixJavaScalaLibBinary
331
+ $runner bazel run test:MixJavaScalaSrcjarLibBinary
332
+ $runner bazel run test:ScalaBinary
333
+ $runner bazel run test:ScalaLibBinary
334
+ $runner test_disappearing_class
335
+ $runner find -L ./bazel-testlogs -iname " *.xml"
336
+ $runner xmllint_test
337
+ $runner test_build_is_identical
338
+ $runner test_transitive_deps
339
+ $runner test_scala_library_suite
340
+ $runner test_repl
341
+ $runner bazel run test:JavaOnlySources
342
+ $runner test_benchmark_jmh
343
+ $runner multiple_junit_suffixes
344
+ $runner multiple_junit_prefixes
345
+ $runner test_scala_junit_test_can_fail
346
+ $runner junit_generates_xml_logs
347
+ $runner multiple_junit_patterns
348
+ $runner test_junit_test_must_have_prefix_or_suffix
349
+ $runner test_junit_test_errors_when_no_tests_found
350
+ $runner scala_library_jar_without_srcs_must_include_direct_file_resources
351
+ $runner scala_library_jar_without_srcs_must_include_filegroup_resources
352
+ $runner bazel run test/src/main/scala/scala/test/large_classpath:largeClasspath
353
+ $runner scala_test_test_filters
354
+ $runner scala_junit_test_test_filter
0 commit comments