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 7A91970358; Tue, 16 Feb 2021 15:02:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7A91970358 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1613476962; bh=G+3JP5zjDGZ+trm/AIPOV3Vktbcdk00XauMdaEejziM=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mC8+ldTQrMJBF/2MaoTndGYmOkjkI+D1iflI6MiwkQNtqas6qb/SaANPY8BFCuqby /2UnXJtQXkQ6xpBR3WjL5j98sG5rToh52CxSx8+KuAALzuFhpP1GztYnnDCJ98xVTu qkkKmXTIFxQfaW22K+5XCAyrtph5rHIS2DDYVC9s= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 1F5BB70358 for ; Tue, 16 Feb 2021 15:02:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1F5BB70358 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lBz3r-0006RC-Dt; Tue, 16 Feb 2021 15:02:36 +0300 To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org References: <3a5360daf42cd920e3ce536020a6ff2fbccc095e.1611232655.git.sergeyb@tarantool.org> <140f1c8e-dc25-3295-9bd8-e7835e2e89c8@tarantool.org> Message-ID: Date: Tue, 16 Feb 2021 15:02:35 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <140f1c8e-dc25-3295-9bd8-e7835e2e89c8@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91883A1EE8D2E9932D506EC6BA87A3EB96A68A3F1035BC666182A05F53808504054329A9F1B2A7A5C1E341A1D9573429309627C481AAC07EB6705490272CA1961 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE746A11221A744BA93EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377A079619B0C2EE308638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FC187C61FB4D580F013EC921ED9660EE081EDA81475BEB45CE389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6957A4DEDD2346B42CC7F00164DA146DA6F5DAA56C3B73B23C77107234E2CFBA567F23339F89546C55F5C1EE8F4F765FCB835E6E385EA5AF075ECD9A6C639B01BBD4B6F7A4D31EC0BC0CAF46E325F83A522CA9DD8327EE4930A3850AC1BE2E735C96613F75B7D048DC4224003CC836476C0CAF46E325F83A50BF2EBBBDD9D6B0F8DB212830C5B42F72623479134186CDE6BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A52CFC7432BA7AF25E020F021287C0F996580F7AEF949FEC54D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D341ADA1A41A420E9B29C41FB50F758026AD094D291A80C946C89E46F43F390AA473F99A02B77D3EE851D7E09C32AA3244CB15591EE60E5875DEEEC1142E73C68C1BBA718C7E6A9E042FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojiBTwj6noE5fRwpUEeTSzow== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638223F9866B27E1A4C1E03376F847B81F71BDD788429FD8613638ED9BB8B05EE7B3AFB559BB5D741EB96D19CD4E7312BAA970A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v8 03/14] test: fix luacheck warnings W113 in test/sql-tap 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: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, thanks for review! On 24.01.2021 20:33, Vladislav Shpilevoy wrote: > Hi! Thanks for the patch! > > See 3 comments below. > > On 21.01.2021 13:49, sergeyb@tarantool.org wrote: >> From: Sergey Bronnikov >> >> W113 (Accessing an undefined global variable) >> >> Part of #5464 >> --- >> .luacheckrc | 37 +++++++++- >> test/sql-tap/badutf1.test.lua | 10 ++- >> test/sql-tap/index1.test.lua | 2 +- >> test/sql-tap/lua/sqltester.lua | 2 +- >> test/sql-tap/lua_sql.test.lua | 6 +- >> test/sql-tap/minmax2.test.lua | 2 + >> test/sql-tap/select1.test.lua | 4 ++ >> test/sql-tap/subquery.test.lua | 7 +- >> test/sql-tap/table.test.lua | 6 +- >> test/sql-tap/tkt1443.test.lua | 2 +- >> test/sql-tap/trigger9.test.lua | 1 + >> test/sql-tap/triggerC.test.lua | 1 - >> test/sql-tap/view.test.lua | 126 +++++++++++++++------------------ >> 13 files changed, 122 insertions(+), 84 deletions(-) >> >> diff --git a/.luacheckrc b/.luacheckrc >> index 81aa61a2b..eb709d6a3 100644 >> --- a/.luacheckrc >> +++ b/.luacheckrc >> @@ -124,3 +122,38 @@ files["test/box-tap/extended_error.test.lua"] = { >> "forbidden_function", >> }, >> } >> +files["test/sql-tap/analyze5.test.lua"] = { >> + ignore = { >> + "113", >> + }, >> +} >> +files["test/sql-tap/cast.test.lua"] = { >> + ignore = { >> + "113", >> + }, >> +} >> +files["test/sql-tap/func.test.lua"] = { >> + ignore = { >> + "113", >> + }, >> +} >> +files["test/sql-tap/e_expr.test.lua"] = { >> + ignore = { >> + "113", >> + }, >> +} >> +files["test/sql-tap/e_select1.test.lua"] = { >> + ignore = { >> + "113", >> + }, >> +} >> +files["test/sql-tap/misc1.test.lua"] = { >> + ignore = { >> + "113", >> + }, >> +} >> +files["test/sql-tap/sort.test.lua"] = { >> + ignore = { >> + "113", >> + }, >> +} > 1. The commit title says "fix", but it does not look like a fix. > I suggest you to try harder to remove the warnings, not hide them. > For example, analyze5 can be fixed like this: > > ==================== > diff --git a/.luacheckrc b/.luacheckrc > index eb709d6a3..977eb2945 100644 > --- a/.luacheckrc > +++ b/.luacheckrc > @@ -122,11 +122,6 @@ files["test/box-tap/extended_error.test.lua"] = { > "forbidden_function", > }, > } > -files["test/sql-tap/analyze5.test.lua"] = { > - ignore = { > - "113", > - }, > -} > files["test/sql-tap/cast.test.lua"] = { > ignore = { > "113", > diff --git a/test/sql-tap/analyze5.test.lua b/test/sql-tap/analyze5.test.lua > index 1d6665ad0..a9eb4dd2f 100755 > --- a/test/sql-tap/analyze5.test.lua > +++ b/test/sql-tap/analyze5.test.lua > @@ -26,6 +26,8 @@ local function eqp(sql) > return test:execsql("EXPLAIN QUERY PLAN"..sql) > end > > +local X = nil > + > local function alpha(blob) > local ret = "" > for _, c in ipairs(X(37, "X!cmd", [=[["split",["blob"],""]]=])) do > @@ -155,6 +157,9 @@ test:do_test( > > -- Verify that range queries generate the correct row count estimates > -- > +local t1x = nil > +local t1y = nil > +local t1z = nil > for i, v in pairs({ > {'z>=0 AND z<=0', t1z, 400}, > {'z>=1 AND z<=1', t1z, 300}, > ==================== > > It does not make much sense, and the whole test does not make it, because > it is disabled. But it is better than just move the ignores from one > place to another. At least now they are local to the disabled places, > not to the whole file. > > Cast.test.lua: > > ==================== > diff --git a/.luacheckrc b/.luacheckrc > index eb709d6a3..15944e378 100644 > --- a/.luacheckrc > +++ b/.luacheckrc > @@ -127,11 +127,6 @@ files["test/sql-tap/analyze5.test.lua"] = { > "113", > }, > } > -files["test/sql-tap/cast.test.lua"] = { > - ignore = { > - "113", > - }, > -} > files["test/sql-tap/func.test.lua"] = { > ignore = { > "113", > diff --git a/test/sql-tap/cast.test.lua b/test/sql-tap/cast.test.lua > index 4d7c92cfc..bcee65d9b 100755 > --- a/test/sql-tap/cast.test.lua > +++ b/test/sql-tap/cast.test.lua > @@ -786,13 +786,19 @@ test:do_execsql_test( > -- Test to see if it is possible to trick sql into reading past > -- the end of a blob when converting it to a number. > if 0 > 0 then > +-- Legacy from the original code. Must be replaced with analogue > +-- functions from box. > +local sql_prepare = nil > +local sql_bind_blob = nil > +local sql_step = nil > +local sql_column_int = nil > +local STMT > test:do_test( > "cast-3.32.1", > function() > - local blob, DB, STMT > + local blob > blob = 1234567890 > - DB = sql_connection_pointer("db") > - STMT = sql_prepare(DB, "SELECT CAST(? AS NUMBER)", -1, "TAIL") > + STMT = sql_prepare("SELECT CAST(? AS NUMBER)", -1, "TAIL") > sql_bind_blob("-static", STMT, 1, blob, 5) > return sql_step(STMT) > end, { > ==================== > > Func.test.lua: > > ==================== > diff --git a/.luacheckrc b/.luacheckrc > index eb709d6a3..7608240c5 100644 > --- a/.luacheckrc > +++ b/.luacheckrc > @@ -132,11 +132,6 @@ files["test/sql-tap/cast.test.lua"] = { > "113", > }, > } > -files["test/sql-tap/func.test.lua"] = { > - ignore = { > - "113", > - }, > -} > files["test/sql-tap/e_expr.test.lua"] = { > ignore = { > "113", > diff --git a/test/sql-tap/func.test.lua b/test/sql-tap/func.test.lua > index d14eef421..a83b15fbc 100755 > --- a/test/sql-tap/func.test.lua > +++ b/test/sql-tap/func.test.lua > @@ -1048,7 +1048,8 @@ test:do_execsql_test( > -- > -- MUST_WORK_TEST testfunc not implemented > if 0 > 0 then > -local DB = sql_connection_pointer("db") > +local DB = nil > +local X = nil > X(525, "X!cmd", [=[["sql_register_test_function",["::DB"],"testfunc"]]=]) > test:do_catchsql_test( > "func-10.1", > @@ -1142,6 +1143,18 @@ end > -- > -- MUST_WORK_TEST test_destructor_count not implemented > if 0 > 0 then > +local X = nil > +-- Legacy from the original code. Must be replaced with analogue > +-- functions from box. > +local sql_prepare = nil > +local sql_bind_text = nil > +local sql_bind_blob = nil > +local sql_column_text = nil > +local sql_step = nil > +local sql_finalize = nil > +local db = nil > +local STMT > + > if X(595, "X!cmd", "[\"expr\",\"[db eval {PRAGMA encoding}]==\\\"UTF-8\\\"\"]") > then > test:do_execsql_test( > @@ -1300,10 +1313,9 @@ test:do_execsql_test( > test:do_test( > "func-13.7", > function() > - local DB, sql, STMT, res > - DB = sql_connection_pointer("db") > + local sql, STMT, res > sql = "SELECT test_auxdata( ? , a ) FROM t4;" > - STMT = sql_prepare(DB, sql, -1, "TAIL") > + STMT = sql_prepare(sql, -1, "TAIL") > sql_bind_text(STMT, 1, "hello\0", -1) > res = { } > while X(690, "X!cmd", [=[["expr"," \"sql_ROW\"==[sql_step $STMT] "]]=]) > @@ -1455,7 +1467,7 @@ test:do_test( > test:execsql([[ > CREATE TABLE tbl2(id integer primary key, a INT, b INT); > ]]) > - local STMT = sql_prepare(DB, "INSERT INTO tbl2 VALUES(1, ?, ?)", -1, "TAIL") > + local STMT = sql_prepare("INSERT INTO tbl2 VALUES(1, ?, ?)", -1, "TAIL") > sql_bind_blob(STMT, 1, "abc", 3) > sql_step(STMT) > sql_finalize(STMT) > @@ -2439,6 +2451,7 @@ test:do_execsql_test( > -- > -- MUST_WORK_TEST > if 0>0 then > +local X = nil > test:do_execsql_test( > "func-25.1", > [[ > @@ -2470,7 +2483,7 @@ test:do_test( > "func-26.2", > function() > local a = "" > - for _ in X(0, "X!for", [=[["set i 1","$i<=$::sql_MAX_FUNCTION_ARG","incr i"]]=]) do > + for i in X(0, "X!for", [=[["set i 1","$i<=$::sql_MAX_FUNCTION_ARG","incr i"]]=]) do > table.insert(a,i) > end > return test:execsql(string.format([[ > @@ -2486,7 +2499,7 @@ test:do_test( > "func-26.3", > function() > local a = "" > - for _ in X(0, "X!for", [=[["set i 1","$i<=$::sql_MAX_FUNCTION_ARG+1","incr i"]]=]) do > + for i in X(0, "X!for", [=[["set i 1","$i<=$::sql_MAX_FUNCTION_ARG+1","incr i"]]=]) do > table.insert(a,i) > end > return test:catchsql(string.format([[ > @@ -2502,7 +2515,7 @@ test:do_test( > "func-26.4", > function() > local a = "" > - for _ in X(0, "X!for", [=[["set i 1","$i<=$::sql_MAX_FUNCTION_ARG-1","incr i"]]=]) do > + for i in X(0, "X!for", [=[["set i 1","$i<=$::sql_MAX_FUNCTION_ARG-1","incr i"]]=]) do > table.insert(a,i) > end > return test:catchsql(string.format([[ > ==================== > > I am sure the other files also can be properly fixed, with stubs > and comments for legacy old functions, and with normal fixes for > the things like in the last lines of the diff above, where it was > a real bug - loop variable was not defined. Your patches with small modification applied. Diff is huge, so I won't post it here but it is in a branch and force pushed. > >> diff --git a/test/sql-tap/badutf1.test.lua b/test/sql-tap/badutf1.test.lua >> index 654629bf7..b7fa8ce0b 100755 >> --- a/test/sql-tap/badutf1.test.lua >> +++ b/test/sql-tap/badutf1.test.lua >> @@ -93,8 +93,12 @@ test:do_test( >> }) >> >> -- commented as it uses utf16 >> -if 0>0 then >> -sql("db2", "") >> +-- testcases are broken >> +-- https://github.com/tarantool/tarantool/issues/5743 >> +local is_gh_5743_closed = false >> +if is_gh_5743_closed then >> +sql("db2", "") -- luacheck: ignore sql >> +-- luacheck: push ignore sql_exec > 2. Or you can use 'local sql_exec = nil', and won't need to > write 'pop'. For me it's not make sense. Replaced push/pop suppression with variable definition. > > The same to the other places, where you try to ignore the same > unknown variable again and again. However I don't insist on > hacks vs luacheck comments. > >> test:do_test( >> "badutf-1.10", >> function() >> @@ -206,7 +210,7 @@ test:do_test( >> -- >> }) >> end >> - >> +-- luacheck: pop >> > diff --git a/test/sql-tap/view.test.lua b/test/sql-tap/view.test.lua >> index 2f1af29b0..67f461132 100755 >> --- a/test/sql-tap/view.test.lua >> +++ b/test/sql-tap/view.test.lua >> @@ -1,6 +1,6 @@ >> #!/usr/bin/env tarantool >> local test = require("sqltester") >> -test:plan(78) >> +test:plan(83) >> >> --!./tcltestrunner.lua >> -- 2002 February 26 >> @@ -501,21 +501,18 @@ test:do_execsql_test( >> }) >> >> -- MUST_WORK_TEST > 3. Why did you keep MUST_WORK_TEST, if it passes now? > The same in other places below. Just missed it, thanks. --- a/test/sql-tap/view.test.lua +++ b/test/sql-tap/view.test.lua @@ -500,7 +500,6 @@ test:do_execsql_test(          --      }) --- MUST_WORK_TEST  test:do_test( "view-7.2", function() @@ -527,7 +526,6 @@ test:do_execsql_test(          -- }) --- MUST_WORK_TEST  test:do_test( "view-7.4", function() @@ -554,7 +552,6 @@ test:do_execsql_test(          -- }) --- MUST_WORK_TEST  test:do_test(      "view-7.6", function() @@ -578,7 +575,6 @@ test:do_execsql_test(          -- }) --- MUST_WORK_TEST  test:do_test( "view-8.2", function() @@ -591,7 +587,6 @@ test:do_test(          --      }) --- MUST_WORK_TEST problem with column names  test:do_execsql_test(      "view-8.3",      [[ @@ -615,7 +610,6 @@ test:do_execsql_test(          --      }) --- MUST_WORK_TEST  test:do_execsql_test(      "view-8.5",      [[ @@ -626,7 +620,6 @@ test:do_execsql_test(          --      }) --- MUST_WORK_TEST  test:do_execsql_test(      "view-8.6",      [[ @@ -637,7 +630,6 @@ test:do_execsql_test(          --      }) --- MUST_WORK_TEST  test:do_execsql_test(      "view-8.7",      [[ @@ -669,7 +661,6 @@ test:do_execsql_test(          --      }) --- MUST_WORK_TEST order by  test:do_execsql_test(      "view-9.2",      [[ @@ -680,7 +671,6 @@ test:do_execsql_test(          --      }) --- MUST_WORK_TEST order by  test:do_execsql_test(      "view-9.3",      [[ @@ -693,7 +683,6 @@ test:do_execsql_test(          --      }) --- MUST_WORK_TEST order by  test:do_execsql_test( > >> -if (0 > 0) >> - then >> - test:do_test( >> - "view-7.2", >> - function() >> - return test:execsql [[ >> - SELECT * FROM test; >> - ]] >> - end, { >> - -- >> - 1, 2, 3 >> - -- >> - }) >> +test:do_test( >> + "view-7.2", >> + function() >> + return test:execsql [[ >> + SELECT * FROM test; >> + ]] >> + end, { >> + -- >> + 1, 2, 3 >> + -- >> + }) >> >> -end >> test:do_execsql_test( >> "view-7.3", >> [[ >> @@ -531,21 +528,18 @@ test:do_execsql_test( >> }) >> >> -- MUST_WORK_TEST >> -if (0 > 0) >> - then >> - test:do_test( >> - "view-7.4", >> - function() >> - return test:execsql [[ >> - SELECT * FROM test; >> - ]] >> - end, { >> - -- >> - 1, 2, 3 >> - -- >> - }) >> +test:do_test( >> + "view-7.4", >> + function() >> + return test:execsql [[ >> + SELECT * FROM test; >> + ]] >> + end, { >> + -- >> + 1, 2, 3 >> + -- >> + }) >> >> -end >> test:do_execsql_test( >> "view-7.5", >> [[ >> @@ -561,21 +555,18 @@ test:do_execsql_test( >> }) >> >> -- MUST_WORK_TEST >> -if (0 > 0) >> - then >> - test:do_test( >> - "view-7.6", >> - function() >> - return test:execsql [[ >> - SELECT * FROM test; >> - ]] >> - end, { >> - -- >> - 1, 2, 3 >> - -- >> - }) >> +test:do_test( >> + "view-7.6", >> + function() >> + return test:execsql [[ >> + SELECT * FROM test; >> + ]] >> + end, { >> + -- >> + 1, 2, 3 >> + -- >> + }) >> >> -end >> test:do_execsql_test( >> "view-8.1", >> [[ >> @@ -588,33 +579,29 @@ test:do_execsql_test( >> }) >> >> -- MUST_WORK_TEST >> -if (0 > 0) >> - then >> - test:do_test( >> - "view-8.2", >> - function() >> - return test:execsql [[ >> - SELECT * FROM v6 ORDER BY xyz; >> - ]] >> - end, { >> - -- >> - 7, 2, 13, 5, 19, 8, 27, 12 >> - -- >> - }) >> - >> - -- MUST_WORK_TEST problem with column names >> - test:do_execsql_test( >> - "view-8.3", >> - [[ >> - CREATE VIEW v7(a) AS SELECT pqr+xyz FROM v6; >> - SELECT * FROM v7 ORDER BY a; >> - ]], { >> - -- >> - 9, 18, 27, 39 >> - -- >> - }) >> +test:do_test( >> + "view-8.2", >> + function() >> + return test:execsql [[ >> + SELECT * FROM v6 ORDER BY xyz; >> + ]] >> + end, { >> + -- >> + 7, 2, 13, 5, 19, 8, 27, 12 >> + -- >> + }) >> >> -end >> +-- MUST_WORK_TEST problem with column names >> +test:do_execsql_test( >> + "view-8.3", >> + [[ >> + CREATE VIEW v7(a) AS SELECT pqr+xyz FROM v6; >> + SELECT * FROM v7 ORDER BY a; >> + ]], { >> + -- >> + 9, 18, 27, 39 >> + -- >> + }) >> >> test:do_execsql_test( >> "view-8.4",