[Tarantool-patches] [PATCH v7] test: fix luacheck warnings in test/long_run-py
Sergey Bronnikov
sergeyb at tarantool.org
Fri Jan 15 12:47:28 MSK 2021
On 15.01.2021 00:46, Vladislav Shpilevoy wrote:
>>>> diff --git a/test/long_run-py/lua/finalizers.lua b/test/long_run-py/lua/finalizers.lua
>>>> index 69146a323..cb6400363 100644
>>>> --- a/test/long_run-py/lua/finalizers.lua
>>>> +++ b/test/long_run-py/lua/finalizers.lua
>>>> @@ -1,19 +1,17 @@
>>>> #!/usr/bin/env tarantool
>>>> -function on_gc(t)
>>>> +local function on_gc()
>>>> end;
>>>> -function test_finalizers()
>>>> +local function test_finalizers()
>>>> local result = {}
>>>> local i = 1
>>>> local ffi = require('ffi')
>>>> while true do
>>>> - result[i] = ffi.gc(ffi.cast('void *', 0), on_gc)
>>>> + local result[i] = ffi.gc(ffi.cast('void *', 0), on_gc)
>>> 2. This change is not correct. Even luacheck tells it, if you don't
>>> ignore this file. You assign a value to a table member, not
>>> declare a variable.
>> It is still not unclear for me why luacheck complains here.
>>
>> result table declared before a loop and scope for it is a whole function body, what's wrong?
>>
>> Similar lua chunk successfully executed by puc lua:
>>
>> local result = {}
>> local i = 0
>> while i == 0 do
>> result[i] = 1
>> end
> Your chunk is similar, but not the same. Originally you used 'local result[i] = ...'
> expression which is obviously wrong. You can't "declare" a table member as local.
> 'result[i]' is not a valid variable name, so it can't be used with 'local' keyword
> to declare it as a variable.
Got it, thanks.
>>>> diff --git a/test/long_run-py/suite.lua b/test/long_run-py/suite.lua
>>>> index 0b33dec7d..7a09dd2b8 100644
>>>> --- a/test/long_run-py/suite.lua
>>>> +++ b/test/long_run-py/suite.lua
>>>> @@ -109,3 +106,8 @@ function delete_insert(engine_name)
>>>> box.space.tester:drop()
>>>> return {counter, string_value_2}
>>>> end
>>>> +
>>>> +return {
>>>> + delete_replace_update = delete_replace_update;
>>>> + delete_insert = delete_insert;
>>> 3. Please, use ',' instead of ';'.
>>>
>> Fixed in a branch.
> I realized suite.lua functions are never used. The file is imported in
> long_run-py/box.lua, but the imported functions are not used. I deleted
> it and the tests pass. I suggest you to delete this file entirely:
>
> ====================
> diff --git a/test/long_run-py/box.lua b/test/long_run-py/box.lua
> index b4f65dcdb..354e680b4 100644
> --- a/test/long_run-py/box.lua
> +++ b/test/long_run-py/box.lua
> @@ -1,7 +1,5 @@
> #!/usr/bin/env tarantool
>
> -require('suite')
> -
> os.execute("rm -rf vinyl_test")
> os.execute("mkdir -p vinyl_test")
>
> diff --git a/test/long_run-py/suite.ini b/test/long_run-py/suite.ini
> index 110bbb548..7561fdb5a 100644
> --- a/test/long_run-py/suite.ini
> +++ b/test/long_run-py/suite.ini
> @@ -5,7 +5,6 @@ script = box.lua
> long_run = finalizers.test.py
> valgrind_disabled =
> release_disabled =
> -lua_libs = suite.lua
> use_unix_sockets = True
> use_unix_sockets_iproto = True
> is_parallel = True
>
> + delete suite.lua file.
Done.
CI: https://gitlab.com/tarantool/tarantool/-/pipelines/242068204
More information about the Tarantool-patches
mailing list