From 58f6ef50a86b968b923dfcf5efffacb665fdfa44 Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 25 May 2017 16:50:06 +0300 Subject: [PATCH] ci: Also lint lua code in src/nvim/lua --- CMakeLists.txt | 21 +++++++++++++++++++-- Makefile | 7 +++++-- ci/run_lint.sh | 6 ++++++ cmake/RunLuacheck.cmake | 17 +++++++++++++---- 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab7595eb11..e2c99d9fd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/Makefile b/Makefile index e69475a514..e349cc4d0f 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/ci/run_lint.sh b/ci/run_lint.sh index 73647dacaa..e7f6727448 100755 --- a/ci/run_lint.sh +++ b/ci/run_lint.sh @@ -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 \ diff --git a/cmake/RunLuacheck.cmake b/cmake/RunLuacheck.cmake index addc9ab35e..5129541cd8 100644 --- a/cmake/RunLuacheck.cmake +++ b/cmake/RunLuacheck.cmake @@ -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}")