From 43dba09c28aa273034711089f675664702a78ca0 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 7 Feb 2016 15:29:04 +0100 Subject: [PATCH] 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 00000000..b5f6f621 --- /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 35794134..3ab3d791 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 53d50e16..40ccf385 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