[Tarantool-patches] [PATCH v8 04/14] test: fix luacheck warnings W211 in test/sql-tap

Sergey Bronnikov sergeyb at tarantool.org
Sat Feb 27 20:09:09 MSK 2021


Hello!

On 27.02.2021 02:42, Vladislav Shpilevoy wrote:
> Thanks for the fixes!
>
>>>> diff --git a/test/sql-tap/func.test.lua b/test/sql-tap/func.test.lua
>>>> index 9cd517673..5dab23007 100755
>>>> --- a/test/sql-tap/func.test.lua
>>>> +++ b/test/sql-tap/func.test.lua
>>>> @@ -1382,7 +1380,6 @@ test:do_execsql_test(
>>>>        })
>>>>      db("cache", "flush")
>>>> -V = "three"
>>> 2. 'V' is supposed to be a variable. It is used in the queries
>>> in the surrounding code. Please, don't delete parts of the tests.
>>> It will not make it simpler to restore the context later. The tests
>>> in this patchset either must be deleted, or resurrected, or hacked
>>> to keep their context and not fail luacheck. What to choose - depends
>>> on individual tests. Here clearly we need to keep 'V'. Try to make
>>> another pass of self-review to locate more of such test-"breaking"
>>> changes.
>> reverted and suppressed
>>
>> --- a/test/sql-tap/func.test.lua
>> +++ b/test/sql-tap/func.test.lua
>> @@ -1382,6 +1382,7 @@ test:do_execsql_test(
>>       })
>>
>>   db("cache", "flush")
>> +local V = "three" -- luacheck: no unused
>>   test:do_execsql_test(
>>       "13.8.6",
>>       [[
> Now take a look at the diff in this file:
>
> ====================
> @@ -1361,7 +1361,6 @@ test:do_execsql_test(
>           -- </13.8.3>
>       })
>   
> -local V = "one"
>   test:do_execsql_test(
>       "13.8.4",
>       [[
> @@ -1372,7 +1371,6 @@ test:do_execsql_test(
>           -- </13.8.4>
>       })
>   
> -V = "two"
>   test:do_execsql_test(
>       "13.8.5",
>       [[
> @@ -1384,7 +1382,7 @@ test:do_execsql_test(
>       })
>   
>   db("cache", "flush")
> -V = "three"
> +local V = "three" -- luacheck: no unused
> ====================
>
> The comment wasn't about only "three". You shouldn't delete
> "two" and "one", obviously. By the same reason. They are
> "used" in these not working tests.
Agree, looks bad. Fixed for "one" and "two" too.
>> diff --git a/test/sql-tap/select9.test.lua b/test/sql-tap/select9.test.lua
>> index 4f7da84e2..045d0e4c8 100755
>> --- a/test/sql-tap/select9.test.lua
>> +++ b/test/sql-tap/select9.test.lua
>> @@ -274,10 +274,8 @@ test:do_execsql_test(
>>           -- </select9-2.0>
>>       })
>>   
>> -local t1_space_id = ""
>> -local t2_space_id = ""
>> -t1_space_id = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
>> -t2_space_id = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
>> +local _ = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
>> +local _ = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
>>   --X(276, "X!cmd", [=[["db","eval","SELECT * from _space where name='t2'","data","\n  set t2_space_id $data(id)\n"]]=])
>>   --local function reverse(lhs, rhs)
>>   --    return X(283, "X!cmd", [=[["string","compare",["rhs"],["lhs"]]]=])
> t2_space_id is used in the commented code. But it looks already
> corrupted, I can't even closely understand what is happening here.

I read a history of commits for select9.test.lua and "t{1,2}_space_id" 
haven't changed since initial import.

See [1].

> t2_space_id and t1_space_id are obvious names anyway, so we probably could
> just delete their declaration and assignment but keep t2_space_id usage
> in the commented code.
>
> Or comment them out too.

removed:

--- a/test/sql-tap/select9.test.lua
+++ b/test/sql-tap/select9.test.lua
@@ -274,10 +274,8 @@ test:do_execsql_test(
          -- </select9-2.0>
      })

-local t1_space_id = ""
-local t2_space_id = ""
-t1_space_id = test:execsql([[SELECT * from "_space" where 
"name"='T1']])["id"]
-t2_space_id = test:execsql([[SELECT * from "_space" where 
"name"='T2']])["id"]
+local _ = test:execsql([[SELECT * from "_space" where "name"='T1']])["id"]
+local _ = test:execsql([[SELECT * from "_space" where "name"='T2']])["id"]
  --X(276, "X!cmd", [=[["db","eval","SELECT * from _space where 
name='t2'","data","\n  set t2_space_id $data(id)\n"]]=])
  --local function reverse(lhs, rhs)
  --    return X(283, "X!cmd", [=[["string","compare",["rhs"],["lhs"]]]=])

1. 
https://github.com/tarantool/tarantool/commit/47b70d97579a0f9fb59ab122cc97cea4a616be3d#diff-e2e23d907919e91e8ea29b579fd5caa73fd7526b242f65688c2c3939a45372a7R276-R279



More information about the Tarantool-patches mailing list