[Tarantool-patches] [PATCH luajit] test: adapt tests checking traceback in tail call

Максим Корякшин m.kokryashkin at tarantool.org
Tue Nov 9 19:59:16 MSK 2021


Hi, Sergey! Thanks for the review!
Here is the new commit message considering your comments:
 
=======================================================
test: adapt tests checking traceback in tail call
 
LuaJIT does not provide information about tail calls,
unlike, Lua 5.1 does, so a traceback in LuaJIT may be different.
 
Consider this chunck of code:
```
local function f(n)
    if n > 0 then
        return f(n - 1)
    else
        coroutine.yield()
    end
end
 
local co = coroutine.create(f)
coroutine.resume(co, 3)
print(debug.traceback(co))
```
 
For LuaJIT traceback looks like the following:
stack traceback:
            [C]: in function 'yield'
            test.lua:5: in function <test.lua:1>
```
 
And for Lua 5.1 it looks like the following:
```
stack traceback:
            [C]: in function 'yield'
            test.lua:5: in function <test.lua:1>
            (tail call): ?
            (tail call): ?
            (tail call): ?
```
 
This commit adapts the corresponding test to the behavior of LuaJIT, so
it doesn't check tail calls anymore.
 
Part of tarantool/tarantool#5870
=======================================================
 
CI:  https://github.com/tarantool/tarantool/tree/fckxorg/gh-5703-adapt-traceback-tail-call-PUC-Rio
 
Best regards,
Maxim Kokryashkin
  
>Понедельник, 11 октября 2021, 18:13 +03:00 от Sergey Kaplun <skaplun at tarantool.org>:
> 
>Hi, Maxim!
>
>Thanks for the patch!
>
>LGTM except a few nits, regarding the commit message.
>
>On 24.09.21, Maxim Kokryashkin wrote:
>> LuaJIT does not provide information about tail calls
>
>Typo: s/calls/calls,/
>
>> unlike, Lua 5.1 does, so a traceback in LuaJIT may be different.
>>
>> Consider this chunck of code:
>> ```
>> local function checktraceback (co, p)
>> local tb = debug.traceback(co)
>> local i = 0
>> for l in string.gmatch(tb, "[^\n]+\n?") do
>> assert(i == 0 or string.find(l, p[i]))
>> i = i+1
>> end
>> assert(p[i] == nil)
>> end
>>
>> local function f (n)
>> if n > 0 then return f(n-1)
>> else coroutine.yield() end
>> end
>>
>> local co = coroutine.create(f)
>> coroutine.resume(co, 3)
>> checktraceback(co, {"yield", "db.lua", "tail", "tail", "tail"})
>> ```
>>
>> For LuaJIT traceback looks like the following:
>> ```
>> stack traceback:
>> [C]: in function 'yield'
>> db.lua:436: in function <db.lua:434>
>> ```
>>
>> And for Lua 5.1 it looks like the following:
>> ```
>> stack traceback:
>> [C]: in function 'yield'
>> db.lua:436: in function <db.lua:434>
>> (tail call): ?
>> (tail call): ?
>> (tail call): ?
>> ```
>
>Please provide a simple example in the commit message. This is too
>monstrous. Also, it is a good practice to mention what the patch does.
>
>>
>> Closes tarantool/tarantool#5703
>> Part of tarantool/tarantool#5845
>> Part of tarantool/tarantool#4473
>
>Looks like it should be 5870 instead 4473. Also, 5845 is already
>closed.
>
>> ---
>> Issue:  https://github.com/tarantool/tarantool/issues/5703
>> GitHub branch:  https://github.com/tarantool/luajit/tree/fckxorg/gh-5703-adapt-traceback-tail-call-PUC-Rio
>>
>> test/PUC-Rio-Lua-5.1-tests/db.lua | 5 ++---
>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/test/PUC-Rio-Lua-5.1-tests/db.lua b/test/PUC-Rio-Lua-5.1-tests/db.lua
>> index 56f59ea8..f254cde6 100644
>> --- a/test/PUC-Rio-Lua-5.1-tests/db.lua
>> +++ b/test/PUC-Rio-Lua-5.1-tests/db.lua
>
><snipped>
>
>> --
>> 2.33.0
>>
>
>--
>Best regards,
>Sergey Kaplun
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20211109/e70820e8/attachment.htm>


More information about the Tarantool-patches mailing list