Hi, Sergey!

thanks for the patch!

On 14.08.2024 16:55, Sergey Kaplun wrote:
This patch moves the aforementioned test from the <misc> to the <lang/>
It is not clear why do you move it to another suite/dir.
directory (with slightly renaming to be consistent with other names),
includes it in <index>, and names the subtest.

Also, it changes the number of iterations to trigger the GC since the
number of objects is different when running the test as a part of the
LuaJIT test suite.

the patch contains minor changes related to formatting.

please describe it in commit message.


Part of tarantool/tarantool#9398
---
 .../{misc/debug_gc.lua => lang/gc_debug.lua}  | 31 ++++++++++++-------
 test/LuaJIT-tests/lang/index                  |  1 +
 2 files changed, 20 insertions(+), 12 deletions(-)
 rename test/LuaJIT-tests/{misc/debug_gc.lua => lang/gc_debug.lua} (63%)

diff --git a/test/LuaJIT-tests/misc/debug_gc.lua b/test/LuaJIT-tests/lang/gc_debug.lua
similarity index 63%
rename from test/LuaJIT-tests/misc/debug_gc.lua
rename to test/LuaJIT-tests/lang/gc_debug.lua
index 30fb2b99..bb30adc1 100644
--- a/test/LuaJIT-tests/misc/debug_gc.lua
+++ b/test/LuaJIT-tests/lang/gc_debug.lua
@@ -1,12 +1,7 @@
-
--- Do not run this test unless the JIT compiler is turned off.
-if jit and jit.status and jit.status() then return end
-
 local caught, caught_line, caught_mm
 
 local function gcmeta()
   if caught ~= "end" then
---    print(debug.traceback())
     -- This may point to the wrong instruction if in a JIT trace.
     -- But there's no guarantee if, when or where any GC steps occur.
     local dbg = debug.getinfo(2)
@@ -22,7 +17,7 @@ local function testgc(mm, f)
   local u = newproxy(true)
   getmetatable(u).__gc = gcmeta
   u = nil
-  for i=1,100000 do
+  for i = 1, 1e7 do
     f(i)
     -- This check may be hoisted. __gc is not supposed to have side-effects.
     if caught then break end
@@ -38,10 +33,22 @@ local function testgc(mm, f)
   end
 end
 
-local x
-testgc("__gc", function(i) x = {} end)
-testgc("__gc", function(i) x = {1} end)
-testgc("__gc", function(i) x = function() end end)
-testgc("__concat", function(i) x = i.."" end)
+do --- Test __gc metamethod info
+  -- Do not run this test unless the JIT compiler is turned off.
+  local jit_need_restore = false
+  if jit and jit.status and jit.status() then
+    jit_need_restore = true
+    jit.off()
+  end
+
+  local x
+  testgc("__gc", function(i) x = {} end)
+  testgc("__gc", function(i) x = {1} end)
+  testgc("__gc", function(i) x = function() end end)
+  testgc("__concat", function(i) x = i.."" end)
 
-caught = "end"
+  caught = "end"
+  if jit_need_restore then
+     jit.on()
+  end
+end
diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
index 803f32d8..4d9feafd 100644
--- a/test/LuaJIT-tests/lang/index
+++ b/test/LuaJIT-tests/lang/index
@@ -17,5 +17,6 @@ upvalue
 tail_recursion.lua
 vararg_jit.lua
 gc.lua
+gc_debug.lua
 goto.lua +goto
 meta