Merge pull request #676 from psychon/luacheck

Luacheck
This commit is contained in:
Daniel Hahler 2016-02-17 17:15:08 +01:00
commit a6dd6b4a20
4 changed files with 60 additions and 12 deletions

36
.luacheckrc Normal file
View File

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

View File

@ -66,8 +66,10 @@ install:
- sudo apt-get install -y gir1.2-pango-1.0 libgirepository1.0-dev - sudo apt-get install -y gir1.2-pango-1.0 libgirepository1.0-dev
- travis_retry sudo luarocks install lgi $LGIVER - travis_retry sudo luarocks install lgi $LGIVER
# Install busted for "make check". # Install busted for "make check-unit".
- travis_retry sudo luarocks install busted - travis_retry sudo luarocks install busted
# Install luacheck for "make luacheck".
- travis_retry sudo luarocks install luacheck
# Install ldoc for building docs. # Install ldoc for building docs.
- travis_retry sudo luarocks install ldoc - travis_retry sudo luarocks install ldoc

View File

@ -352,14 +352,24 @@ endif()
# }}} # }}}
# {{{ Tests # {{{ 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) find_program(BUSTED_EXECUTABLE busted)
if(BUSTED_EXECUTABLE) if(BUSTED_EXECUTABLE)
# Keep the arguments in sync with the version below!
add_custom_target(check-unit ALL add_custom_target(check-unit ALL
${BUSTED_EXECUTABLE} "--helper=${CMAKE_SOURCE_DIR}/spec/preload.lua" ${BUSTED_EXECUTABLE} "--helper=${CMAKE_SOURCE_DIR}/spec/preload.lua"
"--lpath=${CMAKE_BINARY_DIR}/lib/?.lua;${CMAKE_BINARY_DIR}/lib/?/init.lua;spec/?.lua" "--lpath=${CMAKE_BINARY_DIR}/lib/?.lua;${CMAKE_BINARY_DIR}/lib/?/init.lua;spec/?.lua"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Running unit tests" COMMENT "Running unit tests"
VERBATIM) VERBATIM)
list(APPEND CHECK_TARGETS check-unit)
# Same as above, but with --coverage argument
add_custom_target(check-coverage add_custom_target(check-coverage
"BUILD_DIRECTORY=${CMAKE_BINARY_DIR}/" "BUILD_DIRECTORY=${CMAKE_BINARY_DIR}/"
${BUSTED_EXECUTABLE} "--helper=${CMAKE_SOURCE_DIR}/spec/preload.lua" ${BUSTED_EXECUTABLE} "--helper=${CMAKE_SOURCE_DIR}/spec/preload.lua"
@ -369,16 +379,16 @@ if(BUSTED_EXECUTABLE)
COMMENT "Running unit tests under LuaCov" COMMENT "Running unit tests under LuaCov"
VERBATIM) VERBATIM)
endif() endif()
add_custom_target(check-integration find_program(LUACHECK_EXECUTABLE luacheck)
"${CMAKE_SOURCE_DIR}/tests/run.sh" if(LUACHECK_EXECUTABLE)
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} add_custom_target(luacheck
COMMENT "Running integration tests" ${LUACHECK_EXECUTABLE} lib spec tests themes awesomerc.lua
VERBATIM) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
if(BUSTED_EXECUTABLE) COMMENT "Running Luacheck"
add_custom_target(check DEPENDS check-integration check-unit) VERBATIM)
else() list(APPEND CHECK_TARGETS luacheck)
add_custom_target(check DEPENDS check-integration)
endif() endif()
add_custom_target(check DEPENDS ${CHECK_TARGETS})
# }}} # }}}
# vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker

View File

@ -163,7 +163,7 @@ function stack:raise_widget(widget, recursive)
end end
end end
local function new(dir, widget1, ...) local function new(...)
local ret = fixed.horizontal(...) local ret = fixed.horizontal(...)
util.table.crush(ret, stack) util.table.crush(ret, stack)
@ -171,7 +171,7 @@ local function new(dir, widget1, ...)
return ret return ret
end end
function stack.mt:__call(...) function stack.mt:__call(_, ...)
return new(...) return new(...)
end end