[Tarantool-patches] [PATCH v7 2/2] luacheck: fix warnings in test/engine_long
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sun Jan 17 19:22:53 MSK 2021
Hi! Thanks for the patch!
> diff --git a/.luacheckrc b/.luacheckrc
> index d58fd57b0..b581136b2 100644
> --- a/.luacheckrc
> +++ b/.luacheckrc
> @@ -176,3 +176,9 @@ files["test/box-tap/extended_error.test.lua"] = {
> "forbidden_function",
> },
> }
> +files["test/engine_long/suite.lua"] = {
> + globals = {
> + "delete_replace_update",
> + "delete_insert",
There is no reason for these functions to be global. The only reason
is being able to call a function via IPROTO_CALL, which is not the
case here.
I proper fix should make them local and returned as a result of
require():
====================
diff --git a/.luacheckrc b/.luacheckrc
index 02349331e..8c67f9d47 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -131,9 +131,3 @@ files["test/box-tap/extended_error.test.lua"] = {
"forbidden_function",
},
}
-files["test/engine_long/suite.lua"] = {
- globals = {
- "delete_replace_update",
- "delete_insert",
- }
-}
diff --git a/test/engine_long/box.lua b/test/engine_long/box.lua
index 28a1560d5..94ae81301 100644
--- a/test/engine_long/box.lua
+++ b/test/engine_long/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/engine_long/delete_insert.result b/test/engine_long/delete_insert.result
index b1d504271..06085ca78 100644
--- a/test/engine_long/delete_insert.result
+++ b/test/engine_long/delete_insert.result
@@ -1,6 +1,9 @@
test_run = require('test_run')
---
...
+delete_insert = require('suite').delete_insert
+---
+...
inspector = test_run.new()
---
...
diff --git a/test/engine_long/delete_insert.test.lua b/test/engine_long/delete_insert.test.lua
index 275aaa23e..b2c4ec308 100644
--- a/test/engine_long/delete_insert.test.lua
+++ b/test/engine_long/delete_insert.test.lua
@@ -1,4 +1,5 @@
test_run = require('test_run')
+delete_insert = require('suite').delete_insert
inspector = test_run.new()
engine = inspector:get_cfg('engine')
iterations = 100000
diff --git a/test/engine_long/delete_replace_update.result b/test/engine_long/delete_replace_update.result
index 66cb9c82c..b12e00688 100644
--- a/test/engine_long/delete_replace_update.result
+++ b/test/engine_long/delete_replace_update.result
@@ -1,3 +1,6 @@
+delete_replace_update = require('suite').delete_replace_update
+---
+...
engine_name = 'memtx'
---
...
diff --git a/test/engine_long/delete_replace_update.test.lua b/test/engine_long/delete_replace_update.test.lua
index 466b8f007..e6906a94b 100644
--- a/test/engine_long/delete_replace_update.test.lua
+++ b/test/engine_long/delete_replace_update.test.lua
@@ -1,3 +1,4 @@
+delete_replace_update = require('suite').delete_replace_update
engine_name = 'memtx'
iterations = 100000
diff --git a/test/engine_long/suite.lua b/test/engine_long/suite.lua
index 586160a1a..995257382 100644
--- a/test/engine_long/suite.lua
+++ b/test/engine_long/suite.lua
@@ -9,7 +9,7 @@ local function string_function()
return random_string
end
-function delete_replace_update(engine_name, iterations)
+local function delete_replace_update(engine_name, iterations)
if (box.space._space.index.name:select{'tester'}[1] ~= nil) then
box.space.tester:drop()
end
@@ -66,7 +66,7 @@ function delete_replace_update(engine_name, iterations)
return {counter, random_number, string_value_2, string_value_3}
end
-function delete_insert(engine_name, iterations)
+local function delete_insert(engine_name, iterations)
if (box.space._space.index.name:select{'tester'}[1] ~= nil) then
box.space.tester:drop()
end
@@ -104,4 +104,7 @@ function delete_insert(engine_name, iterations)
return {counter, string_value_2}
end
-_G.protected_globals = {'delete_replace_update', 'delete_insert'}
+return {
+ delete_replace_update = delete_replace_update,
+ delete_insert = delete_insert
+}
More information about the Tarantool-patches
mailing list