forked from openpgpjs/openpgpjs
-
Notifications
You must be signed in to change notification settings - Fork 2
/
travis.sh
executable file
·60 lines (45 loc) · 1.72 KB
/
travis.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
#!/bin/bash
set -e
if [ $OPENPGPJSTEST = "coverage" ]; then
echo "Running OpenPGP.js unit tests on node.js with code coverage."
grunt coverage
codeclimate-test-reporter < coverage/lcov.info
elif [ $OPENPGPJSTEST = "unit" ]; then
echo "Running OpenPGP.js unit tests on node.js."
grunt build test --lightweight=$LIGHTWEIGHT
elif [ $OPENPGPJSTEST = "browserstack" ]; then
echo "Running OpenPGP.js browser unit tests on Browserstack."
grunt build browserify:unittests copy:browsertest --compat=$COMPAT
echo -n "Using config: "
echo "{\"browsers\": [$BROWSER], \"test_framework\": \"mocha\", \"test_path\": [\"test/unittests.html?ci=true\"], \"timeout\": 1800, \"exit_with_fail\": true, \"project\": \"openpgpjs/${TRAVIS_EVENT_TYPE:-push}${COMPAT:+/compat}${LIGHTWEIGHT:+/lightweight}\"}" > browserstack.json
cat browserstack.json
result=0
count=1
while [ $count -le 3 ]; do
[ $result -ne 0 ] && {
echo -e "\nThe command failed. Retrying, $count of 3.\n" >&2
}
browserstack-runner &
background_process_pid=$!
# https://github.com/travis-ci/travis-ci/issues/4190
seconds=0
limit=2000
while kill -0 $background_process_pid >/dev/null 2>&1; do
echo -n -e " \b" # never leave evidences!
if [ $seconds == $limit ]; then
echo -e "\nThe tests timed out.\n" >&2
exit 1
fi
seconds=$((seconds+1))
sleep 1
done
wait $background_process_pid && { result=0 && break; } || result=$?
[ $result -eq 0 ] && break
[ $seconds -gt 10 ] && break # If the tests took <10 seconds, assume they failed to launch and try again.
count=$(($count + 1))
done
[ $count -gt 3 ] && {
echo -e "\nThe command failed 3 times.\n" >&2
}
exit $result
fi