summaryrefslogtreecommitdiffstats
path: root/.travis/utils.sh
blob: d084a7aef3380e96210921f83ec4b6a382817813 (plain)
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
#!/usr/bin/env bash

# Prevent travis from timing out after 10 minutes of no output
tick() {
	(while true; do sleep 300; echo; done) &
	local PID=$!
	disown

	"$@"
	local RET=$?

	kill $PID
	return $RET
}
export -f tick

retry() {
	local tries=$1
	shift

	local i=0
	while [ "$i" -lt "$tries" ]; do
		"$@" && return 0
		sleep $((2**((i++))))
	done

	return 1
}
export -f retry