forked from vordimous/openpgpjs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
travis.sh
executable file
·68 lines (51 loc) · 1.93 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
61
62
63
64
65
66
67
68
#!/bin/bash
set -e
if [ $OPENPGPJSTEST = "coverage" ]; then
echo "Running OpenPGP.js unit tests on node.js with code coverage."
npm run coverage
codeclimate-test-reporter < coverage/lcov.info
elif [ $OPENPGPJSTEST = "lint" ]; then
echo "Running OpenPGP.js eslint."
npm run lint
elif [ $OPENPGPJSTEST = "test-type-definitions" ]; then
echo "Testing OpenPGP.js type definitions."
npm run test-type-definitions
elif [ $OPENPGPJSTEST = "unit" ]; then
echo "Running OpenPGP.js unit tests on node.js."
npm test ${LIGHTWEIGHT+ -- --grep lightweight}
elif [ $OPENPGPJSTEST = "browserstack" ]; then
echo "Running OpenPGP.js browser unit tests on Browserstack."
npm run build-test
echo -n "Using config: "
echo "{\"browsers\": [$BROWSER], \"test_framework\": \"mocha\", \"test_path\": [\"test/unittests.html?ci=true${LIGHTWEIGHT+&lightweight=true&grep=lightweight}\"], \"timeout\": 1800, \"exit_with_fail\": true, \"project\": \"openpgpjs/${TRAVIS_EVENT_TYPE:-push}${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