[Tarantool-patches] [PATCH v2 06/10] test: support tarantool in lua-Harness

Maxim Kokryashkin max.kokryashkin at gmail.com
Tue Jul 20 19:26:54 MSK 2021


Backports 'supoort Tarantool' patch[1] from lua-Harness.

[1]: https://framagit.org/fperrad/lua-Harness/-/commit/d3ceee16

Part of tarantool/tarantool#5970
Part of tarantool/tarantool#4473
---
 ...standalone.t.disabled => 241-standalone.t} |  5 ++
 test/lua-Harness-tests/320-stdin.t            |  2 +-
 .../{411-luajit.t.disabled => 411-luajit.t}   |  2 +-
 test/lua-Harness-tests/profile_tarantool.lua  | 63 +++++++++++++++++++
 4 files changed, 70 insertions(+), 2 deletions(-)
 rename test/lua-Harness-tests/{241-standalone.t.disabled => 241-standalone.t} (99%)
 rename test/lua-Harness-tests/{411-luajit.t.disabled => 411-luajit.t} (99%)
 create mode 100644 test/lua-Harness-tests/profile_tarantool.lua

diff --git a/test/lua-Harness-tests/241-standalone.t.disabled b/test/lua-Harness-tests/241-standalone.t
similarity index 99%
rename from test/lua-Harness-tests/241-standalone.t.disabled
rename to test/lua-Harness-tests/241-standalone.t
index 47c50a6b..57d9e5bd 100755
--- a/test/lua-Harness-tests/241-standalone.t.disabled
+++ b/test/lua-Harness-tests/241-standalone.t
@@ -29,6 +29,11 @@ L<https://www.lua.org/manual/5.4/manual.html#7>
 --]]
 
 require'test_assertion'
+
+if _TARANTOOL then
+    skip_all("tarantool")
+end
+
 local has_bytecode = not ujit and not ravi
 local has_error52 = _VERSION >= 'Lua 5.2'
 local has_error53 = _VERSION >= 'Lua 5.3'
diff --git a/test/lua-Harness-tests/320-stdin.t b/test/lua-Harness-tests/320-stdin.t
index bff63760..f4de97fd 100755
--- a/test/lua-Harness-tests/320-stdin.t
+++ b/test/lua-Harness-tests/320-stdin.t
@@ -64,7 +64,7 @@ end
 ]]
     f:close()
 
-    local cmd = lua .. [[ -e "f = loadfile(); print(foo); f(); print(foo('ok'))" < foo-320.lua]]
+    local cmd = lua .. [[ -e "foo = nil; f = loadfile(); print(foo); f(); print(foo('ok'))" < foo-320.lua]]
     f = io.popen(cmd)
     equals(f:read'*l', 'nil', "function loadfile (stdin)")
     equals(f:read'*l', 'ok')
diff --git a/test/lua-Harness-tests/411-luajit.t.disabled b/test/lua-Harness-tests/411-luajit.t
similarity index 99%
rename from test/lua-Harness-tests/411-luajit.t.disabled
rename to test/lua-Harness-tests/411-luajit.t
index 7830df4f..da1af9ce 100755
--- a/test/lua-Harness-tests/411-luajit.t.disabled
+++ b/test/lua-Harness-tests/411-luajit.t
@@ -27,7 +27,7 @@ See L<http://luajit.org/running.html>
 require'test_assertion'
 local profile = require'profile'
 
-if not jit or ujit then
+if not jit or ujit or _TARANTOOL then
     skip_all("only with LuaJIT")
 end
 
diff --git a/test/lua-Harness-tests/profile_tarantool.lua b/test/lua-Harness-tests/profile_tarantool.lua
new file mode 100644
index 00000000..2abd37ff
--- /dev/null
+++ b/test/lua-Harness-tests/profile_tarantool.lua
@@ -0,0 +1,63 @@
+---
+-- lua-Harness : <https://fperrad.frama.io/lua-Harness/>
+---
+
+local profile = {
+
+--[[ compat 5.0
+    has_string_gfind = true,
+    has_math_mod = true,
+--]]
+
+    compat51 = false,
+--[[
+    has_unpack = true,
+    has_package_loaders = true,
+    has_math_log10 = true,
+    has_loadstring = true,
+    has_table_maxn = true,
+    has_module = true,
+    has_package_seeall = true,
+--]]
+
+    compat52 = false,
+--[[
+    has_mathx = true,
+    has_bit32 = true,
+    has_metamethod_ipairs = true,
+--]]
+
+    compat53 = false,
+--[[
+    has_math_log10 = true,
+    has_mathx = true,
+    has_metamethod_ipairs = true,
+--]]
+
+-- [[ luajit
+    luajit_compat52 = false,
+    openresty = false,
+--]]
+
+}
+
+require'strict'.off()                   -- allows undeclared variables
+
+_G.utf8 = nil                           -- not compatible with the PUC one
+
+-- luacheck: globals _dofile
+function _dofile (filename)
+    print("# Custom dofile")
+    return dofile(filename)
+end
+
+package.loaded.profile = profile        -- prevents loading of default profile
+
+return profile
+
+--
+-- Copyright (c) 2018-2021 Francois Perrad
+--
+-- This library is licensed under the terms of the MIT/X11 license,
+-- like Lua itself.
+--
-- 
2.32.0



More information about the Tarantool-patches mailing list