diff --git a/.travis.yml b/.travis.yml index 8f1286f9b..82bdb8b79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ env: matrix: - LUA=5.2 LUANAME=lua5.2 DO_COVERAGE=coveralls # Lua 5.3 isn't available in Ubuntu Trusty, so some magic below installs it. - - LUA=5.3 LUANAME=lua5.3 LUALIBRARY=/usr/lib/liblua.so DO_COVERAGE=codecov AWESOME_THEME=xresources + - LUA=5.3 LUANAME=lua5.3 LUALIBRARY=/usr/lib/liblua.so DO_COVERAGE=codecov # luajit: installed from source. - LUA=5.1 LUANAME=luajit-2.0 LUALIBRARY=/usr/lib/libluajit-5.1.so LUAROCKS_ARGS=--lua-suffix=jit-2.0.5 TEST_PREV_COMMITS=1 # Note: luarocks does not work with Lua 5.0. @@ -148,10 +148,6 @@ install: } script: - export CMAKE_ARGS="-DLUA_LIBRARY=${LUALIBRARY} -DLUA_INCLUDE_DIR=${LUAINCLUDE} -D OVERRIDE_VERSION=$AWESOME_VERSION -DSTRICT_TESTS=true" - - | - if [ ! -z "$AWESOME_THEME" ]; then - sed awesomerc.lua -i -e "s/default\/theme/$AWESOME_THEME\/theme/g" - fi - | if [ "$DO_COVERAGE" = "codecov" ]; then export CXXFLAGS="-fprofile-arcs -ftest-coverage" @@ -195,7 +191,7 @@ script: make check-unit-coverage || exit 1 do_codecov unittests - tests/run.sh + make check-integration || exit 1 do_codecov functionaltests do_codecov_gcov c_code diff --git a/CMakeLists.txt b/CMakeLists.txt index 1916d5ce5..3fb5711fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -317,7 +317,7 @@ endif() # }}} # {{{ Theme icons -file(GLOB icon_sources RELATIVE ${SOURCE_DIR} ${SOURCE_DIR}/themes/*/titlebar/*.png) +file(GLOB_RECURSE icon_sources RELATIVE ${SOURCE_DIR} ${SOURCE_DIR}/themes/*.png) foreach(icon ${icon_sources}) # Copy all icons to the build dir to simplify the following code. @@ -405,6 +405,15 @@ add_custom_target(check-integration USES_TERMINAL VERBATIM) add_dependencies(check-integration test-gravity) +add_custom_target(check-themes + ${CMAKE_SOURCE_DIR}/tests/themes/run.sh + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Testing themes" + USES_TERMINAL + DEPENDS generated_icons generate_awesomerc ${PROJECT_AWE_NAME} + VERBATIM) +add_dependencies(check-integration check-themes) + add_custom_target(check-requires lua "${CMAKE_SOURCE_DIR}/build-utils/check_for_invalid_requires.lua" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} diff --git a/tests/_runner.lua b/tests/_runner.lua index 3cfb1530d..2e7c1649b 100644 --- a/tests/_runner.lua +++ b/tests/_runner.lua @@ -66,7 +66,7 @@ runner.run_steps = function(steps, options) step_count = step_count + 1 local step_as_string = step..'/'..#steps..' (@'..step_count..')' if verbose then - print(string.format('Running step %s..', step_as_string)) + io.stderr:write(string.format('Running step %s..\n', step_as_string)) end -- Call the current step's function. diff --git a/tests/run.sh b/tests/run.sh index 138c1291d..57f0d136e 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -161,9 +161,9 @@ 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)" -RC_FILE=${source_dir}/awesomerc.lua -export AWESOME_THEMES_PATH="$source_dir/themes" -export AWESOME_ICON_PATH="$source_dir/icons" +RC_FILE=${AWESOME_RC_FILE:-${source_dir}/awesomerc.lua} +AWESOME_THEMES_PATH="${AWESOME_THEMES_PATH:-${source_dir}/themes}" +AWESOME_ICON_PATH="${AWESOME_ICON_PATH:-${source_dir}/icons}" # Inject coverage runner via temporary RC file. if [ -n "$DO_COVERAGE" ] && [ "$DO_COVERAGE" != 0 ]; then @@ -181,7 +181,10 @@ start_awesome() { cd "$build_dir" # Kill awesome after $timeout_stale seconds (e.g. for errors during test setup). # SOURCE_DIRECTORY is used by .luacov. - DISPLAY="$D" SOURCE_DIRECTORY="$source_dir" timeout "$timeout_stale" "$AWESOME" -c "$RC_FILE" "${awesome_options[@]}" > "$awesome_log" 2>&1 & + DISPLAY="$D" SOURCE_DIRECTORY="$source_dir" \ + AWESOME_THEMES_PATH="$AWESOME_THEMES_PATH" \ + AWESOME_ICON_PATH="$AWESOME_ICON_PATH" \ + timeout "$timeout_stale" "$AWESOME" -c "$RC_FILE" "${awesome_options[@]}" > "$awesome_log" 2>&1 & awesome_pid=$! cd - >/dev/null diff --git a/tests/themes/run.sh b/tests/themes/run.sh new file mode 100755 index 000000000..b49f82364 --- /dev/null +++ b/tests/themes/run.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# +# Test all themes. +# This should be run via `make check-themes` (or manually from the build +# directory). + +set -e + +if ! [ -f CMakeCache.txt ]; then + echo 'This should be run from the build directory (expected CMakeCache.txt).' >&2 + exit 64 +fi +build_dir="$PWD" +tests_dir="$(dirname -- "$0")/.." + +config_file="$build_dir/test-themes-awesomerc.lua" + +for theme in themes/*/theme.lua; do + echo "== Testing $theme ==" + theme=${theme%/*} + theme=${theme##*/} + + sed "s~default/theme~$theme/theme~g" "awesomerc.lua" > "$config_file" + + # Set CMAKE_BINARY_DIR for out-of-tree builds. + CMAKE_BINARY_DIR="$PWD" \ + AWESOME_RC_FILE="$config_file" \ + AWESOME_THEMES_PATH="$PWD/themes" \ + AWESOME_ICON_PATH="$PWD/icons" \ + "$tests_dir/run.sh" themes/tests.lua +done diff --git a/tests/themes/tests.lua b/tests/themes/tests.lua new file mode 100644 index 000000000..93eac95de --- /dev/null +++ b/tests/themes/tests.lua @@ -0,0 +1,18 @@ +--- Simple script to load/test a theme. +-- This is used from tests/themes/run.sh. + +local awful = require("awful") + +local steps = { + function(count) + if count <= 2 then + awful.spawn("xterm") + elseif #client.get() == 2 then + return true + end + end, +} + +require("_runner").run_steps(steps) + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80