From 6d4837a53abb04bbceff99ec91c9fe8b26c6430d Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 5 Aug 2015 17:10:56 +0200 Subject: [PATCH 1/7] tests/run.sh: Start dbus after X server startup The code does some dances with xrdb to ensure that the server finished starting up. However, before this it already tries to access the server via dbus-launch. Since nothing uses dbus in this part of the code, we can just move this down. Signed-off-by: Uli Schlachter --- tests/run.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index 2134a703..f239dc7f 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -50,9 +50,6 @@ else # ( sleep 1; kill -USR1 $xserver_pid ) & fi -# Use a separate D-Bus session; sets $DBUS_SESSION_BUS_PID. -eval $(DISPLAY="$D" dbus-launch --sh-syntax --exit-with-session) - cd $root_dir/build LUA_PATH="$(lua -e 'print(package.path)');lib/?.lua;lib/?/init.lua" @@ -101,6 +98,9 @@ while true; do sleep 0.05 done +# Use a separate D-Bus session; sets $DBUS_SESSION_BUS_PID. +eval $(DISPLAY="$D" dbus-launch --sh-syntax --exit-with-session) + AWESOME_CLIENT="$root_dir/utils/awesome-client" From 41d81a4501f4f23d2a1dbd2f05adf3cea46662bd Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 5 Aug 2015 17:36:21 +0200 Subject: [PATCH 2/7] tests/run.sh: Move definition of AWESOME_CLIENT up Signed-off-by: Uli Schlachter --- tests/run.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index f239dc7f..a5dd3588 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -36,6 +36,7 @@ XEPHYR=Xephyr XVFB=Xvfb AWESOME=$root_dir/build/awesome RC_FILE=$root_dir/build/awesomerc.lua +AWESOME_CLIENT="$root_dir/utils/awesome-client" D=:5 SIZE=1024x768 @@ -101,9 +102,6 @@ done # Use a separate D-Bus session; sets $DBUS_SESSION_BUS_PID. eval $(DISPLAY="$D" dbus-launch --sh-syntax --exit-with-session) - -AWESOME_CLIENT="$root_dir/utils/awesome-client" - # Start awesome. start_awesome() { export DISPLAY="$D" From d8a1b563e7beff2d8b736abb42d237979a3f8d3e Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 5 Aug 2015 17:41:26 +0200 Subject: [PATCH 3/7] tests/run.sh: Use a temporary directory Signed-off-by: Uli Schlachter --- tests/run.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index a5dd3588..838f1d09 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -60,22 +60,20 @@ XDG_CONFIG_HOME="./" export LUA_PATH export XDG_CONFIG_HOME -awesome_log=/tmp/_awesome_test.log -echo "awesome_log: $awesome_log" - cd - >/dev/null - -kill_childs() { +# Cleanup on errors / aborting. +cleanup() { for p in $awesome_pid $xserver_pid; do kill -TERM $p 2>/dev/null || true done + rm -rf $tmp_files || true } -# Cleanup on errors / aborting. -set_trap() { - trap "kill_childs" 0 2 3 15 -} -set_trap +trap "cleanup" 0 2 3 15 + +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. From 0688e8899e5b5c8f73282cf421b5f66b08db99c1 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 5 Aug 2015 17:44:00 +0200 Subject: [PATCH 4/7] tests/run.sh: Allow execution without installing When this script is not run under Travis, it will prepare a temporary config file and a theme file that point to the files that were not yet installed. Signed-off-by: Uli Schlachter --- tests/run.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/run.sh b/tests/run.sh index 838f1d09..6c404505 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -100,6 +100,17 @@ done # Use a separate D-Bus session; sets $DBUS_SESSION_BUS_PID. eval $(DISPLAY="$D" dbus-launch --sh-syntax --exit-with-session) +# Not in Travis? +if [ "$CI" != true ]; then + # Prepare a config file pointing to a working theme + RC_FILE=$tmp_files/awesomerc.lua + THEME_FILE=$tmp_files/theme.lua + sed -e "s:beautiful.init(\"@AWESOME_THEMES_PATH@/default/theme.lua\"):beautiful.init('$THEME_FILE'):" $root_dir/awesomerc.lua > $RC_FILE + sed -e "s:@AWESOME_THEMES_PATH@/default/titlebar:$root_dir/build/themes/default/titlebar:" \ + -e "s:@AWESOME_THEMES_PATH@:$root_dir/themes/:" \ + -e "s:@AWESOME_ICON_PATH@:$root_dir/icons:" $root_dir/themes/default/theme.lua > $THEME_FILE +fi + # Start awesome. start_awesome() { export DISPLAY="$D" From 17e8827212614aacc345f5285813e5ef229317ac Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 5 Aug 2015 17:48:09 +0200 Subject: [PATCH 5/7] 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 --- tests/run.sh | 65 +++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index 6c404505..f9c4cfc9 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -75,27 +75,33 @@ tmp_files=$(mktemp -d) awesome_log=$tmp_files/_awesome_test.log echo "awesome_log: $awesome_log" +wait_until_success() { + max_wait=60 + while true; do + set +e + eval reply="\$($2)" + ret=$? + set -e + if [ $ret = 0 ]; then + break + fi + max_wait=$(expr $max_wait - 1 || true) + if [ "$max_wait" -lt 0 ]; then + 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. -max_wait=60 -while true; do - set +e - reply="$(echo "Xft.dpi: 96" | DISPLAY="$D" xrdb 2>&1)" - ret=$? - set -e - if [ $ret = 0 ]; then - break - fi - max_wait=$(expr $max_wait - 1) - if [ "$max_wait" -lt 0 ]; then - echo "Error: failed to setup xrdb!" - echo "Last reply: $reply." - echo "Log:" - cat "$awesome_log" - exit 1 - fi - sleep 0.05 -done +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. From 0ee24317c740ef02427044bb49b0d932388d7d6f Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 5 Aug 2015 17:57:50 +0200 Subject: [PATCH 6/7] tests/run.sh: Temporarily disable -x in wait_until_success Signed-off-by: Uli Schlachter --- tests/run.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/run.sh b/tests/run.sh index f9c4cfc9..e2dcaf69 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -76,6 +76,9 @@ awesome_log=$tmp_files/_awesome_test.log echo "awesome_log: $awesome_log" wait_until_success() { + if [ "$CI" = true ]; then + set +x + fi max_wait=60 while true; do set +e @@ -97,6 +100,9 @@ wait_until_success() { fi sleep 0.05 done + if [ "$CI" = true ]; then + set -x + fi } # Wait for DISPLAY to be available, and setup xrdb, From cbba6157487f27c28355027059396a73615e1b73 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 5 Aug 2015 17:58:10 +0200 Subject: [PATCH 7/7] tests/run.sh: Show full error messages If an error occurs during startup, tail might not show the full error message. Signed-off-by: Uli Schlachter --- tests/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run.sh b/tests/run.sh index e2dcaf69..4983f8c1 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -153,7 +153,7 @@ for f in $tests; do cat $f | DISPLAY=$D "$AWESOME_CLIENT" 2>&1 # Tail the log and quit, when awesome quits. - tail -f --pid $awesome_pid $awesome_log + tail -n 100000 -f --pid $awesome_pid $awesome_log if grep -q -E '^Error|assertion failed' $awesome_log; then echo "===> ERROR running $f! <==="