[Tarantool-patches] [PATCH luajit 4/5] test: fix warnings found with luacheck in misclib*

Sergey Bronnikov sergeyb at tarantool.org
Mon Feb 8 18:40:20 MSK 2021


+ tarantool-patches

On 08.02.2021 18:19, Sergey Bronnikov wrote:
> Thanks for the patch!
>
> LGTM
>
>> : -----Original Message-----
>> : From: Tarantool-patches 
>> <tarantool-patches-bounces at dev.tarantool.org> On
>> : Behalf Of Igor Munkin via Tarantool-patches
>> : Subject: [Tarantool-patches] [PATCH luajit 4/5] test: fix warnings 
>> found
>> : with luacheck in misclib*
>> :
>> : Since the regular static analysis has not been enabled for the test
>> : chunks in LuaJIT repository yet, the tests for recently implemented
>> : features still produce luacheck warnings.
>> :
>> : The most of the issues are fixed in scope of the commit
>> : 8fc103fb1a21c28185a1942e75d8d9485e3aade7 ('test: fix warnings 
>> spotted by
>> : luacheck') and this patch fixes the remaining ones.
>> :
>> : Fixes tarantool/tarantool#5631
>> : Part of tarantool/tarantool#4862
>> : Part of tarantool/tarantool#5470
>> : Follows up tarantool/tarantool#5187
>> :
>> : Reported-by: Sergey Bronnikov <sergeyb at tarantool.org>
>> : Signed-off-by: Igor Munkin <imun at tarantool.org>
>> : ---
>> :  .../misclib-getmetrics-capi.test.lua          | 22 ++++++---------
>> :  .../misclib-getmetrics-lapi.test.lua          | 28 
>> +++++++++----------
>> :  2 files changed, 23 insertions(+), 27 deletions(-)
>> :
>> : diff --git a/test/tarantool-tests/misclib-getmetrics-capi.test.lua
>> : b/test/tarantool-tests/misclib-getmetrics-capi.test.lua
>> : index c418e9f..d409ea9 100755
>> : --- a/test/tarantool-tests/misclib-getmetrics-capi.test.lua
>> : +++ b/test/tarantool-tests/misclib-getmetrics-capi.test.lua
>> : @@ -38,29 +38,29 @@ 
>> test:ok(testgetmetrics.objcount(function(iterations)
>> :      }
>> :
>> :      -- Separate objects creations to separate jit traces.
>> : -    for i = 1, iterations do
>> : -        table.insert(placeholder.str, tostring(i))
>> : +    for _ = 1, iterations do
>> : +        table.insert(placeholder.str, tostring(_))
>> :      end
>> :
>> : -    for i = 1, iterations do
>> : -        table.insert(placeholder.tab, {i})
>> : +    for _ = 1, iterations do
>> : +        table.insert(placeholder.tab, {_})
>> :      end
>> :
>> : -    for i = 1, iterations do
>> : +    for _ = 1, iterations do
>> :          table.insert(placeholder.udata, newproxy())
>> :      end
>> :
>> : -    for i = 1, iterations do
>> : +    for _ = 1, iterations do
>> :          -- Check counting of VLA/VLS/aligned cdata.
>> :          table.insert(placeholder.cdata, ffi.new("char[?]", 4))
>> :      end
>> :
>> : -    for i = 1, iterations do
>> : +    for _ = 1, iterations do
>> :          -- Check counting of non-VLA/VLS/aligned cdata.
>> : -        table.insert(placeholder.cdata, ffi.new("uint64_t", i))
>> : +        table.insert(placeholder.cdata, ffi.new("uint64_t", _))
>> :      end
>> :
>> : -    placeholder = nil
>> : +    placeholder = nil -- luacheck: no unused
>> :      -- Restore default jit settings.
>> :      jit.opt.start(unpack(jit_opt_default))
>> :  end))
>> : @@ -69,15 +69,11 @@ end))
>> :  test:ok(testgetmetrics.snap_restores(function()
>> :      jit.opt.start(0, "hotloop=1")
>> :
>> : -    local old_metrics = misc.getmetrics()
>> : -
>> :      local sum = 0
>> :      for i = 1, 20 do
>> :          sum = sum + i
>> :      end
>> :
>> : -    local new_metrics = misc.getmetrics()
>> : -
>> :      -- Restore default jit settings.
>> :      jit.opt.start(unpack(jit_opt_default))
>> :
>> : diff --git a/test/tarantool-tests/misclib-getmetrics-lapi.test.lua
>> : b/test/tarantool-tests/misclib-getmetrics-lapi.test.lua
>> : index 959293d..d54caac 100755
>> : --- a/test/tarantool-tests/misclib-getmetrics-lapi.test.lua
>> : +++ b/test/tarantool-tests/misclib-getmetrics-lapi.test.lua
>> : @@ -58,10 +58,10 @@ test:test("gc-allocated-freed", function(subtest)
>> :      until collectgarbage("count") == count
>> :
>> :      -- Bump getmetrics table and string keys allocation.
>> : -    local old_metrics = misc.getmetrics()
>> : +    misc.getmetrics()
>> :
>> :      -- Remember allocated size for getmetrics table.
>> : -    old_metrics = misc.getmetrics()
>> : +    local old_metrics = misc.getmetrics()
>> :
>> :      collectgarbage("collect")
>> :
>> : @@ -77,7 +77,7 @@ test:test("gc-allocated-freed", function(subtest)
>> :      -- (such as concatenation, string.format, table.concat)
>> :      -- while creating the string. Otherwise gc_freed/gc_allocated
>> :      -- relations will not be so straightforward.
>> : -    local str = string.sub("Hello, world", 1, 5)
>> : +    local str = string.sub("Hello, world", 1, 5) -- luacheck: no 
>> unused
>> :      collectgarbage("collect")
>> :
>> :      new_metrics = misc.getmetrics()
>> : @@ -196,29 +196,29 @@ test:test("objcount", function(subtest)
>> :      }
>> :
>> :      -- Separate objects creations to separate jit traces.
>> : -    for i = 1, 1000 do
>> : -        table.insert(placeholder.str, tostring(i))
>> : +    for _ = 1, 1000 do
>> : +        table.insert(placeholder.str, tostring(_))
>> :      end
>> :
>> : -    for i = 1, 1000 do
>> : -        table.insert(placeholder.tab, {i})
>> : +    for _ = 1, 1000 do
>> : +        table.insert(placeholder.tab, {_})
>> :      end
>> :
>> : -    for i = 1, 1000 do
>> : +    for _ = 1, 1000 do
>> :          table.insert(placeholder.udata, newproxy())
>> :      end
>> :
>> : -    for i = 1, 1000 do
>> : +    for _ = 1, 1000 do
>> :          -- Check counting of VLA/VLS/aligned cdata.
>> :          table.insert(placeholder.cdata, ffi.new("char[?]", 4))
>> :      end
>> :
>> : -    for i = 1, 1000 do
>> : +    for _ = 1, 1000 do
>> :          -- Check counting of non-VLA/VLS/aligned cdata.
>> : -        table.insert(placeholder.cdata, ffi.new("uint64_t", i))
>> : +        table.insert(placeholder.cdata, ffi.new("uint64_t", _))
>> :      end
>> :
>> : -    placeholder = nil
>> : +    placeholder = nil -- luacheck: no unused
>> :      collectgarbage("collect")
>> :      local new_metrics = misc.getmetrics()
>> :
>> : @@ -372,7 +372,7 @@ test:test("strhash", function(subtest)
>> :      assert(new_metrics.strhash_miss - old_metrics.strhash_miss == 0)
>> :      old_metrics = new_metrics
>> :
>> : -    local str1  = "strhash".."_hit"
>> : +    local _ = "strhash".."_hit"
>> :
>> :      new_metrics = misc.getmetrics()
>> :      assert(new_metrics.strhash_hit - old_metrics.strhash_hit == 20)
>> : @@ -384,7 +384,7 @@ test:test("strhash", function(subtest)
>> :      assert(new_metrics.strhash_miss - old_metrics.strhash_miss == 0)
>> :      old_metrics = new_metrics
>> :
>> : -    local str2 = "new".."string"
>> : +    local _ = "new".."string"
>> :
>> :      new_metrics = misc.getmetrics()
>> :      assert(new_metrics.strhash_hit - old_metrics.strhash_hit == 19)
>> : --
>> : 2.25.0
>>
>>


More information about the Tarantool-patches mailing list