[Tarantool-patches] [PATCH] test: disable cases in PUC-Rio tests for debug line hook

Sergey Kaplun skaplun at tarantool.org
Mon Feb 6 16:24:25 MSK 2023


Hi, Sergey!

Thanks for the fixes!
LGTM, after fixing a few more nits.

On 06.02.23, Sergey Bronnikov wrote:
> Hi, Sergey!
> 
> Thanks for a quick review!
> 
> See my answers inline.
> 
> On 2/6/23 11:31, Sergey Kaplun wrote:
> > Hi, Sergey!
> >
> > Thanks for the patch!
> > Please consider my comments below.
> >
> > On 06.02.23, Sergey Bronnikov wrote:
> >> From: Sergey Bronnikov <sergeyb at tarantool.org>
> >>
> >> In order to fix issue [1] it is required to introduce a wrapper for
> >> `__pairs()`. This wrapper breaks a couple of tests for builtin debug
> > IINM, it's not for the metamethod `__pairs`, but for the built-in
> > function `pairs()`.
> Right! Updated  commit message.
> >
> >> module.
> >            ^ Those tests rely on specific backtrace, which is changed by
> >    an additional wrapper for `pairs()`.
> 
> Added to commit message.

Nit: "tests" should be in plural form in those sentences as far as the
only one test (the one with `pairs()` usage) is broken after introducing
`pairs()` wrapper.

> 
> 
> >
> >>          Patch disables testcases when running under Tarantool.
> >>
> >> 1. https://github.com/tarantool/tarantool/issues/2867
> >> ---
> >>   test/PUC-Rio-Lua-5.1-tests/db.lua | 4 ++++
> >>   1 file changed, 4 insertions(+)
> >>
> >> diff --git a/test/PUC-Rio-Lua-5.1-tests/db.lua b/test/PUC-Rio-Lua-5.1-tests/db.lua
> >> index b148c2dd..b05075bb 100644
> >> --- a/test/PUC-Rio-Lua-5.1-tests/db.lua
> >> +++ b/test/PUC-Rio-Lua-5.1-tests/db.lua
> >> @@ -169,10 +169,12 @@ test([[for i=1,3 do
> >>   end
> >>   ]], {1,2,1,2,1,2,1,3})
> >>   
> >> +if not _TARANTOOL then
> > Minor: It will be nice to add the comment about the wrapper for
> > `pairs()` in Tarantool here.
> 
> 
> Added:
> 
> "Tarantool has a wrapper around builtin function `pairs()`, see see gh-2867.
> Testcase below relies on a specific backtrace, which is changed by an
> introduced wrapper for `pairs()`."

Nit: Please, use `--` comment stile, like elsewhere in this file.
Multiline comments are used for debug tests and for quoting some chunks
output.

Friendly reminder: Don't forget to change linedefined below:).

> 
> >
> >>   test([[for i,v in pairs{'a','b'} do
> >>     a=i..v
> >>   end
> >>   ]], {1,2,1,2,1,3})
> >> +end
> >>   
> >>   -- Test is adapted to the behaviour of LuaJIT, as it generates
> >>   -- only four line events, unlike Lua, which generates five
> >> @@ -411,7 +413,9 @@ function g1(x) g(x) end
> >>   
> >>   local function h (x) local f=g1; return f(x) end
> >>   
> >> +if not _TARANTOOL then
> >>   h(true)
> >> +end
> > These changes don't fix the problem for the test in LuaJIT [1]:
> >
> > | src/luajit: test/PUC-Rio-Lua-5.1-tests/db.lua:403: assertion failed!
> > | stack traceback:
> > |         [C]: in function 'assert'
> > |         test/PUC-Rio-Lua-5.1-tests/db.lua:403: in function 'g'
> > |         test/PUC-Rio-Lua-5.1-tests/db.lua:412: in function 'h'
> > |         test/PUC-Rio-Lua-5.1-tests/db.lua:417: in function '_dofile'
> > |         test/PUC-Rio-Lua-5.1-tests/all.lua:89: in main chunk
> > |         [C]: at 0x56039b641064
> > As far as the linedefined number for `g1()` function is changed.
> >
> > I suggest the following patch (without comments to add) (haven't checked
> > it on Tarantool):
> > ===================================================================
> > diff --git a/test/PUC-Rio-Lua-5.1-tests/db.lua b/test/PUC-Rio-Lua-5.1-tests/db.lua
> > index b05075bb..550debdc 100644
> > --- a/test/PUC-Rio-Lua-5.1-tests/db.lua
> > +++ b/test/PUC-Rio-Lua-5.1-tests/db.lua
> > @@ -400,7 +400,7 @@ local function f (x)
> >     if x then
> >       assert(debug.getinfo(1, "S").what == "Lua")
> >       local tail = debug.getinfo(2)
> > -    assert(tail.what == "Lua" and tail.linedefined == 410 and tail.func == g1)
> > +    assert(tail.what == "Lua" and tail.linedefined == 412 and tail.func == g1)
> >       assert(getfenv(3))
> >       assert(debug.getinfo(3, "S").what == "main")
> >       print"+"
> > @@ -413,9 +413,7 @@ function g1(x) g(x) end
> >   
> >   local function h (x) local f=g1; return f(x) end
> >   
> > -if not _TARANTOOL then
> >   h(true)
> > -end
> >   
> >   local b = {}
> >   debug.sethook(function (e) table.insert(b, e) end, "cr")
> > ===================================================================
> 
> Reverted a change around call of h() function, updated line number and 
> added a message to assert with useful information:
> 
> 
>     if x then
>       assert(debug.getinfo(1, "S").what == "Lua")
>       local tail = debug.getinfo(2)
> -    assert(tail.what == "Lua" and tail.linedefined == 410 and tail.func 
> == g1)
> +    assert(tail.what == "Lua" and tail.linedefined == 418 and tail.func 
> == g1,
> +           ("linedefined %s, what %s"):format(tail.linedefined, tail.what))
>       assert(getfenv(3))
>       assert(debug.getinfo(3, "S").what == "main")
>       print"+"
> 
> 
> >>   
> >>   local b = {}
> >>   debug.sethook(function (e) table.insert(b, e) end, "cr")
> >> -- 
> >> 2.34.1
> >>
> > [1]: https://github.com/tarantool/luajit/actions/runs/4101439522/jobs/7073225472
> >

-- 
Best regards,
Sergey Kaplun


More information about the Tarantool-patches mailing list