Tarantool development patches archive
 help / color / mirror / Atom feed
From: Igor Munkin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>,
	Timur Safin <tsafin@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH luajit 5/5] test: run luacheck static analysis via CMake
Date: Tue,  2 Feb 2021 23:57:45 +0300
Message-ID: <7057011c43d41adab30dbd13621570418064d38d.1612291495.git.imun@tarantool.org> (raw)
In-Reply-To: <cover.1612291495.git.imun@tarantool.org>

This patch introduces a separate target to run luacheck against all Lua
chunks within LuaJIT repository except those explicitly ignored in
.luacheckrc. There is also a single additional change over the 'luajit'
std defaults: to suppress all false positives related to <misc>
namespace introduced in 5a61e1ab54b5c66bfebd836db1ac47996611e065 ('misc:
add C and Lua API for platform metrics'), this name is added to
<read_globals> list.

All Lua sources originally inherited from LuaJIT vanilla repository are
ignored, to leave them coherent with the upstream.

The new target is a dependency for the root <test> target.

Part of tarantool/tarantool#4862
Part of tarantool/tarantool#5470

Signed-off-by: Igor Munkin <imun@tarantool.org>
---
 .gitignore          |  1 +
 .luacheckrc         | 11 +++++++++++
 test/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)
 create mode 100644 .luacheckrc

diff --git a/.gitignore b/.gitignore
index 35d2580..7902547 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,7 @@ Makefile
 cmake_install.cmake
 compile_commands.json
 install_manifest.txt
+luacheck.ok
 luajit-parse-memprof
 luajit.pc
 tests.ok
diff --git a/.luacheckrc b/.luacheckrc
new file mode 100644
index 0000000..0a5d001
--- /dev/null
+++ b/.luacheckrc
@@ -0,0 +1,11 @@
+-- Use the default LuaJIT globals.
+std = 'luajit'
+-- This fork also introduces a new global for misc API namespace.
+read_globals = { 'misc' }
+
+-- These files are inherited from the vanilla LuaJIT and need to
+-- be coherent with the upstream.
+exclude_files = {
+  'dynasm/',
+  'src/',
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f05dd90..c89efc2 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -3,6 +3,36 @@
 # See the rationale in the root CMakeLists.txt.
 cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
 
+find_program(LUACHECK luacheck)
+if(LUACHECK)
+  set(LUACHECK_RC ${PROJECT_SOURCE_DIR}/.luacheckrc)
+  set(LUACHECK_OK ${CMAKE_CURRENT_BINARY_DIR}/luacheck.ok)
+  file(GLOB_RECURSE LUACHECK_DEPS ${PROJECT_SOURCE_DIR}/*.lua)
+  add_custom_command(
+    COMMENT "Running luacheck static analysis"
+    OUTPUT ${LUACHECK_OK}
+    DEPENDS ${LUACHECK} ${LUACHECK_RC} ${LUACHECK_DEPS}
+    COMMAND
+      ${LUACHECK} ${PROJECT_SOURCE_DIR}
+        --codes
+        --config ${LUACHECK_RC}
+      && touch ${LUACHECK_OK}
+      # XXX: Filenames in .luacheckrc are considered relative to
+      # the working directory, hence luacheck should be run in the
+      # project root directory.
+      WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+  )
+else()
+  add_custom_command(
+    COMMENT "`luacheck' is not found, so ${PROJECT_NAME}-luacheck target is dummy"
+    OUTPUT luacheck.ok
+    COMMAND touch luacheck.ok
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+  )
+endif()
+
+add_custom_target(${PROJECT_NAME}-luacheck DEPENDS luacheck.ok)
+
 add_subdirectory(tarantool-tests)
 
 add_custom_target(${PROJECT_NAME}-test DEPENDS
@@ -24,5 +54,6 @@ if(LUAJIT_USE_TEST)
 
   add_custom_target(test DEPENDS
     ${PROJECT_NAME}-test
+    ${PROJECT_NAME}-luacheck
   )
 endif()
-- 
2.25.0


  parent reply	other threads:[~2021-02-02 21:00 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-02 20:57 [Tarantool-patches] [PATCH luajit 0/5] Self-sufficient LuaJIT testing environment Igor Munkin via Tarantool-patches
2021-02-02 20:57 ` [Tarantool-patches] [PATCH luajit 1/5] build: preserve the original build system Igor Munkin via Tarantool-patches
2021-02-04 22:53   ` Timur Safin via Tarantool-patches
2021-02-08 15:56     ` Igor Munkin via Tarantool-patches
2021-02-09 11:38   ` Sergey Kaplun via Tarantool-patches
2021-02-09 12:47     ` Igor Munkin via Tarantool-patches
2021-02-09 14:45       ` Sergey Kaplun via Tarantool-patches
2021-02-09 15:28         ` Igor Munkin via Tarantool-patches
2021-02-10  9:35           ` Sergey Kaplun via Tarantool-patches
2021-02-02 20:57 ` [Tarantool-patches] [PATCH luajit 2/5] build: replace GNU Make with CMake Igor Munkin via Tarantool-patches
2021-02-04 22:53   ` Timur Safin via Tarantool-patches
2021-02-08 15:56     ` Igor Munkin via Tarantool-patches
2021-02-09 13:55       ` Timur Safin via Tarantool-patches
2021-02-09 15:09         ` Igor Munkin via Tarantool-patches
2021-02-11 19:23   ` Sergey Kaplun via Tarantool-patches
2021-02-16 15:28     ` Igor Munkin via Tarantool-patches
2021-02-18  9:56       ` Sergey Kaplun via Tarantool-patches
2021-02-20 19:18         ` Igor Munkin via Tarantool-patches
2021-02-27 10:48           ` Sergey Kaplun via Tarantool-patches
2021-02-28 18:18             ` Igor Munkin via Tarantool-patches
2021-02-13  3:47   ` Sergey Kaplun via Tarantool-patches
2021-02-16 15:32     ` Igor Munkin via Tarantool-patches
2021-02-02 20:57 ` [Tarantool-patches] [PATCH luajit 3/5] test: run LuaJIT tests via CMake Igor Munkin via Tarantool-patches
2021-02-08 15:05   ` Timur Safin via Tarantool-patches
2021-02-08 16:29     ` Igor Munkin via Tarantool-patches
2021-02-09  8:16       ` Timur Safin via Tarantool-patches
2021-02-09  8:43         ` Igor Munkin via Tarantool-patches
2021-02-09 13:59           ` Timur Safin via Tarantool-patches
2021-02-09 15:10             ` Igor Munkin via Tarantool-patches
2021-02-14 18:48   ` Sergey Kaplun via Tarantool-patches
2021-02-19 19:04     ` Igor Munkin via Tarantool-patches
2021-02-27 13:50       ` Sergey Kaplun via Tarantool-patches
2021-02-28 18:18         ` Igor Munkin via Tarantool-patches
2021-02-02 20:57 ` [Tarantool-patches] [PATCH luajit 4/5] test: fix warnings found with luacheck in misclib* Igor Munkin via Tarantool-patches
     [not found]   ` <012f01d6fe1a$a2aa6890$e7ff39b0$@tarantool.org>
2021-02-08 15:57     ` Igor Munkin via Tarantool-patches
     [not found]     ` <2c495492-50f4-acfd-ad66-2cb44abb5fa1@tarantool.org>
2021-02-08 15:40       ` Sergey Bronnikov via Tarantool-patches
2021-02-08 15:58       ` Igor Munkin via Tarantool-patches
2021-02-14 19:16   ` Sergey Kaplun via Tarantool-patches
2021-02-16 15:29     ` Igor Munkin via Tarantool-patches
2021-02-16 16:36       ` Sergey Kaplun via Tarantool-patches
2021-02-02 20:57 ` Igor Munkin via Tarantool-patches [this message]
2021-02-04 22:52   ` [Tarantool-patches] [PATCH luajit 5/5] test: run luacheck static analysis via CMake Timur Safin via Tarantool-patches
2021-02-08 15:57     ` Igor Munkin via Tarantool-patches
2021-02-14 19:32   ` Sergey Kaplun via Tarantool-patches
2021-02-19 19:14     ` Igor Munkin via Tarantool-patches
2021-02-28 22:04 ` [Tarantool-patches] [PATCH luajit 0/5] Self-sufficient LuaJIT testing environment Igor Munkin via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7057011c43d41adab30dbd13621570418064d38d.1612291495.git.imun@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imun@tarantool.org \
    --cc=skaplun@tarantool.org \
    --cc=tsafin@tarantool.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git