From f698a17138cd9c1d55f3d8f146c1337bf28798de Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 10 Aug 2017 12:16:27 +0200 Subject: [PATCH] Add check-themes, which tests themes via tests/themes/ It relies on tests/run.sh to handle failures. --- CMakeLists.txt | 9 +++++++++ tests/themes/run.sh | 31 +++++++++++++++++++++++++++++++ tests/themes/tests.lua | 18 ++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100755 tests/themes/run.sh create mode 100644 tests/themes/tests.lua diff --git a/CMakeLists.txt b/CMakeLists.txt index 61b82bc7..3fb5711f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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/themes/run.sh b/tests/themes/run.sh new file mode 100755 index 00000000..b49f8236 --- /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 00000000..93eac95d --- /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