[Tarantool-patches] [PATCH v7] test: fix luacheck warnings in test/swim

sergeyb at tarantool.org sergeyb at tarantool.org
Mon Jan 18 12:50:37 MSK 2021


From: Sergey Bronnikov <sergeyb at tarantool.org>

Closes #5465

Reviewed-by: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
Reviewed-by: Igor Munkin <imun at tarantool.org>

Co-authored-by: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
Co-authored-by: Igor Munkin <imun at tarantool.org>
---

Changelog v7:
- rebased to master

Changelog v6:

- splitted patch in test/ for patches per sub-directory
- adjusted supressions in .luacheckrc
- fixed formatting issues in .luacheckrc

Issue: https://github.com/tarantool/tarantool/issues/5465
Gitlab CI: https://gitlab.com/tarantool/tarantool/-/pipelines/243085008
Branch: ligurio/gh-5465-luacheck-warnings-test-swim

 .luacheckrc               | 10 +++++++++-
 test/swim/box.lua         |  7 +++----
 test/swim/errinj.result   |  5 ++++-
 test/swim/errinj.test.lua |  3 ++-
 test/swim/swim.result     |  6 ++++++
 test/swim/swim.test.lua   |  2 ++
 6 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/.luacheckrc b/.luacheckrc
index 497b1efc8..1fc4b1c7a 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -46,7 +46,7 @@ exclude_files = {
     "test/replication/**/*.lua",
     "test/replication-py/**/*.lua",
     "test/sql/**/*.lua",
-    "test/swim/**/*.lua",
+    "test/swim/*.test.lua",
     "test/var/**/*.lua",
     "test/vinyl/**/*.lua",
     "test/wal_off/*.test.lua",
@@ -131,3 +131,11 @@ files["test/box-tap/extended_error.test.lua"] = {
         "forbidden_function",
     },
 }
+files["test/swim/box.lua"] = {
+    globals = {
+        "listen_port",
+        "listen_uri",
+        "uuid",
+        "uri",
+    }
+}
diff --git a/test/swim/box.lua b/test/swim/box.lua
index a603777e0..d15f0c1a1 100644
--- a/test/swim/box.lua
+++ b/test/swim/box.lua
@@ -1,7 +1,6 @@
 #!/usr/bin/env tarantool
 
-swim = require('swim')
-fiber = require('fiber')
+local swim = require('swim')
 listen_uri = tostring(os.getenv("LISTEN"))
 listen_port = require('uri').parse(listen_uri).service
 
@@ -12,8 +11,8 @@ box.cfg{}
 -- with encryption. Otherwise they can accidentally discover
 -- SWIM instances from other tests.
 --
-enc_key = box.info.uuid
-enc_algo = 'aes128'
+local enc_key = box.info.uuid
+local enc_algo = 'aes128'
 
 --
 -- Wrap swim.new with a codec to prevent test workers affecting
diff --git a/test/swim/errinj.result b/test/swim/errinj.result
index cf26b0a4a..6abf42da4 100644
--- a/test/swim/errinj.result
+++ b/test/swim/errinj.result
@@ -1,4 +1,7 @@
-test_run = require('test_run').new()
+fiber = require('fiber')
+---
+...
+swim = require('swim')
 ---
 ...
 errinj = box.error.injection
diff --git a/test/swim/errinj.test.lua b/test/swim/errinj.test.lua
index 6c73f9f3d..8ef12ba8a 100644
--- a/test/swim/errinj.test.lua
+++ b/test/swim/errinj.test.lua
@@ -1,4 +1,5 @@
-test_run = require('test_run').new()
+fiber = require('fiber')
+swim = require('swim')
 errinj = box.error.injection
 
 --
diff --git a/test/swim/swim.result b/test/swim/swim.result
index 8b7f98afc..bfc83c143 100644
--- a/test/swim/swim.result
+++ b/test/swim/swim.result
@@ -1,3 +1,9 @@
+fiber = require('fiber')
+---
+...
+swim = require('swim')
+---
+...
 test_run = require('test_run').new()
 ---
 ...
diff --git a/test/swim/swim.test.lua b/test/swim/swim.test.lua
index 7e2f5a857..1593d8833 100644
--- a/test/swim/swim.test.lua
+++ b/test/swim/swim.test.lua
@@ -1,3 +1,5 @@
+fiber = require('fiber')
+swim = require('swim')
 test_run = require('test_run').new()
 test_run:cmd("push filter '\\.lua.*:[0-9]+: ' to '.lua:<line>: '")
 test_run:cmd("push filter '127.0.0.1:[0-9]+$' to '127.0.0.1:<port>'")
-- 
2.25.1


More information about the Tarantool-patches mailing list