"make check": Support out-of-tree builds

Currently, tests/run.sh expects the directory layout that our wrapper Makefile
sets up before running CMake. This commit adds support for any other directory
configuration as well.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-05-08 18:34:39 +02:00
parent d497cdf081
commit 7ea816045d
2 changed files with 17 additions and 13 deletions

View File

@ -361,7 +361,7 @@ endif()
# {{{ Tests # {{{ Tests
set(CHECK_TARGETS check-integration) set(CHECK_TARGETS check-integration)
add_custom_target(check-integration add_custom_target(check-integration
"${CMAKE_SOURCE_DIR}/tests/run.sh" sh -c "CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}' ${CMAKE_SOURCE_DIR}/tests/run.sh"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running integration tests" COMMENT "Running integration tests"
VERBATIM) VERBATIM)

View File

@ -17,6 +17,12 @@ if [ "$CI" = true ]; then
set -x set -x
fi fi
source_dir="$PWD"
build_dir="$CMAKE_BINARY_DIR"
if [ -z "$build_dir" ]; then
build_dir="$PWD/build"
fi
# Change to file's dir (POSIXly). # Change to file's dir (POSIXly).
cd -P -- "$(dirname -- "$0")" cd -P -- "$(dirname -- "$0")"
this_dir=$PWD this_dir=$PWD
@ -28,8 +34,6 @@ else
tests=$this_dir/test*.lua tests=$this_dir/test*.lua
fi fi
root_dir=$PWD/..
# Travis. # Travis.
if [ "$CI" = true ]; then if [ "$CI" = true ]; then
HEADLESS=1 HEADLESS=1
@ -44,13 +48,13 @@ export TEST_PAUSE_ON_ERRORS # Used in tests/_runner.lua.
XEPHYR=Xephyr XEPHYR=Xephyr
XVFB=Xvfb XVFB=Xvfb
AWESOME=$root_dir/build/awesome AWESOME=$build_dir/awesome
if ! [ -x "$AWESOME" ]; then if ! [ -x "$AWESOME" ]; then
echo "$AWESOME is not executable." >&2 echo "$AWESOME is not executable." >&2
exit 1 exit 1
fi fi
RC_FILE=$root_dir/build/awesomerc.lua RC_FILE=$build_dir/awesomerc.lua
AWESOME_CLIENT="$root_dir/utils/awesome-client" AWESOME_CLIENT="$source_dir/utils/awesome-client"
D=:5 D=:5
SIZE=1024x768 SIZE=1024x768
@ -65,7 +69,7 @@ else
# ( sleep 1; kill -USR1 $xserver_pid ) & # ( sleep 1; kill -USR1 $xserver_pid ) &
fi fi
cd $root_dir/build cd $build_dir
LUA_PATH="$(lua -e 'print(package.path)');lib/?.lua;lib/?/init.lua" LUA_PATH="$(lua -e 'print(package.path)');lib/?.lua;lib/?/init.lua"
# Add test dir (for _runner.lua). # Add test dir (for _runner.lua).
@ -154,21 +158,21 @@ eval $(DISPLAY="$D" dbus-launch --sh-syntax --exit-with-session)
if [ "$CI" != true ]; then if [ "$CI" != true ]; then
# Prepare a config file pointing to a working theme # Prepare a config file pointing to a working theme
# Handle old filename of config files (useful for git-bisect). # Handle old filename of config files (useful for git-bisect).
if [ -f $root_dir/awesomerc.lua.in ]; then if [ -f $source_dir/awesomerc.lua.in ]; then
SED_IN=.in SED_IN=.in
fi fi
RC_FILE=$tmp_files/awesomerc.lua RC_FILE=$tmp_files/awesomerc.lua
THEME_FILE=$tmp_files/theme.lua THEME_FILE=$tmp_files/theme.lua
sed -e "s:.*beautiful.init(.*default/theme.lua.*:beautiful.init('$THEME_FILE'):" $root_dir/awesomerc.lua$SED_IN > $RC_FILE 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:$root_dir/build/themes/default/titlebar:" \ sed -e "s:@AWESOME_THEMES_PATH@/default/titlebar:$build_dir/themes/default/titlebar:" \
-e "s:@AWESOME_THEMES_PATH@:$root_dir/themes/:" \ -e "s:@AWESOME_THEMES_PATH@:$source_dir/themes/:" \
-e "s:@AWESOME_ICON_PATH@:$root_dir/icons:" $root_dir/themes/default/theme.lua$SED_IN > $THEME_FILE -e "s:@AWESOME_ICON_PATH@:$source_dir/icons:" $source_dir/themes/default/theme.lua$SED_IN > $THEME_FILE
fi fi
# Start awesome. # Start awesome.
start_awesome() { start_awesome() {
export DISPLAY="$D" export DISPLAY="$D"
cd $root_dir/build cd $build_dir
DISPLAY="$D" "$AWESOME" -c "$RC_FILE" $AWESOME_OPTIONS > $awesome_log 2>&1 & DISPLAY="$D" "$AWESOME" -c "$RC_FILE" $AWESOME_OPTIONS > $awesome_log 2>&1 &
awesome_pid=$! awesome_pid=$!
cd - >/dev/null cd - >/dev/null