generated from MapColonies/ts-server-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-test.sh
41 lines (32 loc) · 1.12 KB
/
docker-test.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
#!/bin/bash
_term() {
echo "Caught signal, stopping gracefully"
kill -TERM "$child" 2>/dev/null
}
trap _term SIGTERM
trap _term SIGINT
xvfbMaxStartWaitTime=10
displayNumber=99
screenNumber=0
echo "Starting Xvfb on display ${displayNumber}"
start-stop-daemon --start --pidfile ~/xvfb.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :${displayNumber} -screen ${screenNumber} 1920x1080x24 -ac +extension GLX +render -noreset
# Wait to be able to connect to the port. This will exit if it cannot in 1 minute.
timeout ${xvfbMaxStartWaitTime} bash -c "while ! xdpyinfo -display :${displayNumber} >/dev/null; do sleep 0.5; done"
if [ $? -ne 0 ]; then
echo "Could not connect to display ${displayNumber} in ${xvfbMaxStartWaitTime} seconds time."
exit 1
fi
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
export DISPLAY=:${displayNumber}.${screenNumber}
testsToRun=""
echo
if [ ! -z $TESTS_TO_RUN ]; then
testsToRun=":${TESTS_TO_RUN}"
fi
dumb-init npm run test$testsToRun "$@" &
child=$!
wait "$child"
exitCode=$?
start-stop-daemon --stop --retry 5 --pidfile ~/xvfb.pid # stop xvfb when exiting
rm ~/xvfb.pid
exit $exitCode