[Tarantool-patches] [PATCH luajit 03/36] test: refactor <lang/coroutine.lua> LuaJIT test

Sergey Bronnikov sergeyb at tarantool.org
Thu Aug 15 16:00:58 MSK 2024


Hi, Sergey!

Thanks for the patch! Please see my comments.

On 14.08.2024 16:55, Sergey Kaplun wrote:
> This patch refactors the <lang/coroutine.lua> test by adding a simple
> check for the content of a `debug.traceback()` result. Also, the test is
> moved to the <lib/coroutine/> directory.

The category for the test is debatable.

In fact, the test target is a function from `debug` module,

not coroutines.

>
> Also, it removes the <misc/coro_traceback.lua> since it is the same test
> that wasn't cleaned up during the refactoring in the original
> repository.
>
> Part of tarantool/tarantool#9398
> ---
>   test/LuaJIT-tests/lang/coroutine.lua          |  8 --------
>   test/LuaJIT-tests/lang/index                  |  1 -
>   test/LuaJIT-tests/lib/coroutine/index         |  1 +
>   test/LuaJIT-tests/lib/coroutine/traceback.lua | 14 ++++++++++++++
>   test/LuaJIT-tests/misc/coro_traceback.lua     |  8 --------
>   5 files changed, 15 insertions(+), 17 deletions(-)
>   delete mode 100644 test/LuaJIT-tests/lang/coroutine.lua
>   create mode 100644 test/LuaJIT-tests/lib/coroutine/traceback.lua
>   delete mode 100644 test/LuaJIT-tests/misc/coro_traceback.lua
>
> diff --git a/test/LuaJIT-tests/lang/coroutine.lua b/test/LuaJIT-tests/lang/coroutine.lua
> deleted file mode 100644
> index 405135c9..00000000
> --- a/test/LuaJIT-tests/lang/coroutine.lua
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -do --- traceback
> -  local co = coroutine.create(function()
> -    local x = nil
> -    local y = x.x
> -  end)
> -  assert(coroutine.resume(co) == false)
> -  debug.traceback(co)
> -end
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index 4ff7a297..803f32d8 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -14,7 +14,6 @@ concat.lua
>   self.lua
>   table.lua
>   upvalue
> -coroutine.lua
>   tail_recursion.lua
>   vararg_jit.lua
>   gc.lua
> diff --git a/test/LuaJIT-tests/lib/coroutine/index b/test/LuaJIT-tests/lib/coroutine/index
> index 9c5c17ec..c4dc6cf1 100644
> --- a/test/LuaJIT-tests/lib/coroutine/index
> +++ b/test/LuaJIT-tests/lib/coroutine/index
> @@ -1 +1,2 @@
> +traceback.lua
>   yield.lua
> diff --git a/test/LuaJIT-tests/lib/coroutine/traceback.lua b/test/LuaJIT-tests/lib/coroutine/traceback.lua
> new file mode 100644
> index 00000000..2b900ef1
> --- /dev/null
> +++ b/test/LuaJIT-tests/lib/coroutine/traceback.lua
> @@ -0,0 +1,14 @@
> +do --- traceback
> +  local function badfunc()
> +    local x = nil
> +    local y = x.x
> +  end
> +
> +  local co = coroutine.create(badfunc)
> +  assert(coroutine.resume(co) == false)
> +
> +  local traceback = debug.traceback(co)
> +  local line = debug.getinfo(badfunc).linedefined
> +
> +  assert(traceback:match('traceback:.*:' .. line))
> +end
> diff --git a/test/LuaJIT-tests/misc/coro_traceback.lua b/test/LuaJIT-tests/misc/coro_traceback.lua
> deleted file mode 100644
> index 2676d2c6..00000000
> --- a/test/LuaJIT-tests/misc/coro_traceback.lua
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -
> -local co = coroutine.create(function()
> -  local x = nil
> -  local y = x.x
> -end)
> -assert(coroutine.resume(co) == false)
> -debug.traceback(co)
> -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20240815/78f04fb9/attachment.htm>


More information about the Tarantool-patches mailing list