mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
tests/run.sh: Factor out a helper function
This factors out a function wait_until_success that runs some command until it succeeds (with a timeout) and uses this function in the two places where this was already done before. Note that this removes the "kill -0" trick for early exit again and instead will use the timeout in case awesome dies during startup. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
0688e8899e
commit
17e8827212
1 changed files with 26 additions and 39 deletions
37
tests/run.sh
37
tests/run.sh
|
@ -75,27 +75,33 @@ tmp_files=$(mktemp -d)
|
|||
awesome_log=$tmp_files/_awesome_test.log
|
||||
echo "awesome_log: $awesome_log"
|
||||
|
||||
# Wait for DISPLAY to be available, and setup xrdb,
|
||||
# for awesome's xresources backend / queries.
|
||||
wait_until_success() {
|
||||
max_wait=60
|
||||
while true; do
|
||||
set +e
|
||||
reply="$(echo "Xft.dpi: 96" | DISPLAY="$D" xrdb 2>&1)"
|
||||
eval reply="\$($2)"
|
||||
ret=$?
|
||||
set -e
|
||||
if [ $ret = 0 ]; then
|
||||
break
|
||||
fi
|
||||
max_wait=$(expr $max_wait - 1)
|
||||
max_wait=$(expr $max_wait - 1 || true)
|
||||
if [ "$max_wait" -lt 0 ]; then
|
||||
echo "Error: failed to setup xrdb!"
|
||||
echo "Error: failed to $1!"
|
||||
echo "Last reply: $reply."
|
||||
if [ -f "$awesome_log" ]; then
|
||||
echo "Log:"
|
||||
cat "$awesome_log"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
sleep 0.05
|
||||
done
|
||||
}
|
||||
|
||||
# Wait for DISPLAY to be available, and setup xrdb,
|
||||
# for awesome's xresources backend / queries.
|
||||
wait_until_success "setup xrdb" "echo 'Xft.dpi: 96' | DISPLAY='$D' xrdb 2>&1"
|
||||
|
||||
# Use a separate D-Bus session; sets $DBUS_SESSION_BUS_PID.
|
||||
eval $(DISPLAY="$D" dbus-launch --sh-syntax --exit-with-session)
|
||||
|
@ -120,26 +126,7 @@ start_awesome() {
|
|||
cd - >/dev/null
|
||||
|
||||
# Wait until the interface for awesome-client is ready (D-Bus interface).
|
||||
client_reply=
|
||||
max_wait=50
|
||||
while true; do
|
||||
set +e
|
||||
client_reply=$(echo 'return 1' | DISPLAY=$D "$AWESOME_CLIENT" 2>&1)
|
||||
ret=$?
|
||||
set -e
|
||||
if [ $ret = 0 ]; then
|
||||
break
|
||||
fi
|
||||
max_wait=$(expr $max_wait - 1 || true)
|
||||
if [ "$max_wait" -lt 0 ] || ! kill -0 $awesome_pid ; then
|
||||
echo "Error: did not receive a successful reply via awesome-client!"
|
||||
echo "Last reply: $client_reply."
|
||||
echo "Log:"
|
||||
cat "$awesome_log"
|
||||
exit 1
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
wait_until_success "wait for awesome startup via awesome-client" "echo 'return 1' | DISPLAY=$D '$AWESOME_CLIENT' 2>&1"
|
||||
}
|
||||
|
||||
# Count errors.
|
||||
|
|
Loading…
Reference in a new issue