From 267ab282b251072d5df0962fbfed3556ec60f26d Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 7 Feb 2016 14:13:43 +0100 Subject: [PATCH 1/2] Sanitize argument handling for wibox.layout.stack constructor Signed-off-by: Uli Schlachter --- lib/wibox/layout/stack.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/wibox/layout/stack.lua b/lib/wibox/layout/stack.lua index 910270cb1..dd26822ed 100644 --- a/lib/wibox/layout/stack.lua +++ b/lib/wibox/layout/stack.lua @@ -163,7 +163,7 @@ function stack:raise_widget(widget, recursive) end end -local function new(dir, widget1, ...) +local function new(...) local ret = fixed.horizontal(...) util.table.crush(ret, stack) @@ -171,7 +171,7 @@ local function new(dir, widget1, ...) return ret end -function stack.mt:__call(...) +function stack.mt:__call(_, ...) return new(...) end From 43dba09c28aa273034711089f675664702a78ca0 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 7 Feb 2016 15:29:04 +0100 Subject: [PATCH 2/2] Add& use Luacheck support This commit adds a new "luacheck" target to the Makefiles. This target is automatically included in "make check" when luacheck is found in $PATH. Additionally, this includes luacheck in Travis so that the build fails when luacheck complains about something. Signed-off-by: Uli Schlachter --- .luacheckrc | 36 ++++++++++++++++++++++++++++++++++++ .travis.yml | 4 +++- CMakeLists.txt | 28 +++++++++++++++++++--------- 3 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 .luacheckrc diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 000000000..b5f6f6216 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,36 @@ +-- Only allow symbols available in all Lua versions +std = "min" + +-- Get rid of "unused argument self"-warnings +self = false + +-- The unit tests can use busted +files["spec"].std = "+busted" + +-- The default config may set global variables +files["awesomerc.lua"].allow_defined_top = true + +-- Global objects defined by the C code +read_globals = { + "awesome", + "button", + "client", + "dbus", + "drawable", + "drawin", + "key", + "keygrabber", + "mouse", + "mousegrabber", + "root", + "screen", + "selection", + "tag", + "window", +} +-- May not be read-only due to client.focus +globals = { + "client" +} + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/.travis.yml b/.travis.yml index 357941344..3ab3d791e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,8 +66,10 @@ install: - sudo apt-get install -y gir1.2-pango-1.0 libgirepository1.0-dev - travis_retry sudo luarocks install lgi $LGIVER - # Install busted for "make check". + # Install busted for "make check-unit". - travis_retry sudo luarocks install busted + # Install luacheck for "make luacheck". + - travis_retry sudo luarocks install luacheck # Install ldoc for building docs. - travis_retry sudo luarocks install ldoc diff --git a/CMakeLists.txt b/CMakeLists.txt index 53d50e165..40ccf385d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -352,14 +352,24 @@ endif() # }}} # {{{ Tests +set(CHECK_TARGETS check-integration) +add_custom_target(check-integration + "${CMAKE_SOURCE_DIR}/tests/run.sh" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "Running integration tests" + VERBATIM) find_program(BUSTED_EXECUTABLE busted) if(BUSTED_EXECUTABLE) + # Keep the arguments in sync with the version below! add_custom_target(check-unit ALL ${BUSTED_EXECUTABLE} "--helper=${CMAKE_SOURCE_DIR}/spec/preload.lua" "--lpath=${CMAKE_BINARY_DIR}/lib/?.lua;${CMAKE_BINARY_DIR}/lib/?/init.lua;spec/?.lua" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMENT "Running unit tests" VERBATIM) + list(APPEND CHECK_TARGETS check-unit) + + # Same as above, but with --coverage argument add_custom_target(check-coverage "BUILD_DIRECTORY=${CMAKE_BINARY_DIR}/" ${BUSTED_EXECUTABLE} "--helper=${CMAKE_SOURCE_DIR}/spec/preload.lua" @@ -369,16 +379,16 @@ if(BUSTED_EXECUTABLE) COMMENT "Running unit tests under LuaCov" VERBATIM) endif() -add_custom_target(check-integration - "${CMAKE_SOURCE_DIR}/tests/run.sh" - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMENT "Running integration tests" - VERBATIM) -if(BUSTED_EXECUTABLE) - add_custom_target(check DEPENDS check-integration check-unit) -else() - add_custom_target(check DEPENDS check-integration) +find_program(LUACHECK_EXECUTABLE luacheck) +if(LUACHECK_EXECUTABLE) + add_custom_target(luacheck + ${LUACHECK_EXECUTABLE} lib spec tests themes awesomerc.lua + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "Running Luacheck" + VERBATIM) + list(APPEND CHECK_TARGETS luacheck) endif() +add_custom_target(check DEPENDS ${CHECK_TARGETS}) # }}} # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker