Add check-themes, which tests themes via tests/themes/

It relies on tests/run.sh to handle failures.
This commit is contained in:
Daniel Hahler 2017-08-10 12:16:27 +02:00
parent f36738f115
commit f698a17138
3 changed files with 58 additions and 0 deletions

View File

@ -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}

31
tests/themes/run.sh Executable file
View File

@ -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

18
tests/themes/tests.lua Normal file
View File

@ -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