Test that beautiful is not used too early (#1471)
For loading a theme, beautiful.init() has to be called. We do not handle dynamic changes of the theme, so if the theme is changed after something was already queried, this change will not apply. This also means that before the theme is loaded, nothing useful can be returned. In fact, code that tries to access the theme during require() will never get a useful value from beautiful, but just nils. To catch this, one Travis build is modified so that an error is raised if the theme is accessed before beautiful.init() was called. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
e36f28a097
commit
844bd1eb05
|
@ -12,7 +12,7 @@ env:
|
|||
matrix:
|
||||
- LUA=5.2 DO_CHECKQA=1 LUANAME=lua5.2 DO_COVERAGE=coveralls
|
||||
# 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.4 TEST_PREV_COMMITS=1
|
||||
- LUA=5.1 LUANAME=luajit-2.0 LUALIBRARY=/usr/lib/libluajit-5.1.so LUAROCKS_ARGS=--lua-suffix=jit-2.0.4 TEST_PREV_COMMITS=1 EMPTY_THEME_WHILE_LOADING=1
|
||||
# Note: luarocks does not work with Lua 5.0.
|
||||
- LUA=5.1 LUANAME=lua5.1 BUILD_IN_DIR=/tmp/awesome-build
|
||||
# Lua 5.2 with older lgi and screen size not divisible by 2.
|
||||
|
@ -138,6 +138,12 @@ install:
|
|||
}
|
||||
script:
|
||||
- export CMAKE_ARGS="-DLUA_LIBRARY=${LUALIBRARY} -DLUA_INCLUDE_DIR=${LUAINCLUDE} -D OVERRIDE_VERSION=$AWESOME_VERSION -DSTRICT_TESTS=true"
|
||||
- |
|
||||
if [ "$EMPTY_THEME_WHILE_LOADING" = 1 ]; then
|
||||
# Break beautiful so that trying to access the theme before beautiful.init() causes an error
|
||||
sed -i -e 's/theme = {}/theme = setmetatable({}, { __index = function() error("May not access theme before beautiful.init()") end })/' lib/beautiful/init.lua \
|
||||
&& grep -q 'May not access' lib/beautiful/init.lua
|
||||
fi
|
||||
- |
|
||||
set -e
|
||||
if [ -n "$BUILD_IN_DIR" ]; then
|
||||
|
|
|
@ -3,4 +3,7 @@
|
|||
-- is not safe to reload and yet Busted manages to do this.
|
||||
require("lgi")
|
||||
|
||||
-- "fix" some intentional beautiful breakage done by .travis.yml
|
||||
require("beautiful").init{}
|
||||
|
||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||
|
|
Loading…
Reference in New Issue