Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH luajit] test: adapt test checking global environment
@ 2021-10-06 13:04 Maxim Kokryashkin via Tarantool-patches
  2021-12-16 14:34 ` Sergey Kaplun via Tarantool-patches
  2022-02-17 16:34 ` Igor Munkin via Tarantool-patches
  0 siblings, 2 replies; 9+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2021-10-06 13:04 UTC (permalink / raw)
  To: tarantool-patches, imun, skaplun, m.shishatskiy

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 varibles, so there is no tail call any more.

Part of tarantool/tarantool#5870
---
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
CI: https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio

 test/PUC-Rio-Lua-5.1-tests/closure.lua | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 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..86f6ad87 100644
--- a/test/PUC-Rio-Lua-5.1-tests/closure.lua
+++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua
@@ -167,22 +167,23 @@ local function foo (a)
   assert(getfenv(0) == a)
   assert(getfenv(1) == _G)
   assert(getfenv(loadstring"") == a)
-  return getfenv()
+
+-- LuaJIT doesn't take into account tail calls for
+-- call-level counting, so `getfenv()` behaviour is different
+-- in tail calls. For example, `pcall()` to this functon returns false
+-- in case of tailcall, because `getfenv()` default level is 1 which
+-- is invalid for this case (`lj_debug_frame()` returns NULL).
+-- See also https://github.com/tarantool/tarantool/issues/5713.
+  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
--- call-level counting, so `getfenv()` behaviour is different
--- in tail calls. For example, this `pcall()` returns false,
--- 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. See the comment above.
+assert(a and b == _G)
 
 
 -- tests for multiple yield/resume arguments
-- 
2.33.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit] test: adapt test checking global environment
  2021-10-06 13:04 [Tarantool-patches] [PATCH luajit] test: adapt test checking global environment Maxim Kokryashkin via Tarantool-patches
@ 2021-12-16 14:34 ` Sergey Kaplun via Tarantool-patches
  2022-01-17 23:42   ` Максим Корякшин via Tarantool-patches
  2022-01-17 23:43   ` Максим Корякшин via Tarantool-patches
  2022-02-17 16:34 ` Igor Munkin via Tarantool-patches
  1 sibling, 2 replies; 9+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2021-12-16 14:34 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Hi, Maxim!

Thanks for the fixes!

LGTM, except a few nits below.

On 06.10.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 varibles, so there is no tail call any more.

Typo: s/varibles/variables/

> 
> Part of tarantool/tarantool#5870

It's OK to mention that this patch "Resolves tarantool/tarantool#5713".

> ---
> 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
> CI: https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio
> 
>  test/PUC-Rio-Lua-5.1-tests/closure.lua | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 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..86f6ad87 100644
> --- a/test/PUC-Rio-Lua-5.1-tests/closure.lua
> +++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua
> @@ -167,22 +167,23 @@ local function foo (a)
>    assert(getfenv(0) == a)
>    assert(getfenv(1) == _G)
>    assert(getfenv(loadstring"") == a)
> -  return getfenv()
> +
> +-- LuaJIT doesn't take into account tail calls for
> +-- call-level counting, so `getfenv()` behaviour is different
> +-- in tail calls. For example, `pcall()` to this functon returns false
> +-- in case of tailcall, because `getfenv()` default level is 1 which
> +-- is invalid for this case (`lj_debug_frame()` returns NULL).
> +-- See also https://github.com/tarantool/tarantool/issues/5713.

Minor: linewidth for comments is 66 symbols.

> +  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
> --- call-level counting, so `getfenv()` behaviour is different
> --- in tail calls. For example, this `pcall()` returns false,
> --- 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. See the comment above.
> +assert(a and b == _G)
>  
>  
>  -- tests for multiple yield/resume arguments
> -- 
> 2.33.0
> 

-- 
Best regards,
Sergey Kaplun

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Tarantool-patches]  [PATCH luajit] test: adapt test checking global environment
  2021-12-16 14:34 ` Sergey Kaplun via Tarantool-patches
@ 2022-01-17 23:42   ` Максим Корякшин via Tarantool-patches
  2022-01-26 22:33     ` Igor Munkin via Tarantool-patches
  2022-01-17 23:43   ` Максим Корякшин via Tarantool-patches
  1 sibling, 1 reply; 9+ messages in thread
From: Максим Корякшин via Tarantool-patches @ 2022-01-17 23:42 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: Maxim Kokryashkin, tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 4616 bytes --]


Hello, Sergey!
Thanks for the review!
 
Here is the new commit message:
================================================================================
test: adapt test checking global environment
 
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 variables, so there is no tail call any more.
 
Part of tarantool/tarantool#5870
Resolves tarantool/tarantool#5713
================================================================================
 
And the diff for the comment fix:
================================================================================
diff --git a/test/PUC-Rio-Lua-5.1-tests/closure.lua b/test/PUC-Rio-Lua-5.1-tests/closure.lua
index 86f6ad87..c4491dcf 100644
--- a/test/PUC-Rio-Lua-5.1-tests/closure.lua
+++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua
@@ -170,9 +170,10 @@ local function foo (a)
 
 -- LuaJIT doesn't take into account tail calls for
 -- call-level counting, so `getfenv()` behaviour is different
--- in tail calls. For example, `pcall()` to this functon returns false
--- in case of tailcall, because `getfenv()` default level is 1 which
--- is invalid for this case (`lj_debug_frame()` returns NULL).
+-- in tail calls. For example, `pcall()` to this functon returns
+-- false in case of tailcall, because `getfenv()` default level
+-- is 1 which is invalid for this case (`lj_debug_frame()`
+-- returns NULL).
 -- See also https://github.com/tarantool/tarantool/issues/5713.
   local env = getfenv()
   return env
================================================================================
 
Best regards,
Maxim Kokryashkin
 
> 
>>Hi, Maxim!
>>
>>Thanks for the fixes!
>>
>>LGTM, except a few nits below.
>>
>>On 06.10.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 varibles, so there is no tail call any more.
>>
>>Typo: s/varibles/variables/
>>
>>>
>>> Part of tarantool/tarantool#5870
>>
>>It's OK to mention that this patch "Resolves tarantool/tarantool#5713".
>>
>>> ---
>>> 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
>>> CI:  https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio
>>>
>>> test/PUC-Rio-Lua-5.1-tests/closure.lua | 21 +++++++++++----------
>>> 1 file changed, 11 insertions(+), 10 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..86f6ad87 100644
>>> --- a/test/PUC-Rio-Lua-5.1-tests/closure.lua
>>> +++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua
>>> @@ -167,22 +167,23 @@ local function foo (a)
>>> assert(getfenv(0) == a)
>>> assert(getfenv(1) == _G)
>>> assert(getfenv(loadstring"") == a)
>>> - return getfenv()
>>> +
>>> +-- LuaJIT doesn't take into account tail calls for
>>> +-- call-level counting, so `getfenv()` behaviour is different
>>> +-- in tail calls. For example, `pcall()` to this functon returns false
>>> +-- in case of tailcall, because `getfenv()` default level is 1 which
>>> +-- is invalid for this case (`lj_debug_frame()` returns NULL).
>>> +-- See also  https://github.com/tarantool/tarantool/issues/5713 .
>>
>>Minor: linewidth for comments is 66 symbols.
>>
>>> + 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
>>> --- call-level counting, so `getfenv()` behaviour is different
>>> --- in tail calls. For example, this `pcall()` returns false,
>>> --- 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. See the comment above.
>>> +assert(a and b == _G)
>>>
>>>
>>> -- tests for multiple yield/resume arguments
>>> --
>>> 2.33.0
>>>
>>
>>--
>>Best regards,
>>Sergey Kaplun
> 

[-- Attachment #2: Type: text/html, Size: 6269 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Tarantool-patches]  [PATCH luajit] test: adapt test checking global environment
  2021-12-16 14:34 ` Sergey Kaplun via Tarantool-patches
  2022-01-17 23:42   ` Максим Корякшин via Tarantool-patches
@ 2022-01-17 23:43   ` Максим Корякшин via Tarantool-patches
  1 sibling, 0 replies; 9+ messages in thread
From: Максим Корякшин via Tarantool-patches @ 2022-01-17 23:43 UTC (permalink / raw)
  To: Sergey Kaplun; +Cc: Maxim Kokryashkin, tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 2925 bytes --]


New CI branch:  https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio-full-ci
 
 
> 
>>Hi, Maxim!
>>
>>Thanks for the fixes!
>>
>>LGTM, except a few nits below.
>>
>>On 06.10.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 varibles, so there is no tail call any more.
>>
>>Typo: s/varibles/variables/
>>
>>>
>>> Part of tarantool/tarantool#5870
>>
>>It's OK to mention that this patch "Resolves tarantool/tarantool#5713".
>>
>>> ---
>>> 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
>>> CI:  https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio
>>>
>>> test/PUC-Rio-Lua-5.1-tests/closure.lua | 21 +++++++++++----------
>>> 1 file changed, 11 insertions(+), 10 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..86f6ad87 100644
>>> --- a/test/PUC-Rio-Lua-5.1-tests/closure.lua
>>> +++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua
>>> @@ -167,22 +167,23 @@ local function foo (a)
>>> assert(getfenv(0) == a)
>>> assert(getfenv(1) == _G)
>>> assert(getfenv(loadstring"") == a)
>>> - return getfenv()
>>> +
>>> +-- LuaJIT doesn't take into account tail calls for
>>> +-- call-level counting, so `getfenv()` behaviour is different
>>> +-- in tail calls. For example, `pcall()` to this functon returns false
>>> +-- in case of tailcall, because `getfenv()` default level is 1 which
>>> +-- is invalid for this case (`lj_debug_frame()` returns NULL).
>>> +-- See also  https://github.com/tarantool/tarantool/issues/5713 .
>>
>>Minor: linewidth for comments is 66 symbols.
>>
>>> + 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
>>> --- call-level counting, so `getfenv()` behaviour is different
>>> --- in tail calls. For example, this `pcall()` returns false,
>>> --- 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. See the comment above.
>>> +assert(a and b == _G)
>>>
>>>
>>> -- tests for multiple yield/resume arguments
>>> --
>>> 2.33.0
>>>
>>
>>--
>>Best regards,
>>Sergey Kaplun
> 

[-- Attachment #2: Type: text/html, Size: 4191 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit] test: adapt test checking global environment
  2022-01-17 23:42   ` Максим Корякшин via Tarantool-patches
@ 2022-01-26 22:33     ` Igor Munkin via Tarantool-patches
  2022-02-07  9:32       ` Максим Корякшин via Tarantool-patches
  0 siblings, 1 reply; 9+ messages in thread
From: Igor Munkin via Tarantool-patches @ 2022-01-26 22:33 UTC (permalink / raw)
  To: Максим
	Корякшин
  Cc: Maxim Kokryashkin, tarantool-patches

Max,

Thanks for the patch!

LGTM, except a couple of typos.

On 18.01.22, Максим Корякшин wrote:
> 
> Hello, Sergey!
> Thanks for the review!
>  
> Here is the new commit message:
> ================================================================================
> test: adapt test checking global environment
>  
> 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

Typo: s/getfenv()`/`getfenv()`/.

> the test case when is called from tail call (`lj_debug_frame()`
> returns NULL).
>  
> This commits adds local variables, so there is no tail call any more.
>  
> Part of tarantool/tarantool#5870
> Resolves tarantool/tarantool#5713

Typo: "Resolves" should go prior to all other GitHub tags ("Part of" in
our case).

> ================================================================================
>  
> And the diff for the comment fix:
> ================================================================================
> diff --git a/test/PUC-Rio-Lua-5.1-tests/closure.lua b/test/PUC-Rio-Lua-5.1-tests/closure.lua
> index 86f6ad87..c4491dcf 100644
> --- a/test/PUC-Rio-Lua-5.1-tests/closure.lua
> +++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua
> @@ -170,9 +170,10 @@ local function foo (a)
>  
>  -- LuaJIT doesn't take into account tail calls for
>  -- call-level counting, so `getfenv()` behaviour is different
> --- in tail calls. For example, `pcall()` to this functon returns false
> --- in case of tailcall, because `getfenv()` default level is 1 which
> --- is invalid for this case (`lj_debug_frame()` returns NULL).
> +-- in tail calls. For example, `pcall()` to this functon returns

Typo: s/functon/function/.

> +-- false in case of tailcall, because `getfenv()` default level

Typo: "tailcall", but "tail calls". Please choose one option for
consistency (at least within a single comment).

> +-- is 1 which is invalid for this case (`lj_debug_frame()`
> +-- returns NULL).
>  -- See also https://github.com/tarantool/tarantool/issues/5713.
>    local env = getfenv()
>    return env
> ================================================================================
>  
> Best regards,
> Maxim Kokryashkin
>  
> > 
> >>Hi, Maxim!
> >>
> >>Thanks for the fixes!
> >>
> >>LGTM, except a few nits below.
> >>
> >>On 06.10.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 varibles, so there is no tail call any more.
> >>
> >>Typo: s/varibles/variables/
> >>
> >>>
> >>> Part of tarantool/tarantool#5870
> >>
> >>It's OK to mention that this patch "Resolves tarantool/tarantool#5713".
> >>
> >>> ---
> >>> 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
> >>> CI:  https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio
> >>>
> >>> test/PUC-Rio-Lua-5.1-tests/closure.lua | 21 +++++++++++----------
> >>> 1 file changed, 11 insertions(+), 10 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..86f6ad87 100644
> >>> --- a/test/PUC-Rio-Lua-5.1-tests/closure.lua
> >>> +++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua
> >>> @@ -167,22 +167,23 @@ local function foo (a)
> >>> assert(getfenv(0) == a)
> >>> assert(getfenv(1) == _G)
> >>> assert(getfenv(loadstring"") == a)
> >>> - return getfenv()
> >>> +
> >>> +-- LuaJIT doesn't take into account tail calls for
> >>> +-- call-level counting, so `getfenv()` behaviour is different
> >>> +-- in tail calls. For example, `pcall()` to this functon returns false
> >>> +-- in case of tailcall, because `getfenv()` default level is 1 which
> >>> +-- is invalid for this case (`lj_debug_frame()` returns NULL).
> >>> +-- See also  https://github.com/tarantool/tarantool/issues/5713 .
> >>
> >>Minor: linewidth for comments is 66 symbols.
> >>
> >>> + 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
> >>> --- call-level counting, so `getfenv()` behaviour is different
> >>> --- in tail calls. For example, this `pcall()` returns false,
> >>> --- 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. See the comment above.

Typo: either s/behavior LuaJIT/LuaJIT behavior/ or
s/behavior LuaJIT/behavior of LuaJIT/ for this case.

> >>> +assert(a and b == _G)
> >>>
> >>>
> >>> -- tests for multiple yield/resume arguments
> >>> --
> >>> 2.33.0
> >>>
> >>
> >>--
> >>Best regards,
> >>Sergey Kaplun
> > 

-- 
Best regards,
IM

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Tarantool-patches]  [PATCH luajit] test: adapt test checking global environment
  2022-01-26 22:33     ` Igor Munkin via Tarantool-patches
@ 2022-02-07  9:32       ` Максим Корякшин via Tarantool-patches
  0 siblings, 0 replies; 9+ messages in thread
From: Максим Корякшин via Tarantool-patches @ 2022-02-07  9:32 UTC (permalink / raw)
  To: Igor Munkin; +Cc: Maxim Kokryashkin, tarantool-patches

[-- Attachment #1: Type: text/plain, Size: 7634 bytes --]


Hi, Igor!
Thanks for the review!
 
Here is the new commit message:
================================================================================
test: adapt test checking global environment
 
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 variables, so there is no tail call any more.
 
Resolves tarantool/tarantool#5713
Part of tarantool/tarantool#5870
================================================================================
 
And here is the diff:
================================================================================
diff --git a/test/PUC-Rio-Lua-5.1-tests/closure.lua b/test/PUC-Rio-Lua-5.1-tests/closure.lua
index c4491dcf..291c1ede 100644
--- a/test/PUC-Rio-Lua-5.1-tests/closure.lua
+++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua
@@ -170,8 +170,8 @@ local function foo (a)
 
 -- LuaJIT doesn't take into account tail calls for
 -- call-level counting, so `getfenv()` behaviour is different
--- in tail calls. For example, `pcall()` to this functon returns
--- false in case of tailcall, because `getfenv()` default level
+-- in tail calls. For example, `pcall()` to this function returns
+-- false in case of tail calls, because `getfenv()` default level
 -- is 1 which is invalid for this case (`lj_debug_frame()`
 -- returns NULL).
 -- See also https://github.com/tarantool/tarantool/issues/5713.
@@ -183,7 +183,7 @@ f = coroutine.wrap(foo)
 local a = {}
 assert(f(a) == _G)
 local a,b = pcall(f)
--- Test is adapted to the behavior LuaJIT. See the comment above.
+-- Test is adapted to the LuaJIT behavior. See the comment above.
 assert(a and b == _G)
================================================================================
 
Best regards,
Maxim Kokryashkin
> 
>>Max,
>>
>>Thanks for the patch!
>>
>>LGTM, except a couple of typos.
>>
>>On 18.01.22, Максим Корякшин wrote:
>>>
>>> Hello, Sergey!
>>> Thanks for the review!
>>>  
>>> Here is the new commit message:
>>> ================================================================================
>>> test: adapt test checking global environment
>>>  
>>> 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
>>
>>Typo: s/getfenv()`/`getfenv()`/.
>>
>>> the test case when is called from tail call (`lj_debug_frame()`
>>> returns NULL).
>>>  
>>> This commits adds local variables, so there is no tail call any more.
>>>  
>>> Part of tarantool/tarantool#5870
>>> Resolves tarantool/tarantool#5713
>>
>>Typo: "Resolves" should go prior to all other GitHub tags ("Part of" in
>>our case).
>>
>>> ================================================================================
>>>  
>>> And the diff for the comment fix:
>>> ================================================================================
>>> diff --git a/test/PUC-Rio-Lua-5.1-tests/closure.lua b/test/PUC-Rio-Lua-5.1-tests/closure.lua
>>> index 86f6ad87..c4491dcf 100644
>>> --- a/test/PUC-Rio-Lua-5.1-tests/closure.lua
>>> +++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua
>>> @@ -170,9 +170,10 @@ local function foo (a)
>>>  
>>>  -- LuaJIT doesn't take into account tail calls for
>>>  -- call-level counting, so `getfenv()` behaviour is different
>>> --- in tail calls. For example, `pcall()` to this functon returns false
>>> --- in case of tailcall, because `getfenv()` default level is 1 which
>>> --- is invalid for this case (`lj_debug_frame()` returns NULL).
>>> +-- in tail calls. For example, `pcall()` to this functon returns
>>
>>Typo: s/functon/function/.
>>
>>> +-- false in case of tailcall, because `getfenv()` default level
>>
>>Typo: "tailcall", but "tail calls". Please choose one option for
>>consistency (at least within a single comment).
>>
>>> +-- is 1 which is invalid for this case (`lj_debug_frame()`
>>> +-- returns NULL).
>>>  -- See also  https://github.com/tarantool/tarantool/issues/5713 .
>>>    local env = getfenv()
>>>    return env
>>> ================================================================================
>>>  
>>> Best regards,
>>> Maxim Kokryashkin
>>>  
>>> > 
>>> >>Hi, Maxim!
>>> >>
>>> >>Thanks for the fixes!
>>> >>
>>> >>LGTM, except a few nits below.
>>> >>
>>> >>On 06.10.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 varibles, so there is no tail call any more.
>>> >>
>>> >>Typo: s/varibles/variables/
>>> >>
>>> >>>
>>> >>> Part of tarantool/tarantool#5870
>>> >>
>>> >>It's OK to mention that this patch "Resolves tarantool/tarantool#5713".
>>> >>
>>> >>> ---
>>> >>> 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
>>> >>> CI:  https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio
>>> >>>
>>> >>> test/PUC-Rio-Lua-5.1-tests/closure.lua | 21 +++++++++++----------
>>> >>> 1 file changed, 11 insertions(+), 10 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..86f6ad87 100644
>>> >>> --- a/test/PUC-Rio-Lua-5.1-tests/closure.lua
>>> >>> +++ b/test/PUC-Rio-Lua-5.1-tests/closure.lua
>>> >>> @@ -167,22 +167,23 @@ local function foo (a)
>>> >>> assert(getfenv(0) == a)
>>> >>> assert(getfenv(1) == _G)
>>> >>> assert(getfenv(loadstring"") == a)
>>> >>> - return getfenv()
>>> >>> +
>>> >>> +-- LuaJIT doesn't take into account tail calls for
>>> >>> +-- call-level counting, so `getfenv()` behaviour is different
>>> >>> +-- in tail calls. For example, `pcall()` to this functon returns false
>>> >>> +-- in case of tailcall, because `getfenv()` default level is 1 which
>>> >>> +-- is invalid for this case (`lj_debug_frame()` returns NULL).
>>> >>> +-- See also  https://github.com/tarantool/tarantool/issues/5713 .
>>> >>
>>> >>Minor: linewidth for comments is 66 symbols.
>>> >>
>>> >>> + 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
>>> >>> --- call-level counting, so `getfenv()` behaviour is different
>>> >>> --- in tail calls. For example, this `pcall()` returns false,
>>> >>> --- 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. See the comment above.
>>
>>Typo: either s/behavior LuaJIT/LuaJIT behavior/ or
>>s/behavior LuaJIT/behavior of LuaJIT/ for this case.
>>
>>> >>> +assert(a and b == _G)
>>> >>>
>>> >>>
>>> >>> -- tests for multiple yield/resume arguments
>>> >>> --
>>> >>> 2.33.0
>>> >>>
>>> >>
>>> >>--
>>> >>Best regards,
>>> >>Sergey Kaplun
>>> > 
>>
>>--
>>Best regards,
>>IM
> 

[-- Attachment #2: Type: text/html, Size: 10417 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit] test: adapt test checking global environment
  2021-10-06 13:04 [Tarantool-patches] [PATCH luajit] test: adapt test checking global environment Maxim Kokryashkin via Tarantool-patches
  2021-12-16 14:34 ` Sergey Kaplun via Tarantool-patches
@ 2022-02-17 16:34 ` Igor Munkin via Tarantool-patches
  1 sibling, 0 replies; 9+ messages in thread
From: Igor Munkin via Tarantool-patches @ 2022-02-17 16:34 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

Max,

I've checked the patch into all long-term branches in tarantool/luajit
and bumped a new version in 1.10, 2.8 and master.

On 06.10.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 varibles, so there is no tail call any more.
> 
> Part of tarantool/tarantool#5870
> ---
> 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
> CI: https://github.com/tarantool/tarantool/tree/fckxorg/gh-5713-adapt-test-global-environment-PUC-Rio
> 
>  test/PUC-Rio-Lua-5.1-tests/closure.lua | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 

<snipped>

> -- 
> 2.33.0
> 

-- 
Best regards,
IM

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Tarantool-patches] [PATCH luajit] test: adapt test checking global environment
  2021-09-24 18:20 Maxim Kokryashkin via Tarantool-patches
@ 2021-10-05 17:37 ` Sergey Kaplun via Tarantool-patches
  0 siblings, 0 replies; 9+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2021-10-05 17:37 UTC (permalink / raw)
  To: Maxim Kokryashkin; +Cc: tarantool-patches

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Tarantool-patches] [PATCH luajit] test: adapt test checking global environment
@ 2021-09-24 18:20 Maxim Kokryashkin via Tarantool-patches
  2021-10-05 17:37 ` Sergey Kaplun via Tarantool-patches
  0 siblings, 1 reply; 9+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2021-09-24 18:20 UTC (permalink / raw)
  To: tarantool-patches, imun, skaplun

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.

Closes tarantool/tarantool#5713
Part of tarantool/tarantool#5845
Part of tarantool/tarantool#4473
---
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

 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()
+  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,
 -- 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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-02-17 16:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 13:04 [Tarantool-patches] [PATCH luajit] test: adapt test checking global environment Maxim Kokryashkin via Tarantool-patches
2021-12-16 14:34 ` Sergey Kaplun via Tarantool-patches
2022-01-17 23:42   ` Максим Корякшин via Tarantool-patches
2022-01-26 22:33     ` Igor Munkin via Tarantool-patches
2022-02-07  9:32       ` Максим Корякшин via Tarantool-patches
2022-01-17 23:43   ` Максим Корякшин via Tarantool-patches
2022-02-17 16:34 ` Igor Munkin via Tarantool-patches
  -- strict thread matches above, loose matches on Subject: below --
2021-09-24 18:20 Maxim Kokryashkin via Tarantool-patches
2021-10-05 17:37 ` Sergey Kaplun via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox