[Tarantool-patches] [PATCH v2 luajit 2/5] test: adjust lua-Harness suite for LuaJIT

Sergey Kaplun skaplun at tarantool.org
Mon Mar 15 18:29:27 MSK 2021


LUAJIT_TEST_COMMAND always extends an amount of line argument by two
causing child test failures.
So, a new universal way to detect program name is required.

This patch introduces the new function `get_lua_binary_name()` inside
lua-Harness tap.lua module to get binary for test execution correctly.

The following tests are adjusted with the new function:
* 241-standalone.t
* 242-luac.t
* 301-basic.t
* 308-io.t
* 309-os.t
* 320-stdin.t
* 411-luajit.t

Part of tarantool/tarantool#5844
Part of tarantool/tarantool#4473
---
 test/lua-Harness-tests/241-standalone.t | 2 +-
 test/lua-Harness-tests/242-luac.t       | 2 +-
 test/lua-Harness-tests/301-basic.t      | 2 +-
 test/lua-Harness-tests/308-io.t         | 2 +-
 test/lua-Harness-tests/309-os.t         | 2 +-
 test/lua-Harness-tests/320-stdin.t      | 2 +-
 test/lua-Harness-tests/411-luajit.t     | 2 +-
 test/lua-Harness-tests/tap.lua          | 9 +++++++++
 8 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/test/lua-Harness-tests/241-standalone.t b/test/lua-Harness-tests/241-standalone.t
index c99f324..c5237ee 100755
--- a/test/lua-Harness-tests/241-standalone.t
+++ b/test/lua-Harness-tests/241-standalone.t
@@ -41,7 +41,7 @@ elseif ravi then
     banner = '^Ravi %d%.%d%.%d'
 end
 
-local lua = arg[-3] or arg[-1]
+local lua = get_lua_binary_name()
 local luac = jit and lua or (lua .. 'c')
 
 if not pcall(io.popen, lua .. [[ -e "a=1"]]) then
diff --git a/test/lua-Harness-tests/242-luac.t b/test/lua-Harness-tests/242-luac.t
index 2d166e5..a95a334 100755
--- a/test/lua-Harness-tests/242-luac.t
+++ b/test/lua-Harness-tests/242-luac.t
@@ -38,7 +38,7 @@ if ravi then
     skip_all("ravi")
 end
 
-local lua = arg[-3] or arg[-1]
+local lua = get_lua_binary_name()
 local luac = lua .. 'c'
 
 if not pcall(io.popen, lua .. [[ -e "a=1"]]) then
diff --git a/test/lua-Harness-tests/301-basic.t b/test/lua-Harness-tests/301-basic.t
index e45599e..f4f9235 100755
--- a/test/lua-Harness-tests/301-basic.t
+++ b/test/lua-Harness-tests/301-basic.t
@@ -48,7 +48,7 @@ local has_warn = _VERSION >= 'Lua 5.4'
 local has_xpcall52 = _VERSION >= 'Lua 5.2' or jit
 local has_xpcall53 = _VERSION >= 'Lua 5.3' or jit
 
-local lua = arg[-3] or arg[-1]
+local lua = get_lua_binary_name()
 
 plan'no_plan'
 
diff --git a/test/lua-Harness-tests/308-io.t b/test/lua-Harness-tests/308-io.t
index cdbcb83..35d39c0 100755
--- a/test/lua-Harness-tests/308-io.t
+++ b/test/lua-Harness-tests/308-io.t
@@ -40,7 +40,7 @@ local has_read53 = _VERSION >= 'Lua 5.3' or luajit21
 local has_meta53 = _VERSION >= 'Lua 5.3'
 local has_meta54 = _VERSION >= 'Lua 5.4'
 
-local lua = arg[-3] or arg[-1]
+local lua = get_lua_binary_name()
 
 plan'no_plan'
 
diff --git a/test/lua-Harness-tests/309-os.t b/test/lua-Harness-tests/309-os.t
index e42fb53..a787b14 100755
--- a/test/lua-Harness-tests/309-os.t
+++ b/test/lua-Harness-tests/309-os.t
@@ -34,7 +34,7 @@ require'tap'
 local profile = require'profile'
 local luajit20 = jit and (jit.version_num < 20100 and not jit.version:match'^RaptorJIT')
 local has_execute51 = _VERSION == 'Lua 5.1' and (not profile.luajit_compat52 or ujit)
-local lua = arg[-3] or arg[-1]
+local lua = get_lua_binary_name()
 
 plan'no_plan'
 
diff --git a/test/lua-Harness-tests/320-stdin.t b/test/lua-Harness-tests/320-stdin.t
index 36528e8..4828285 100755
--- a/test/lua-Harness-tests/320-stdin.t
+++ b/test/lua-Harness-tests/320-stdin.t
@@ -26,7 +26,7 @@ Tests Lua Basic & IO Libraries with stdin
 
 require'tap'
 
-local lua = arg[-3] or arg[-1]
+local lua = get_lua_binary_name()
 
 if not pcall(io.popen, lua .. [[ -e "a=1"]]) then
     skip_all "io.popen not supported"
diff --git a/test/lua-Harness-tests/411-luajit.t b/test/lua-Harness-tests/411-luajit.t
index 05111be..feb752e 100755
--- a/test/lua-Harness-tests/411-luajit.t
+++ b/test/lua-Harness-tests/411-luajit.t
@@ -31,7 +31,7 @@ if not jit or ujit then
     skip_all("only with LuaJIT")
 end
 
-local lua = arg[-3] or arg[-1]
+local lua = get_lua_binary_name()
 
 if not pcall(io.popen, lua .. [[ -e "a=1"]]) then
     skip_all("io.popen not supported")
diff --git a/test/lua-Harness-tests/tap.lua b/test/lua-Harness-tests/tap.lua
index 08a99b8..5ce95e6 100644
--- a/test/lua-Harness-tests/tap.lua
+++ b/test/lua-Harness-tests/tap.lua
@@ -195,6 +195,15 @@ function todo (reason, count)
     todo_reason = reason
 end
 
+-- The last arg element is guaranteed name of tested binary.
+function get_lua_binary_name ()
+    local i = 0
+    while arg[i] do
+        i = i - 1
+    end
+    return arg[i + 1]
+end
+
 --
 -- Copyright (c) 2009-2018 Francois Perrad
 --
-- 
2.28.0



More information about the Tarantool-patches mailing list