mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
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 <psychon@znc.in>
This commit is contained in:
parent
267ab282b2
commit
43dba09c28
3 changed files with 58 additions and 10 deletions
36
.luacheckrc
Normal file
36
.luacheckrc
Normal 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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue