Skip to content

Commit

Permalink
test: fix luacheck warnings in test/sql-tap
Browse files Browse the repository at this point in the history
Closes #5464

Reviewed-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Reviewed-by: Igor Munkin <imun@tarantool.org>

Co-authored-by: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Co-authored-by: Igor Munkin <imun@tarantool.org>
  • Loading branch information
3 people committed Jan 13, 2021
1 parent 56016d2 commit ea6dcfb
Show file tree
Hide file tree
Showing 39 changed files with 85 additions and 112 deletions.
18 changes: 9 additions & 9 deletions test/sql-tap/analyze9.test.lua
Expand Up @@ -244,7 +244,7 @@ test:do_execsql_test(
local function insert_filler_rows_n(iStart, nCopy, nVal)
for i = 0, nVal-1 do
local iVal = iStart+i
for j = 0, nCopy-1 do
for _ = 0, nCopy-1 do
box.execute(string.format("INSERT INTO t1 VALUES (null, %s, %s, '%s')", iVal, iVal, iVal))
end
end
Expand Down Expand Up @@ -615,7 +615,7 @@ test:do_execsql_test(
test:do_test(
"10.1.2",
function()
local a = 0
local a
for i = 1, 100 do
if i > 90 then
a = i
Expand Down Expand Up @@ -663,7 +663,7 @@ test:do_execsql_test(
test:do_test(
"10.2.2",
function()
local a = 0
local a
for i = 1, 100 do
if i > 90 then
a = i
Expand Down Expand Up @@ -717,7 +717,7 @@ test:do_execsql_test(
test:do_test(
11.1,
function()
local a = 0
local a
for i = 0, 100 do
if i % 10 == 0 then
a = "\"ABC\""
Expand Down Expand Up @@ -768,7 +768,7 @@ test:do_execsql_test(
test:do_test(
11.5,
function()
local a = 0
local a
for i = 0, 100 do
if i % 10 == 0 then
a = "\"ABC\""
Expand Down Expand Up @@ -829,7 +829,7 @@ test:do_execsql_test(
test:do_test(
12.1,
function()
local a = 0
local a
for i = 0, 100 do
if i % 10 == 0 then
a = "\"ABC\""
Expand Down Expand Up @@ -880,7 +880,7 @@ test:do_execsql_test(
test:do_test(
12.5,
function()
local a = 0
local a
for i = 0, 100 do
if i % 10 == 0 then
a = "\"ABC\""
Expand Down Expand Up @@ -937,7 +937,7 @@ test:do_test(
test:execsql("CREATE TABLE t1(id INTEGER PRIMARY KEY AUTOINCREMENT, a TEXT, b INT, c INT, d INT);")
test:execsql("CREATE INDEX i1 ON t1(a);")
test:execsql("CREATE INDEX i2 ON t1(b, c);")
local a = 0
local a
for i = 0, 100 do
if i % 2 == 1 then
a = "\"abc\""
Expand Down Expand Up @@ -1167,7 +1167,7 @@ test:do_test(
INSERT INTO t1 SELECT null, 2*a,2*b,2*c,d FROM t1;
INSERT INTO t1 SELECT null, 2*a,2*b,2*c,d FROM t1;
]])
local b = 0
local b
for i = 0, 31 do
if (i < 8) then
b = 0
Expand Down
4 changes: 2 additions & 2 deletions test/sql-tap/between.test.lua
Expand Up @@ -61,11 +61,11 @@ local function queryplan(sql)
table.insert(data,x)
local eqp = box.execute("EXPLAIN QUERY PLAN "..sql.."").rows
-- puts eqp=$eqp
for i, val in ipairs(eqp) do
for _, val in ipairs(eqp) do
--local a = val[1]
--local b = val[2]
--local c = val[3]
local x = val[4]
x = val[4]
local tab, idx = string.match(x, "TABLE (%w+) USING.* INDEX (%w+)")

if tab then
Expand Down
3 changes: 2 additions & 1 deletion test/sql-tap/date.test.lua
Expand Up @@ -29,7 +29,8 @@ test:plan(0)

-- Disabled until #3694 is resolved.
--
if false then
local enable_broken_tests = false
if enable_broken_tests then
local function datetest(tnum, expr, result)
test:do_test(
"date-"..tnum,
Expand Down
11 changes: 6 additions & 5 deletions test/sql-tap/e_expr.test.lua
Expand Up @@ -1077,7 +1077,7 @@ test:do_execsql_test(
--
-- MUST_WORK_TEST prepared statements
if (0>0) then
local function parameter_test(tn, sql, params, result)
local function parameter_test(tn, sql, params, result) -- luacheck: no unused args
local stmt = sql_prepare_v2("db", sql, -1)
for _ in X(0, "X!foreach", [=[["number name",["params"]]]=]) do
local nm = sql_bind_parameter_name(stmt, number)
Expand Down Expand Up @@ -1264,7 +1264,7 @@ test:do_execsql_test(
test:execsql [[
CREATE TABLE tblname(cname INT PRIMARY KEY);
]]
local function glob(args)
local function glob()
return 1
end

Expand Down Expand Up @@ -2121,7 +2121,7 @@ test:do_execsql_test(
local likeargs = {}
local function likefunc(...)
local args = {...}
for i, v in ipairs(args) do
for _, v in ipairs(args) do
table.insert(likeargs, v)
end
return 1
Expand Down Expand Up @@ -2356,7 +2356,7 @@ end
local regexpargs = {}
local function regexpfunc(...)
local args = {...}
for i, v in ipairs(args) do
for _, v in ipairs(args) do
table.insert(regexpargs, v)
end
return 1
Expand Down Expand Up @@ -2415,7 +2415,7 @@ test:do_test(
local matchargs = { }
local function matchfunc(...)
local args = {...}
for i, v in ipairs(args) do
for _, v in ipairs(args) do
table.insert(matchargs, v)
end
return 1
Expand Down Expand Up @@ -2679,6 +2679,7 @@ if 0>0 then
-- comparisons take place.
--

-- luacheck: ignore (loop is executed at most once)
for _ in X(0, "X!foreach", [=[["a b c",[["list",[["expr","3"]],[["expr","4"]],[["expr","5"]]]]]]=]) do
break
end
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/func.test.lua
Expand Up @@ -1473,7 +1473,7 @@ test:do_test(
test:do_test(
"func-17.1",
function()
local function testfunc1(args)
local function testfunc1()
X(768, "X!cmd", [=[["error","Error %d with %s percents %p"]]=])
end

Expand Down
8 changes: 4 additions & 4 deletions test/sql-tap/gh-2723-concurrency.test.lua
Expand Up @@ -20,7 +20,7 @@ for id = 1, N do
end
)
end
for id = 1, N do
for _ = 1, N do
ch:get()
end

Expand All @@ -46,7 +46,7 @@ for id = 1, N do
end
)
end
for id = 1, N do
for _ = 1, N do
ch:get()
end
test:do_test(
Expand All @@ -64,15 +64,15 @@ box.execute("create index i1 on t1(b);")
for id = 1, N*N do
box.execute(string.format("insert into t1 values(%s, %s, 3)", id, id))
end
for id = 1, N do
for _ = 1, N do
fiber.create(
function ()
box.execute("delete from t1")
ch:put(1)
end
)
end
for id = 1, N do
for _ = 1, N do
ch:get()
end
test:do_test(
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua
Expand Up @@ -12,7 +12,7 @@ test:do_test(
box.execute("insert into test(id, k) values(" .. i .. "," .. i .. ")")
end

for i = 1, 10000 do
for _ = 1, 10000 do
box.execute("SELECT id, k FROM test WHERE k IN (5849, 4986, 4997, 5020, 5044, 4990, 5013, 4983)")
end
end, {
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/gh-3332-tuple-format-leak.test.lua
Expand Up @@ -21,7 +21,7 @@ test:do_test(
test:do_test(
"format-leak",
function()
for i = 1, 100000 do
for _ = 1, 100000 do
box.execute("SELECT id FROM t1 WHERE flags=3 ORDER BY id LIMIT 2");
end
end, {
Expand Down
10 changes: 5 additions & 5 deletions test/sql-tap/gh2127-indentifier-max-length.test.lua
Expand Up @@ -7,7 +7,7 @@ local tt = {}
local table_word = "АААААААААА"

-- Create 30kb table name
for i=1,300 do
for _=1,300 do
table.insert(tt, table_word)
end

Expand All @@ -27,7 +27,7 @@ local vt = {}
local view_word = "BBBBBBBBBB"

-- Create 30kb view name
for i=1, 300 do
for _=1, 300 do
table.insert(vt, view_word)
end

Expand All @@ -45,7 +45,7 @@ local it = {}
local index_word = "ЕЕЕЕЕЕЕЕЕЕ"

-- Create 30kb index name
for i=1, 300 do
for _=1, 300 do
table.insert(it, index_word)
end

Expand All @@ -55,7 +55,7 @@ local field_table = {}
local field_word = 'ДДДДДДДДД'

-- Create 30kb field name
for i=1, 300 do
for _=1, 300 do
table.insert(field_table, field_word)
end

Expand All @@ -75,7 +75,7 @@ test:do_execsql_test(
local trig_table = {}
local trigger_word = "ССССССССС"

for i=1, 300 do
for _=1, 300 do
table.insert(trig_table, trigger_word)
end

Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/identifier-characters.test.lua
Expand Up @@ -65,7 +65,7 @@ local testcases = {
test:execsql("commit")
if ok == false then error(res) end
end,
function (id) end},
function () end},
{"trigger name",
function (id)
test:execsql(string.format([[
Expand Down
4 changes: 1 addition & 3 deletions test/sql-tap/index1.test.lua
Expand Up @@ -106,7 +106,6 @@ test:do_test(
test:do_test(
"index-2.2",
function()
local msg
local v , msg= pcall(function()
test:execsql("CREATE INDEX index1 ON test1(f1, f2, f4, f3)")
end)
Expand Down Expand Up @@ -1011,8 +1010,7 @@ end
test:do_test(
"index-22.1.0",
function()
local format
format = {}
local format = {}
format[1] = { name = 'id', type = 'scalar'}
format[2] = { name = 'f2', type = 'scalar'}
box.schema.create_space('T', {format = format})
Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/join3.test.lua
Expand Up @@ -49,7 +49,7 @@ for N=1, bitmask_size do
end
-- Joins with a comparison
--
local result = {}
result = {}
--for _ in X(0, "X!for", [=[["set N 1","$N<=$bitmask_size","incr N"]]=]) do
for N=1, bitmask_size do
table.insert(result,N)
Expand Down
5 changes: 2 additions & 3 deletions test/sql-tap/lua-tables.test.lua
Expand Up @@ -5,11 +5,10 @@ test:plan(14)
test:do_test(
"lua-tables-prepare-1",
function()
local format, s
format = {}
local format = {}
format[1] = { name = 'id', type = 'scalar'}
format[2] = { name = 'f2', type = 'scalar'}
s = box.schema.create_space('t', {format = format})
local s = box.schema.create_space('t', {format = format})
s:create_index('i', {parts={1, 'scalar'}})

s:replace{1, 4}
Expand Down
5 changes: 2 additions & 3 deletions test/sql-tap/lua/sqltester.lua
Expand Up @@ -176,7 +176,7 @@ local function execsql(self, sql)
end
test.execsql = execsql

local function catchsql(self, sql, expect)
local function catchsql(self, sql)
local r = {pcall(execsql, self, sql) }
if r[1] == true then
r[1] = 0
Expand Down Expand Up @@ -272,7 +272,7 @@ test.catchsql2 = catchsql2
-- that different SQL statements generate exactly the same VDBE code.
local function explain_no_trace(self, sql)
local tr = execsql(self, "EXPLAIN "..sql)
for i=1,8 do
for _=1,8 do
table.remove(tr,1)
end
return tr
Expand Down Expand Up @@ -378,7 +378,6 @@ function test.randstr(Length)
for Loop = 0, 255 do
Chars[Loop+1] = string.char(Loop)
end
local String = table.concat(Chars)
local Result = {}
local Lookup = Chars
local Range = #Lookup
Expand Down
4 changes: 2 additions & 2 deletions test/sql-tap/misc1.test.lua
Expand Up @@ -726,7 +726,7 @@ test:do_execsql_test(
-- MUST_WORK_TEST collate
if 0>0 then
db("collate", "numeric", "numeric_collate")
local function numeric_collate(lhs, rhs)
local function numeric_collate1(lhs, rhs)
if (lhs == rhs)
then
return 0
Expand All @@ -736,7 +736,7 @@ if 0>0 then

-- Mimic the sql 2 collation type TEXT.
db("collate", "text", "text_collate")
local function numeric_collate(lhs, rhs)
local function numeric_collate2()
return X(34, "X!cmd", [=[["string","compare",["lhs"],["rhs"]]]=])
end

Expand Down
2 changes: 1 addition & 1 deletion test/sql-tap/misc5.test.lua
Expand Up @@ -292,7 +292,7 @@ test:do_test(
local sql, tail
sql = "INSERT INTO t1 VALUES("
tail = ""
for i = 0, 199, 1 do
for _ = 0, 199, 1 do
sql = sql .. "(1+"
tail = tail .. ")"
end
Expand Down
6 changes: 3 additions & 3 deletions test/sql-tap/select1.test.lua
@@ -1,6 +1,7 @@
#!/usr/bin/env tarantool
local test = require("sqltester")
test:plan(173)
local enable_broken_tests = false

local function set_full_column_names(value)
box.space._session_settings:update('sql_full_column_names', {
Expand Down Expand Up @@ -1513,8 +1514,7 @@ test:do_execsql_test(
-- TODO: This test is failing because f1 is now being loaded off the
-- disk as a vdbe integer, not a string. Hence the value of f1/(f1-11)
-- changes because of rounding. Disable the test for now.
if false
then
if enable_broken_tests then
test:do_execsql_test(
"select1-8.4",
[[
Expand Down Expand Up @@ -1970,7 +1970,7 @@ test:do_test(
START TRANSACTION;
INSERT INTO abc VALUES(1, 1, 1);
]]
for i = 0,9,1 do
for _ = 0,9,1 do
test:execsql [[
INSERT INTO abc SELECT a+(select max(a) FROM abc), b+(select max(a) FROM abc), c+(select max(a) FROM abc) FROM abc;
]]
Expand Down

0 comments on commit ea6dcfb

Please sign in to comment.