From ec9a981dd7c424789b57ce340abe5a0eaf6041b7 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 5 Jan 2017 01:06:49 +0100 Subject: [PATCH] tests: move coverage setup into tests/run.sh This allows for `DO_COVERAGE=1 make check` with local tests (where `CI=true` is not given). It uses the new environment variables to configure the default theme, instead of creating a temporary config/theme. --- .travis.yml | 1 - tests/run.sh | 25 +++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 74866d80d..d3d97f49a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -168,7 +168,6 @@ script: (make check-unit-coverage \ && do_codecov unittests \ - && sed -i "1 s~^~require('luacov.runner')('$PWD/.luacov'); \0~" build/awesomerc.lua \ && tests/run.sh \ && do_codecov functionaltests) ret=$? diff --git a/tests/run.sh b/tests/run.sh index ffb21891f..ed2a60473 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -59,7 +59,6 @@ if ! [ -x "$AWESOME" ]; then echo "$AWESOME is not executable." >&2 exit 1 fi -RC_FILE=$build_dir/awesomerc.lua AWESOME_CLIENT="$source_dir/utils/awesome-client" D=:5 SIZE="${TESTS_SCREEN_SIZE:-1024x768}" @@ -90,6 +89,9 @@ cleanup() { for p in $awesome_pid $xserver_pid; do kill -TERM "$p" 2>/dev/null || true done + if [ -n "$DO_COVERAGE" ] && [ "$DO_COVERAGE" != 0 ]; then + mv "$RC_FILE.coverage.bak" "$RC_FILE" + fi rm -rf "$tmp_files" || true } trap "cleanup" 0 2 3 15 @@ -160,19 +162,14 @@ wait_until_success "setup xrdb" "printf 'Xft.dpi: 96 # 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 - # Handle old filename of config files (useful for git-bisect). - if [ -f "$source_dir/awesomerc.lua.in" ]; then - SED_IN=.in - fi - RC_FILE=$tmp_files/awesomerc.lua - THEME_FILE=$tmp_files/theme.lua - sed -e "s:.*beautiful.init(.*default/theme.lua.*:beautiful.init('$THEME_FILE'):" "$source_dir/awesomerc.lua$SED_IN" > "$RC_FILE" - sed -e "s:@AWESOME_THEMES_PATH@/default/titlebar:$build_dir/themes/default/titlebar:" \ - -e "s:@AWESOME_THEMES_PATH@:$source_dir/themes/:" \ - -e "s:@AWESOME_ICON_PATH@:$source_dir/icons:" "$source_dir/themes/default/theme.lua$SED_IN" > "$THEME_FILE" +RC_FILE=${source_dir}/awesomerc.lua +export AWESOME_THEMES_PATH="$source_dir/themes" +export AWESOME_ICON_PATH="$source_dir/icons" + +# Inject coverage runner to RC file, which will be restored on exit/cleanup. +if [ -n "$DO_COVERAGE" ] && [ "$DO_COVERAGE" != 0 ]; then + cp -a "$RC_FILE" "$RC_FILE.coverage.bak" + sed -i "1 s~^~require('luacov.runner')('$source_dir/.luacov'); \0~" "$RC_FILE" fi # Start awesome.