[Tarantool-patches] [PATCH luajit] test: adapt test checking global environment

Sergey Kaplun skaplun at tarantool.org
Tue Oct 5 20:37:06 MSK 2021


Hi, Maxim!

Thanks for the patch!
LGTM, with a few nitpicks below.

On 24.09.21, Maxim Kokryashkin wrote:
> LuaJIT doesn't take into account tail calls for
> call-level counting, so `getfenv()` behaviour is different
> in tail calls. getfenv()` default level is 1 which is invalid for
> the test case when is called from tail call (`lj_debug_frame()`
> returns NULL).
> 
> This commits adds local varible, so there is no tail call any more.

Typo: s/varible/variable/

> 
> Closes tarantool/tarantool#5713
> Part of tarantool/tarantool#5845

This issue is already closed via disabling the aforementioned test.
Just refer 5870 ticket instead.

> Part of tarantool/tarantool#4473

It is better to mention 5870 only. We want epics to stay clear, IINM.

> ---
> Issue: https://github.com/tarantool/tarantool/issues/5713
> GitHub branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio

Please, share the Tarantool branch with the patch to check that CI still
works :).

> 
>  test/PUC-Rio-Lua-5.1-tests/closure.lua | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/test/PUC-Rio-Lua-5.1-tests/closure.lua b/test/PUC-Rio-Lua-5.1-tests/closure.lua
> index 551fe70d..c0377179 100644
> --- a/test/PUC-Rio-Lua-5.1-tests/closure.lua
> +++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua
> @@ -167,22 +167,24 @@ local function foo (a)
>    assert(getfenv(0) == a)
>    assert(getfenv(1) == _G)
>    assert(getfenv(loadstring"") == a)
> -  return getfenv()

I suppose that we can move the comment here to explain the change.

> +  local env = getfenv()
> +  return env
>  end
>  
>  f = coroutine.wrap(foo)
>  local a = {}
>  assert(f(a) == _G)
>  local a,b = pcall(f)
> --- FIXME: LuaJIT doesn't take into account tail calls for
> +-- LuaJIT doesn't take into account tail calls for
>  -- call-level counting, so `getfenv()` behaviour is different
>  -- in tail calls. For example, this `pcall()` returns false,

Minor: returns false in case of tailcall, strictly saying, as far as you
change the function behaviour.

>  -- because `getfenv()` default level is 1 which is invalid for
>  -- this case when is called from tail call (`lj_debug_frame()`
>  -- returns NULL).
>  -- See also https://github.com/tarantool/tarantool/issues/5713.
> --- Test is disabled for LuaJIT for now.
> --- assert(a and b == _G)
> +
> +-- Test is adapted to the behavior LuaJIT.
> +assert(a and b == _G)
>  
>  
>  -- tests for multiple yield/resume arguments
> -- 
> 2.33.0
> 

[1]: https://github.com/tarantool/tarantool/issues/5870

-- 
Best regards,
Sergey Kaplun


More information about the Tarantool-patches mailing list