From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 8007C45C304 for ; Wed, 16 Dec 2020 19:01:14 +0300 (MSK) From: sergeyb@tarantool.org Date: Wed, 16 Dec 2020 19:00:00 +0300 Message-Id: <6eefb156be01bb9a6dd6f1a6f51f81ac319bb885.1608127545.git.sergeyb@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v7 1/3] luacheck: fix warnings in test/app-tap List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, lvasiliev@tarantool.org, v.shpilevoy@tarantool.org From: Sergey Bronnikov Part of #5453 Reviewed-by: Vladislav Shpilevoy Reviewed-by: Igor Munkin Co-authored-by: Vladislav Shpilevoy Co-authored-by: Igor Munkin --- .luacheckrc | 9 ++- test/app-tap/cfg.test.lua | 2 +- test/app-tap/clock.test.lua | 4 +- test/app-tap/console.test.lua | 10 ++-- test/app-tap/csv.test.lua | 56 +++++++++---------- test/app-tap/fail_main.test.lua | 4 +- .../gh-4761-json-per-call-options.test.lua | 4 +- test/app-tap/gh-5013-fiber-cancel.test.lua | 2 +- .../gh-5130-panic-on-invalid-log.test.lua | 4 +- test/app-tap/http_client.test.lua | 25 +++------ test/app-tap/iconv.test.lua | 4 +- test/app-tap/init_script.test.lua | 16 +++--- test/app-tap/inspector.test.lua | 5 +- test/app-tap/json.test.lua | 1 - test/app-tap/logger.test.lua | 12 ++-- test/app-tap/lua/serializer_test.lua | 28 +++------- test/app-tap/module_api.test.lua | 13 ++--- test/app-tap/msgpackffi.test.lua | 3 +- test/app-tap/pcall.test.lua | 2 +- test/app-tap/snapshot.test.lua | 15 +++-- test/app-tap/string.test.lua | 30 +++++----- test/app-tap/tap.test.lua | 4 +- test/app-tap/tarantoolctl.test.lua | 46 ++++++--------- test/app-tap/trigger.test.lua | 8 +-- test/app-tap/yaml.test.lua | 14 ++--- test/app-tap/yield-in-gc-finalizer.test.lua | 3 +- 26 files changed, 145 insertions(+), 179 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 29db9eeeb..ae96576ec 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -3,6 +3,8 @@ globals = {"box", "_TARANTOOL", "tonumber64"} ignore = { -- Accessing an undefined field of a global variable . "143/debug", + -- Accessing an undefined field of a global variable . + "143/os", -- Accessing an undefined field of a global variable . "143/string", -- Accessing an undefined field of a global variable . @@ -31,7 +33,6 @@ exclude_files = { -- Third-party source code. "test-run/**/*.lua", "test/app/**/*.lua", - "test/app-tap/**/*.lua", "test/box/**/*.lua", "test/box-py/**/*.lua", "test/box-tap/**/*.lua", @@ -102,3 +103,9 @@ files["src/box/lua/console.lua"] = { "212", } } +files["test/app-tap/lua/require_mod.lua"] = { + globals = {"exports"} +} +files["test/app-tap/string.test.lua"] = { + globals = {"utf8"} +} diff --git a/test/app-tap/cfg.test.lua b/test/app-tap/cfg.test.lua index ba6b735ab..7a94f16a3 100755 --- a/test/app-tap/cfg.test.lua +++ b/test/app-tap/cfg.test.lua @@ -12,7 +12,7 @@ test:plan(11) local nil_uuid = '00000000-0000-0000-0000-000000000000' local ok = pcall(box.cfg, {instance_uuid = nil_uuid}) test:ok(not ok, 'nil instance UUID is not allowed') -ok, err = pcall(box.cfg, {replicaset_uuid = nil_uuid}) +ok = pcall(box.cfg, {replicaset_uuid = nil_uuid}) test:ok(not ok, 'nil replicaset UUID is not allowed') test:is(type(box.ctl), "table", "box.ctl is available before box.cfg") diff --git a/test/app-tap/clock.test.lua b/test/app-tap/clock.test.lua index fd1c4f272..d1ea4f0a8 100755 --- a/test/app-tap/clock.test.lua +++ b/test/app-tap/clock.test.lua @@ -1,7 +1,7 @@ #!/usr/bin/env tarantool -clock = require("clock") -test = require("tap").test("csv") +local clock = require("clock") +local test = require("tap").test("csv") test:plan(10) test:ok(clock.realtime() > 0, "realtime") test:ok(clock.thread() > 0, "thread") diff --git a/test/app-tap/console.test.lua b/test/app-tap/console.test.lua index d5452aa17..d397d4a37 100755 --- a/test/app-tap/console.test.lua +++ b/test/app-tap/console.test.lua @@ -5,9 +5,9 @@ local console = require('console') local socket = require('socket') local yaml = require('yaml') local fiber = require('fiber') -local ffi = require('ffi') local log = require('log') local fio = require('fio') -- Suppress console log messages log.level(4) @@ -19,7 +19,7 @@ os.remove(IPROTO_SOCKET) -- local EOL = "\n...\n" -test = tap.test("console") +local test = tap.test("console") test:plan(78) @@ -60,6 +60,7 @@ client:write('\\set output lua\n') client:read(";") - long_func_f = nil + local long_func_f = nil +-- luacheck: globals long_func (is called via client socket) function long_func() long_func_f = fiber.self() box.session.push('push') @@ -87,12 +88,9 @@ test:is(#client:read(EOL) > 0, true, "_G") client:write("require('fiber').id()\n") local fid1 = yaml.decode(client:read(EOL))[1] local state = fiber.find(fid1).storage.console -local server_info = state.client:peer() local client_info = state.client:name() test:is(client_info.host, client_info.host, "state.socker:peer().host") test:is(client_info.port, client_info.port, "state.socker:peer().port") -server_info = nil -client_info = nil -- Check console.delimiter() client:write("require('console').delimiter(';')\n") @@ -225,7 +223,7 @@ box.cfg{listen = ''} os.remove(IPROTO_SOCKET) local s = console.listen('127.0.0.1:0') -addr = s:name() +local addr = s:name() test:is(addr.family, 'AF_INET', 'console.listen uri support') test:is(addr.host, '127.0.0.1', 'console.listen uri support') test:isnt(addr.port, 0, 'console.listen uri support') diff --git a/test/app-tap/csv.test.lua b/test/app-tap/csv.test.lua index a7f17b1ea..eb180f95d 100755 --- a/test/app-tap/csv.test.lua +++ b/test/app-tap/csv.test.lua @@ -2,9 +2,9 @@ local function table2str(t) local res = "" - for k, line in pairs(t) do + for _, line in pairs(t) do local s = "" - for k2, field in pairs(line) do + for _, field in pairs(line) do s = s .. '|' .. field .. '|\t' end res = res .. s .. '\n' @@ -12,9 +12,9 @@ local function table2str(t) return res end -local function myread(self, bytes) +local function myread(self, bytes) self.i = self.i + bytes - return self.v:sub(self.i - bytes + 1, self.i) + return self.v:sub(self.i - bytes + 1, self.i) end local csv = require('csv') local fio = require('fio') @@ -27,18 +27,18 @@ local test4_ans = '|123|\t|5|\t|92|\t|0|\t|0|\t\n|1|\t|12 34|\t|56|\t' .. local test5_ans = "|1|\t\n|23|\t|456|\t|abcac|\t|'multiword field 4'|\t\n" .. "|none|\t|none|\t|0|\t\n||\t||\t||\t\n|aba|\t|adda|\t|f" .. "3|\t|0|\t\n|local res = internal.pwrite(self.fh|\t|dat" .. - "a|\t|len|\t|offset)|\t\n|iflag = bit.bor(iflag|\t|fio." .. + "a|\t|len|\t|offset)|\t\n|iflag = bit.bor(iflag|\t|fio." .. "c.flag[ flag ])|\t\n||\t||\t||\t\n" local test6_ans = "|23|\t|456|\t|abcac|\t|'multiword field 4'|\t\n|none|" .. - "\t|none|\t|0|\t\n||\t||\t||\t\n|aba|\t|adda|\t|f3|\t|" .. + "\t|none|\t|0|\t\n||\t||\t||\t\n|aba|\t|adda|\t|f3|\t|" .. "0|\t\n|local res = internal.pwrite(self.fh|\t|data|\t" .. "|len|\t|offset)|\t\n|iflag = bit.bor(iflag|\t|fio.c.f" .. "lag[ flag ])|\t\n||\t||\t||\t\n" -test = tap.test("csv") +local test = tap.test("csv") test:plan(12) -readable = {} +local readable = {} readable.read = myread readable.v = "a,b\n1,\"ha\n\"\"ha\"\"\nha\"\n3,4\n" readable.i = 0 @@ -52,17 +52,17 @@ readable.v = ", \r\nkp\"\"v" readable.i = 0 test:is(table2str(csv.load(readable, {chunk_size = 3})), test3_ans, "obj test3") -tmpdir = fio.tempdir() -file1 = fio.pathjoin(tmpdir, 'file.1') -file2 = fio.pathjoin(tmpdir, 'file.2') -file3 = fio.pathjoin(tmpdir, 'file.3') -file4 = fio.pathjoin(tmpdir, 'file.4') +local tmpdir = fio.tempdir() +local file1 = fio.pathjoin(tmpdir, 'file.1') +local file2 = fio.pathjoin(tmpdir, 'file.2') +local file3 = fio.pathjoin(tmpdir, 'file.3') +local file4 = fio.pathjoin(tmpdir, 'file.4') local f = fio.open(file1, { 'O_WRONLY', 'O_TRUNC', 'O_CREAT' }, tonumber('0777', 8)) f:write("123 , 5 , 92 , 0, 0\n" .. "1, 12 34, 56, \"quote , \", 66\nok") f:close() -f = fio.open(file1, {'O_RDONLY'}) +f = fio.open(file1, {'O_RDONLY'}) test:is(table2str(csv.load(f, {chunk_size = 10})), test4_ans, "fio test1") f:close() @@ -77,31 +77,31 @@ f:write("1\n23,456,abcac,\'multiword field 4\'\n" .. ",," ) f:close() -f = fio.open(file2, {'O_RDONLY'}) +f = fio.open(file2, {'O_RDONLY'}) --symbol by symbol reading -test:is(table2str(csv.load(f, {chunk_size = 1})), test5_ans, "fio test2") +test:is(table2str(csv.load(f, {chunk_size = 1})), test5_ans, "fio test2") f:close() -f = fio.open(file2, {'O_RDONLY'}) -opts = {chunk_size = 7, skip_head_lines = 1} +f = fio.open(file2, {'O_RDONLY'}) +local opts = {chunk_size = 7, skip_head_lines = 1} --7 symbols per chunk -test:is(table2str(csv.load(f, opts)), test6_ans, "fio test3") +test:is(table2str(csv.load(f, opts)), test6_ans, "fio test3") f:close() -t = { - {'quote" d', ',and, comma', 'both " of " t,h,e,m'}, - {'"""', ',","'}, - {'mul\nti\nli\r\nne\n\n', 'field'}, - {""}, - {'"'}, - {"\n"} +local t = { + {'quote" d', ',and, comma', 'both " of " t,h,e,m'}, + {'"""', ',","'}, + {'mul\nti\nli\r\nne\n\n', 'field'}, + {""}, + {'"'}, + {"\n"} } f = require("fio").open(file3, { "O_WRONLY", "O_TRUNC" , "O_CREAT"}, 0x1FF) csv.dump(t, {}, f) f:close() -f = fio.open(file3, {'O_RDONLY'}) -t2 = csv.load(f, {chunk_size = 5}) +f = fio.open(file3, {'O_RDONLY'}) +local t2 = csv.load(f, {chunk_size = 5}) f:close() test:is(table2str(t), table2str(t2), "test roundtrip") diff --git a/test/app-tap/fail_main.test.lua b/test/app-tap/fail_main.test.lua index f8c45bf6f..cf6b1d8ed 100755 --- a/test/app-tap/fail_main.test.lua +++ b/test/app-tap/fail_main.test.lua @@ -7,7 +7,7 @@ local tarantool_bin = arg[-1] test:plan(1) -function run_script(code) +local function run_script(code) local dir = fio.tempdir() local script_path = fio.pathjoin(dir, 'script.lua') local script = fio.open(script_path, {'O_CREAT', 'O_WRONLY', 'O_APPEND'}, @@ -30,7 +30,7 @@ end -- gh-4382: an error in main script should be handled gracefully, -- with proper logging. -- -local code, output = run_script("error('Error in the main script')") +local _, output = run_script("error('Error in the main script')") test:ok(output:match("fatal error, exiting the event loop"), "main script error is handled gracefully") diff --git a/test/app-tap/gh-4761-json-per-call-options.test.lua b/test/app-tap/gh-4761-json-per-call-options.test.lua index 1fb24744e..c6b31ba61 100755 --- a/test/app-tap/gh-4761-json-per-call-options.test.lua +++ b/test/app-tap/gh-4761-json-per-call-options.test.lua @@ -13,7 +13,7 @@ local res = tap.test('gh-4761-json-per-call-options', function(test) test:plan(2) -- Preparation code: call :decode() with a custom option. - local ok, err = pcall(json.decode, '{"foo": {"bar": 1}}', + local ok = pcall(json.decode, '{"foo": {"bar": 1}}', {decode_max_depth = 1}) assert(not ok, 'expect "too many nested data structures" error') @@ -25,7 +25,7 @@ local res = tap.test('gh-4761-json-per-call-options', function(test) -- Same check for json.encode. local nan = 1/0 - local ok, err = pcall(json.encode, {a = nan}, + local ok = pcall(json.encode, {a = nan}, {encode_invalid_numbers = false}) assert(not ok, 'expected "number must not be NaN or Inf" error') local exp_res = '{"a":inf}' diff --git a/test/app-tap/gh-5013-fiber-cancel.test.lua b/test/app-tap/gh-5013-fiber-cancel.test.lua index 91c6775dc..7efb6ab5d 100755 --- a/test/app-tap/gh-5013-fiber-cancel.test.lua +++ b/test/app-tap/gh-5013-fiber-cancel.test.lua @@ -8,7 +8,7 @@ test:plan(2) local result = {} -function test_f() +local function test_f() local cond = fiber.cond() local res, err = pcall(cond.wait, cond) result.res = res diff --git a/test/app-tap/gh-5130-panic-on-invalid-log.test.lua b/test/app-tap/gh-5130-panic-on-invalid-log.test.lua index 24af8139c..7ebff1425 100755 --- a/test/app-tap/gh-5130-panic-on-invalid-log.test.lua +++ b/test/app-tap/gh-5130-panic-on-invalid-log.test.lua @@ -9,11 +9,11 @@ test:plan(3) -- -- Invalid log. No panic, just error -_, err = pcall(log.cfg, {log=' :invalid'}) +local _, err = pcall(log.cfg, {log=' :invalid'}) test:like(err, "expecting a file name or a prefix") -- Empty string - default log (to be compatible with box.cfg) -ok = pcall(log.cfg, {log=''}) +local ok = pcall(log.cfg, {log=''}) test:ok(ok) -- Dynamic reconfiguration - error, no info about invalid logger type diff --git a/test/app-tap/http_client.test.lua b/test/app-tap/http_client.test.lua index b85b605cf..093af8fe4 100755 --- a/test/app-tap/http_client.test.lua +++ b/test/app-tap/http_client.test.lua @@ -42,7 +42,7 @@ local function start_server(test, sock_family, sock_addr) test:is(server:read("*l"), "heartbeat", "server started") test:diag("trying to connect to %s", url) local r - for i=1,10 do + for _=1,10 do r = client.get(url, merge(opts, {timeout = 0.01})) if r.status == 200 then break @@ -164,7 +164,7 @@ local function test_cancel_and_errinj(test, url, opts) local errinj = box.error.injection errinj.set('ERRINJ_HTTP_RESPONSE_ADD_WAIT', true) local topts = merge(opts, {timeout = 1200}) - f = fiber.create(func, topts) + fiber.create(func, topts) r = ch:get() test:is(r.status, 200, "No hangs in errinj") errinj.set('ERRINJ_HTTP_RESPONSE_ADD_WAIT', false) @@ -180,7 +180,6 @@ local function test_post_and_get(test, url, opts) local my_body = { key = "value" } local json_body = json.encode(my_body) local responses = {} - local data = {a = 'b'} headers['Content-Type'] = 'application/json' local fibers = 7 local ch = fiber.channel(fibers) @@ -213,7 +212,7 @@ local function test_post_and_get(test, url, opts) responses.absent_get = http:get(url .. 'absent', opts) ch:put(1) end) - for i=1,fibers do + for _=1,fibers do ch:get() end local r = responses.good_get @@ -270,7 +269,6 @@ local function test_errors(test) test:ok(not status and string.find(json.encode(err), "Unsupported protocol"), "POST: exception on bad protocol") - local r = http:get("http://do_not_exist_8ffad33e0cb01e6a01a03d00089e71e5b2b7e9930dfcba.ru") end -- gh-3679 Check that opts.headers values can be strings only. @@ -355,7 +353,7 @@ local function test_request_headers(test, url, opts) local http = client:new() for _, case in ipairs(cases) do - local opts = merge(table.copy(opts), case.opts) + opts = merge(table.copy(opts), case.opts) local ok, err = pcall(http.get, http, url, opts) if case.postrequest_check ~= nil then case.postrequest_check(opts) @@ -425,7 +423,6 @@ local function test_special_methods(test, url, opts) local responses = {} local fibers = 7 local ch = fiber.channel(fibers) - local _ fiber.create(function() responses.patch_data = http:patch(url, "{\"key\":\"val\"}", opts) ch:put(1) @@ -454,7 +451,7 @@ local function test_special_methods(test, url, opts) responses.custom_data = http:request("CUSTOM", url, nil, opts) ch:put(1) end) - for i = 1, fibers do + for _ = 1, fibers do ch:get() end @@ -483,10 +480,6 @@ end local function test_concurrent(test, url, opts) test:plan(3) - local http = client.new() - local headers = { my_header = "1", my_header2 = "2" } - local my_body = { key = "value" } - local json_body = json.encode(my_body) local num_test = 10 local num_load = 10 local curls = { } @@ -497,7 +490,7 @@ local function test_concurrent(test, url, opts) headers["My-header" .. i] = "my-value" end - for i = 1, num_test do + for _ = 1, num_test do table.insert(curls, { url = url, http = client.new(), @@ -515,7 +508,7 @@ local function test_concurrent(test, url, opts) -- Creating concurrent clients for i=1,num_test do local obj = curls[i] - for j=1,num_load do + for _=1,num_load do fiber.create(function() local r = obj.http:post(obj.url, obj.body, merge(opts, { headers = obj.headers, @@ -540,13 +533,11 @@ local function test_concurrent(test, url, opts) end local ok_sockets_added = true local ok_active = true - local ok_timeout = true local ok_req = true -- Join test local rest = num_test while true do - local ticks = 0 for i = 1, num_load do local obj = curls[i] -- checking that stats in concurrent are ok @@ -582,7 +573,7 @@ local function test_concurrent(test, url, opts) test:ok(ok_active, "no active requests") end -function run_tests(test, sock_family, sock_addr) +local function run_tests(test, sock_family, sock_addr) test:plan(11) local server, url, opts = start_server(test, sock_family, sock_addr) test:test("http.client", test_http_client, url, opts) diff --git a/test/app-tap/iconv.test.lua b/test/app-tap/iconv.test.lua index 6f6a04b14..eeadd6673 100755 --- a/test/app-tap/iconv.test.lua +++ b/test/app-tap/iconv.test.lua @@ -3,7 +3,7 @@ local tap = require('tap') local iconv = require('iconv') -test = tap.test("iconv") +local test = tap.test("iconv") test:plan(11) local simple_str = 'ascii string' @@ -34,7 +34,7 @@ test:is(c8_1251(c1251_16(c16_16be(c16be_8(cyrillic_str)))), cyrillic_str, 'complex multi-format conversion') -- test huge string -huge_str = string.rep(cyrillic_str, 50) +local huge_str = string.rep(cyrillic_str, 50) test:is(c16be_8(c8_16be(huge_str)), huge_str, "huge string") diff --git a/test/app-tap/init_script.test.lua b/test/app-tap/init_script.test.lua index e6f298f93..56de6d44e 100755 --- a/test/app-tap/init_script.test.lua +++ b/test/app-tap/init_script.test.lua @@ -9,14 +9,14 @@ box.cfg{ log="tarantool.log" } -yaml = require('yaml') -fiber = require('fiber') +local yaml = require('yaml') +local fiber = require('fiber') if box.space.tweedledum ~= nil then box.space.space1:drop() end -space = box.schema.space.create('tweedledum') +local space = box.schema.space.create('tweedledum') space:create_index('primary', { type = 'hash' }) print[[ @@ -24,7 +24,7 @@ print[[ -- Access to box.cfg from init script -- ]] -t = {} +local t = {} for k,v in pairs(box.cfg) do if k == 'listen' then @@ -36,7 +36,7 @@ for k,v in pairs(box.cfg) do end table.sort(t) print('box.cfg') -for k,v in pairs(t) do print(v) end +for _,v in pairs(t) do print(v) end -- -- Insert tests -- @@ -44,7 +44,7 @@ local function do_insert() space:insert{1, 2, 4, 8} end -fiber1 = fiber.create(do_insert) +fiber.create(do_insert) print[[ -- @@ -71,12 +71,12 @@ print[[ -- Check that require function(math.floor) reachable in the init script -- ]] -floor = require("math").floor +local floor = require("math").floor print(floor(0.5)) print(floor(0.9)) print(floor(1.1)) -mod = require('require_mod') +local mod = require('require_mod') print(mod.test(10, 15)) -- -- A test case for https://github.com/tarantool/tarantool/issues/53 diff --git a/test/app-tap/inspector.test.lua b/test/app-tap/inspector.test.lua index ed10020a2..cda3eda2c 100755 --- a/test/app-tap/inspector.test.lua +++ b/test/app-tap/inspector.test.lua @@ -1,9 +1,6 @@ #!/usr/bin/env tarantool -local socket = require('socket') - -test_run = require('test_run') -inspector = test_run.new() +local inspector = require('test_run').new() print('create instance') print(inspector:cmd("create server replica with rpl_master=default, script='box/box.lua'\n")) diff --git a/test/app-tap/json.test.lua b/test/app-tap/json.test.lua index 70e9f6cf7..be60e45c9 100755 --- a/test/app-tap/json.test.lua +++ b/test/app-tap/json.test.lua @@ -2,7 +2,6 @@ package.path = "lua/?.lua;"..package.path -local ffi = require('ffi') local tap = require('tap') local common = require('serializer_test') diff --git a/test/app-tap/logger.test.lua b/test/app-tap/logger.test.lua index a448ba87a..890d3f5c3 100755 --- a/test/app-tap/logger.test.lua +++ b/test/app-tap/logger.test.lua @@ -7,7 +7,7 @@ test:plan(64) -- gh-5121: Allow to use 'json' output before box.cfg() -- local log = require('log') -_, err = pcall(log.log_format, 'json') +local _, err = pcall(log.log_format, 'json') test:ok(err == nil) -- We're not allowed to use json with syslog though. @@ -141,7 +141,7 @@ end log.info(message) local line = file:read() test:is(line:sub(-message:len()), message, "message") -s, err = pcall(json.decode, line) +local s = pcall(json.decode, line) test:ok(not s, "plain") -- -- gh-700: Crash on calling log.info() with formatting characters @@ -160,7 +160,7 @@ test:is(file:read():match('I>%s+(.*)'), '{"key":"value"}', "table is handled as log.info({message="value"}) test:is(file:read():match('I>%s+(.*)'), '{"message":"value"}', "table is handled as json") -function help() log.info("gh-2340: %s %s", 'help') end +local function help() log.info("gh-2340: %s %s", 'help') end xpcall(help, function(err) test:ok(err:match("bad argument #3"), "found error string") @@ -171,14 +171,14 @@ file:close() test:ok(log.pid() >= 0, "pid()") --- logger uses 'debug', try to set it to nil +-- luacheck: ignore (logger uses 'debug', try to set it to nil) debug = nil log.info("debug is nil") debug = require('debug') test:ok(log.info(true) == nil, 'check tarantool crash (gh-2516)') -s, err = pcall(box.cfg, {log_format='json', log="syslog:identity:tarantool"}) +s = pcall(box.cfg, {log_format='json', log="syslog:identity:tarantool"}) test:ok(not s, "check json not in syslog") box.cfg{log=filename, @@ -235,7 +235,7 @@ file = fio.open(filename) while file == nil do file = fio.open(filename) fiber.sleep(0.0001) end line = file:read() while line == nil or line == "" do line = file:read() fiber.sleep(0.0001) end -index = line:find('\n') +local index = line:find('\n') line = line:sub(1, index) message = json.decode(line) test:is(message.message, "log file has been reopened", "check message after log.rotate()") diff --git a/test/app-tap/lua/serializer_test.lua b/test/app-tap/lua/serializer_test.lua index 2a668f898..cea78f7ed 100644 --- a/test/app-tap/lua/serializer_test.lua +++ b/test/app-tap/lua/serializer_test.lua @@ -2,7 +2,7 @@ local ffi = require('ffi') local function rt(test, s, x, t) local buf1 = s.encode(x) - local x1, offset1 = s.decode(buf1) + local x1 = s.decode(buf1) local xstr if type(x) == "table" then xstr = "table" @@ -189,8 +189,6 @@ local function test_double(test, s) ss.cfg{decode_invalid_numbers = true} rt(test, s, nan) rt(test, s, inf) - - ss = nil end local function test_decimal(test, s) @@ -258,14 +256,14 @@ local function test_table(test, s, is_array, is_map) test:ok(is_map(s.encode({k1 = 'v1', k2 = 'v2', k3 = 'v3'})), "map is map") -- utf-8 pairs - rt(test, s, {Метапеременная = { 'Метазначение' }}) + rt(test, s, {['Метапеременная'] = { 'Метазначение' }}) rt(test, s, {test = { 'Результат' }}) local arr = setmetatable({1, 2, 3, k1 = 'v1', k2 = 'v2', 4, 5}, { __serialize = 'seq'}) local map = setmetatable({1, 2, 3, 4, 5}, { __serialize = 'map'}) local obj = setmetatable({}, { - __serialize = function(x) return 'serialize' end + __serialize = function() return 'serialize' end }) -- __serialize on encode @@ -306,8 +304,6 @@ local function test_table(test, s, is_array, is_map) -- string (from __serialize hook) test:is(ss.decode(ss.encode(obj)), "serialize", "object load __serialize") - ss = nil - -- -- decode_save_metatables -- @@ -325,14 +321,12 @@ local function test_table(test, s, is_array, is_map) "array save __serialize") test:is(getmetatable(ss.decode(ss.encode(map))).__serialize, "map", "map save __serialize") - ss = nil - -- -- encode_sparse_convert / encode_sparse_ratio / encode_sparse_safe -- - local ss = s.new() + ss = s.new() ss.cfg{encode_sparse_ratio = 2, encode_sparse_safe = 10} @@ -359,8 +353,6 @@ local function test_table(test, s, is_array, is_map) -- array test:ok(is_array(ss.encode({1, 2, 3, 4, 5, [100] = 100})), "sparse safe 2") - - ss = nil end local function test_ucdata(test, s) @@ -374,9 +366,9 @@ local function test_ucdata(test, s) local ctype = ffi.typeof('struct serializer_cdata_test') ffi.metatype(ctype, { __index = { - __serialize = function(obj) return 'unpack' end, + __serialize = function() return 'unpack' end, }, - __tostring = function(obj) return 'tostring' end + __tostring = function() return 'tostring' end }); local cdata = ffi.new(ctype) @@ -409,8 +401,6 @@ local function test_ucdata(test, s) test:istable(ss.decode(ss.encode(udata)), 'udata hook priority') -- gh-1226: luaL_convertfield should ignore __serialize hook for ctypes test:like(ss.decode(ss.encode(ctype)), 'ctype