From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 9AA8D6B461; Wed, 3 Mar 2021 21:02:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9AA8D6B461 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1614794572; bh=tNkbz0feOiP66RJt2Yp0zdXWqA0PAnffNN6LApZuB7E=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=pw82/x16IB4i1ZEVC0yMY1ruZV2O7YSlJCCEwBVodDQ44osKQJOKA2fl8W0S8RJ3F 1evBxVDBBlR/D+R+TRucgHqnnS7c4SqTaQrf7bs3g1mjGLAkaJpO78ZPuf56N1T4/2 8elH7LE31vJuVwGNb2RiCmD8TYh43GuUE/ob5Ayg= Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [94.100.177.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9C6B86B461 for ; Wed, 3 Mar 2021 21:02:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9C6B86B461 Received: by smtp50.i.mail.ru with esmtpa (envelope-from ) id 1lHVph-0003hA-JD; Wed, 03 Mar 2021 21:02:50 +0300 Date: Wed, 3 Mar 2021 21:02:57 +0300 To: Igor Munkin Message-ID: <20210303180257.ktityub26cd27ogh@tkn_work_nb> References: <524c0ce8acc18111ab4c8b36e383ff192779c780.1613661908.git.alexander.turenko@tarantool.org> <20210226181158.GD9042@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210226181158.GD9042@tarantool.org> X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92A98208ECBDD29F5BCF62610559114B730DD7337B29CB406182A05F53808504065569A4BD470A9DE363ADD7A94391B68BACA8EB2042D7D1A86CB9D3597FA8FB2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79A02CDD1178524C2EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379FED03E15F715FAA8638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95CDB1C6D2319E1F167C8D2E9B87A694E5CD09912A18BFA465FA471835C12D1D9774AD6D5ED66289B5259CC434672EE6371117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE71AE4D56B06699BBC9FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE7ECBA5718FF5EB491D32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED62991661749BA6B977359935A1E27F592749B3661434B16C20AC78D18283394535A975ECD9A6C639B01BC09775C1D3CA48CF09A7649CC036878F35872C767BF85DA22EF20D2F80756B5F40A5AABA2AD3711975ECD9A6C639B01B78DA827A17800CE7F45C1E71A9DFFA2A731C566533BA786A40A5AABA2AD371193C9F3DD0FB1AF5EB39B26F9A09A85A293C9F3DD0FB1AF5EB4E70A05D1297E1BBCB5012B2E24CD356 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A24A6D60772A99906F8E1CD14B953EB46D2EC56D9DF168F0E7355D89D7DBCDD132 X-C1DE0DAB: 0D63561A33F958A5ADCE2F7174298DF6D1FD77B9A50CC0755897F745BB35B9A9D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3444047AE358B40754B402275E8A666534D18D8C6F91DB7D85C80509E212AFE3040BF57A3CF6BE14161D7E09C32AA3244C41BA9EE3682A1BF1F5ACA89A3AFDEE4E725D5B54B2FE4575FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnllmSZCgRqtZxFsONYc96A== X-Mailru-Sender: FFAA8E4AEE17E37C3731A083A1A85ADE1F48719091DAD605730C7C9FF1AF9775B7EA9FE7735C3DBFC664A44C781FCEA7C77752E0C033A69EDF9F2CE1E9CF805D8CD356D4F938FF726C18EFA0BB12DBB0 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2] tools: fix luacheck invocation in different cases X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Alexander Turenko via Tarantool-patches Reply-To: Alexander Turenko Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" I asked Igor for a voice discussion to clarify his points. The summary is below. Second and third points were mixed a bit, so I'll reword and repeat Igor's points. The key idea of Igor's proposal: we have two exclusions mechanisms: .luacheckrc and --exclude-files. He stated that we can use just one. There si also the statement that the --exclude-files (the builddir exclusion) is necessary solely to get rid of luajit autogenerated files. Both statements have their flaws. The build dir exclusion is not solely for luajit generated files. We have test files in the build directory, copied from the source directory during `make test`. .luacheckrc contains file specific rules for particular test files and the paths are like 'test/box/box.lua' -- relative to the source dir. It'll not match the copies in the build dir, so we'll get warnings for them (when a build directory is under the source directory). It seems that excluding of the builddir entirely with --exclude-files is the easiest way to solve the problem. I'll note that a build directory name is arbitrary, so we unable to exclude it like `build/**/*.lua` using .luacheckrc (or we should generate the config...). On the other hand, we unable to entirely remove .luacheckrc exclusions, because there is no separate build dir for in-source build (`cmake .`). So I see the following alternatives to my solution: 1. Generate .luacheckrc and get rid of --exclude-files. - So we should store a template in the repo, generate the file. - We unable to call luacheck directly, without cmake/make (or should explicitly set the template as the config). - I dislike this alternative, it is too complex and restrictive. 2. Use exclusions / matching patterns like '**/box/box.lua' in .luacheckrc to match a build directory content too. - This looks fragile: it may be broken by a build layout / test vardir layout changes. - It'll not be quite obvious, why the config is written in such strange way. - I'm not sure that such path patterns will not match something that we don't intend to match. - I don't know, to be honest, whether it'll work at all. So I would keep the proposed solution, because it still looks as the simplest one. Igor, please, agree explicitly or challenge my point. BTW, while looking into the problem with Igor, we found that luajit's luacheck rule fails on source / build paths with symlinks components. The solution is to use real paths everywhere. On Fri, Feb 26, 2021 at 09:11:58PM +0300, Igor Munkin wrote: > Sasha, > > Thanks for your patch! > > TL;DR: the patch LGTM (but I agree with Sergey regarding the whitespace > in statement). At the same time I see a small rationale for such > complex logic, considering the upcoming LuaJIT build system refactoring > and the fact your solution doesn't work in the most general case (but > nobody asked for it). > > As we discussed before we have three possible cases of configuration: > 1. do not intersect with ("true" OOS build) > 2. is (in source build) > 3. is a subdirectory within ("quasi" OOS build) > > The first case is very simple: you need only run luacheck within > , since all paths in .luacheckrc are considered relative to the > current working directory. This issue is solved via WORKING_DIRECTORY > property and you even resolve all symlinks for . > > The second case is a bit tricky: there might be autogenerated Lua chunks > (e.g. jit/vmdef.lua). These files are not considered as Lua sources per > se, so there is no need to check these files with luacheck. Then simply > exclude the whole recursively and the issue is completely gone. > Unfortunately, it's not. > > The third case is the most complex one, though it doesn't look so. In > case of in source build, those autogenerated Lua chunks are build within > and there is no other way than explicitly exclude those files > from the list to be checked with luacheck. We don't face this case, > since everything within third_party/luajit/ is excluded from check. I > even haven't faced this in LuaJIT submodule, since src/ directory is > excluded from the check, so src/jit/vmdef.lua is not checked. Hence if > there would be an autogenerated Lua chunk violating .luacheckrc rules in > scope of Tarantool src/ directory, you had to explicitly suppress it to > make luacheck happy. > > I hope my arguments are clear enough. > > Let's return to LuaJIT build system enhancements. If out of source build > is used now, LuaJIT submodule is fully copied to the , so all > Lua sources are moved in Tarantool source tree. Hence they are checked > with luacheck and there are many warnings produced. In scope of #4862 I > reimplemented LuaJIT source tree manipulations, so all LuaJIT sources > are left within third_party/luajit despite to the chosen build type. > > As a result, there is a single Lua file violating luacheck warnings: > jit/vmdef.lua that is generated within Tarantool source tree (in "quasi" > out of source build case). It looks to be much easier to explicitly > exclude this single file via --exclude-files option and leave the > comment with the rationale, since you complex solution doesn't work in a > general case. > > Anyway, this is not a major point against applying your changes, but > rather common sense. Everything except the point above is OK, so if you > are sure with your solution feel free to proceed with the patch. > > On 18.02.21, Alexander Turenko wrote: > > Now `make luacheck` gracefully handles different cases: in-source and > > out-of-source build (within the source tree or outside), current working > > directory as a real path or with symlink components. > > > > As result of looking into those problems I filed the issue [1] against > > luacheck. It seems, there are problems around absolute paths with > > symlinks components. > > > > [1]: https://github.com/mpeterv/luacheck/issues/208 > > --- > > > > no issue > > Totktonada/fix-luacheck-invocation > > https://github.com/tarantool/tarantool/tree/Totktonada/fix-luacheck-invocation > > > > Changes since v1: > > > > * Moved the logic to CMake, dropped the shell wrapper. > > * Shrink comments. > > * Handled the case, when a build directory is in the source directory, > > and cmake is called not like `cmake ..`, but `cmake /path/to/source`, > > where the path is not a real path. > > > > CMakeLists.txt | 28 ++++++++++++++++++++++++++-- > > cmake/utils.cmake | 22 ++++++++++++++++++++++ > > 2 files changed, 48 insertions(+), 2 deletions(-) > > > > > diff --git a/cmake/utils.cmake b/cmake/utils.cmake > > index eaec821b3..e9b5fed5d 100644 > > --- a/cmake/utils.cmake > > +++ b/cmake/utils.cmake > > @@ -86,3 +86,25 @@ function(bin_source varname srcfile dstfile) > > > > endfunction() > > > > +# > > +# Whether a file is descendant to a directory. > > +# > > +# If the file is the directory itself, the answer is FALSE. > > +# > > +function(file_is_in_directory varname file dir) > > + file(RELATIVE_PATH file_relative "${dir}" "${file}") > > + if (file_relative STREQUAL "") > > + # and is the same directory. > > + set(${varname} FALSE PARENT_SCOPE) > > + elseif (file_relative STREQUAL "..") > > + # inside a (so it is a directory too), not > > + # vice versa. > > + set(${varname} FALSE PARENT_SCOPE) > > It looks this branch is excess and is covered by the next one (if you > remove the trailing slash). > > > + elseif (file_relative MATCHES "^\\.\\./") > > + # somewhere outside of the . > > + set(${varname} FALSE PARENT_SCOPE) > > + else() > > + # is descendant to . > > + set(${varname} TRUE PARENT_SCOPE) > > + endif() > > +endfunction() > > -- > > 2.30.0 > > > > -- > Best regards, > IM