Sergey,

On 21.08.2024 11:58, Sergey Kaplun wrote:
This patch moves the aforementioned test from the <misc> to the <lang/>
directory, includes it in <index>, names the subtests, and adds testing
of the error message for all non-tail call cases.

Part of tarantool/tarantool#9398
---
thanks for the patch! LGTM with a minor comment below.
 test/LuaJIT-tests/lang/index       |  1 +
 test/LuaJIT-tests/lang/stackov.lua | 48 ++++++++++++++++++++++++++++++
Probably filename "stack_overflow.lua" will be better. Feel free to ignore.
 test/LuaJIT-tests/misc/stackov.lua | 40 -------------------------
 3 files changed, 49 insertions(+), 40 deletions(-)
 create mode 100644 test/LuaJIT-tests/lang/stackov.lua
 delete mode 100644 test/LuaJIT-tests/misc/stackov.lua

diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index b262c555..fa6db3c3 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -17,6 +17,7 @@ lightud.lua
 modulo.lua
 concat.lua
 self.lua
+stackov.lua
 table.lua
 parse_comp.lua
 parse_esc.lua
diff --git a/test/LuaJIT-tests/lang/stackov.lua b/test/LuaJIT-tests/lang/stackov.lua
new file mode 100644
index 00000000..21ae40b6
--- /dev/null
+++ b/test/LuaJIT-tests/lang/stackov.lua
@@ -0,0 +1,48 @@
+local function f()
+  f()
+end
+
+local function g(i)
+  g(i)
+end
+
+local function vtail(...)
+  return vtail(1, ...)
+end
+
+local function vcall(...)
+  vcall(1, ...)
+end
+
+local function test_error_msg(func, s)
+  local first = string.match(s, "[^\n]+")
+  local line = debug.getinfo(func, "S").linedefined + 1
+  assert(string.match(first, ":" .. line .. ": stack overflow$"))
+
+  local n = 1
+  for _ in string.gmatch(s, "\n") do n = n + 1 end
+  assert(n == 1 + 1 + 11 + 1 + 10)
+end
+
+do --- Base test.
+  local err, s = xpcall(f, debug.traceback)
+  assert(err == false)
+  test_error_msg(f, s)
+end
+
+do --- Stack overflow with non-empty arg list.
+  local err, s = xpcall(g, debug.traceback, 1)
+  assert(err == false)
+  test_error_msg(g, s)
+end
+
+do --- Vararg tail call with non-empty arg list. +slow
+  local err, s = xpcall(vtail, debug.traceback, 1)
+  assert(err == false)
+end
+
+do --- Vararg non-tail call.
+  local err, s = xpcall(vcall, debug.traceback, 1)
+  assert(err == false)
+  test_error_msg(vcall, s)
+end
diff --git a/test/LuaJIT-tests/misc/stackov.lua b/test/LuaJIT-tests/misc/stackov.lua
deleted file mode 100644
index ef105af6..00000000
--- a/test/LuaJIT-tests/misc/stackov.lua
+++ /dev/null
@@ -1,40 +0,0 @@
-
-local function f()
-  f()
-end
-
-local err, s = xpcall(f, debug.traceback)
-assert(err == false)
-
-local first = string.match(s, "[^\n]+")
-local line = debug.getinfo(f, "S").linedefined+1
-assert(string.match(first, ":"..line..": stack overflow$"))
-
-local n = 1
-for _ in string.gmatch(s, "\n") do n = n + 1 end
-assert(n == 1+1+11+1+10)
-
-local function g(i)
-  g(i)
-end
-
-local err, s = xpcall(g, debug.traceback, 1)
-assert(err == false)
-
---[[
--- too slow
-local function vtail(...)
-  return vtail(1, ...)
-end
-
-local err, s = xpcall(vtail, debug.traceback, 1)
-assert(err == false)
---]]
-
-local function vcall(...)
-  vcall(1, ...)
-end
-
-local err, s = xpcall(vcall, debug.traceback, 1)
-assert(err == false)
-