forked from linkedin/photon-ml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.sh
executable file
·70 lines (54 loc) · 1.77 KB
/
tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
#
# This script is used to customize Travis CI testing as follows:
# - Wrapper for gradle call to run unit and integration tests in parallel
# - Redirect integTest output to tmp file to avoid Travis CI 4MB log file limit. In addition, ping Travis CI while
# testing to avoid the 10 minute no-output timeout. This code modified from the base script found here:
# http://stackoverflow.com/questions/26082444/how-to-work-around-travis-cis-4mb-output-limit
#
NUM_LINES=500
# Helper functions
dump_output() {
echo "Dumping the last $NUM_LINES lines of output:"
tail -${NUM_LINES} ${BUILD_OUTPUT}
}
kill_ping_loop() {
kill ${PING_LOOP_PID}
}
clean_up() {
# The build finished without returning an error so dump a tail of the output
dump_output
# Nicely terminate the ping output loop
kill_ping_loop
}
error_handler() {
echo "ERROR: An error was encountered with the build."
clean_up
exit 1
}
# Abort on error
set -e
if [[ $# -ne 1 ]]; then
echo "ERROR: Wrong # of arguments"
exit 1
fi
if [[ "$1" == "integration" ]]; then
# Redirect output to file, ping Travis intermittently so it doesn't kill the test.
PING_SLEEP=30s
BUILD_OUTPUT=/tmp/build.out
touch ${BUILD_OUTPUT}
# If an error occurs, run our error handler to output a tail of the build
trap 'error_handler' ERR
# Set up a repeating loop to send some output to Travis.
bash -c "while true; do echo \"\$(date) - testing ...\"; sleep $PING_SLEEP; done" &
PING_LOOP_PID=$!
# Run integration tests, redirect output to tmp file
./gradlew check -x test &> ${BUILD_OUTPUT}
# Kill ping process, output final
clean_up
elif [[ "$1" == "unit" ]]; then
./gradlew check -x integTest
else
echo "ERROR: Invalid test type specified; must be either 'unit' or 'integration'"
exit 1
fi