Skip to content

Commit

Permalink
ci: Also lint lua code in src/nvim/lua
Browse files Browse the repository at this point in the history
  • Loading branch information
ZyX-I committed May 25, 2017
1 parent 5b84c21 commit 58f6ef5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
21 changes: 19 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,26 @@ if(LUACHECK_PRG)
add_custom_target(testlint
COMMAND ${CMAKE_COMMAND}
-DLUACHECK_PRG=${LUACHECK_PRG}
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
-DLUAFILES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
-DIGNORE_PATTERN="*/preload.lua"
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
-P ${PROJECT_SOURCE_DIR}/cmake/RunTestsLint.cmake)
-P ${PROJECT_SOURCE_DIR}/cmake/RunLuacheck.cmake)

add_custom_target(
blobcodelint
COMMAND
${CMAKE_COMMAND}
-DLUACHECK_PRG=${LUACHECK_PRG}
-DLUAFILES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/src/nvim/lua
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
-DREAD_GLOBALS=vim
-P ${PROJECT_SOURCE_DIR}/cmake/RunLuacheck.cmake
)
# TODO(ZyX-I): Run linter for all lua code in src
add_custom_target(
lualint
DEPENDS blobcodelint
)
endif()

set(CPACK_PACKAGE_NAME "Neovim")
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ functionaltest-lua: | nvim
testlint: | build/.ran-cmake deps
$(BUILD_CMD) -C build testlint

lualint: | build/.ran-cmake deps
$(BUILD_CMD) -C build lualint

unittest: | nvim
+$(BUILD_CMD) -C build unittest

Expand Down Expand Up @@ -138,6 +141,6 @@ check-single-includes: build/.ran-cmake
appimage:
bash scripts/genappimage.sh

lint: check-single-includes clint testlint
lint: check-single-includes clint testlint lualint

.PHONY: test testlint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage
.PHONY: test testlint lualint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage
6 changes: 6 additions & 0 deletions ci/run_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ run_test 'top_make testlint' testlint

exit_suite --continue

enter_suite 'lualint'

run_test 'top_make lualint' lualint

exit_suite --continue

enter_suite single-includes

CLICOLOR_FORCE=1 run_test_wd \
Expand Down
17 changes: 13 additions & 4 deletions cmake/RunLuacheck.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
set(IGNORE_FILES "${TEST_DIR}/*/preload.lua")
set(LUACHECK_ARGS -q "${LUAFILES_DIR}")
if(DEFINED IGNORE_PATTERN)
list(APPEND LUACHECK_ARGS --exclude-files "${LUAFILES_DIR}/${IGNORE_PATTERN}")
endif()
if(DEFINED CHECK_PATTERN)
list(APPEND LUACHECK_ARGS --include-files "${LUAFILES_DIR}/${CHECK_PATTERN}")
endif()
if(DEFINED READ_GLOBALS)
list(APPEND LUACHECK_ARGS --read-globals "${READ_GLOBALS}")
endif()

execute_process(
COMMAND ${LUACHECK_PRG} -q ${TEST_DIR} --exclude-files ${IGNORE_FILES}
WORKING_DIRECTORY ${TEST_DIR}
COMMAND "${LUACHECK_PRG}" ${LUACHECK_ARGS}
WORKING_DIRECTORY "${LUAFILES_DIR}"
ERROR_VARIABLE err
RESULT_VARIABLE res
${EXTRA_ARGS})
)

if(NOT res EQUAL 0)
message(STATUS "Output to stderr:\n${err}")
Expand Down

0 comments on commit 58f6ef5

Please sign in to comment.