[Tarantool-patches] [PATCH v2 luajit 01/30] test: add PUC-Rio Lua 5.1 test suite

Igor Munkin imun at tarantool.org
Wed Mar 31 01:13:52 MSK 2021


Sergey,

Thanks for the patch! LGTM, except the nits below.

On 26.03.21, Sergey Kaplun wrote:
> This patch adds PUC-Rio Lua 5.1 test suite as a part of the LuaJIT test
> suite. Source code taken verbatim (except trailing whitespaces) from

Typo: s/code taken/code is taken/.
Typo: I believe it's always singular: whitespace.

> https://www.lua.org/tests/lua5.1-tests.tar.gz.
> 
> Some tests may fail after this commit. They will be disabled
> or adapted in the next patches.
> 
> Part of tarantool/tarantool#5845
> Part of tarantool/tarantool#4473
> ---
>  .luacheckrc                                |    5 +-
>  test/CMakeLists.txt                        |    2 +
>  test/PUC-Lua-5.1-tests/CMakeLists.txt      |   45 +
>  test/PUC-Lua-5.1-tests/README              |   41 +
>  test/PUC-Lua-5.1-tests/all.lua             |  137 +++
>  test/PUC-Lua-5.1-tests/api.lua             |  711 ++++++++++++
>  test/PUC-Lua-5.1-tests/attrib.lua          |  339 ++++++
>  test/PUC-Lua-5.1-tests/big.lua             |  381 +++++++
>  test/PUC-Lua-5.1-tests/calls.lua           |  294 +++++
>  test/PUC-Lua-5.1-tests/checktable.lua      |   77 ++
>  test/PUC-Lua-5.1-tests/closure.lua         |  422 +++++++
>  test/PUC-Lua-5.1-tests/code.lua            |  143 +++
>  test/PUC-Lua-5.1-tests/constructs.lua      |  240 ++++
>  test/PUC-Lua-5.1-tests/db.lua              |  499 +++++++++
>  test/PUC-Lua-5.1-tests/errors.lua          |  250 +++++
>  test/PUC-Lua-5.1-tests/etc/ltests.c        | 1147 ++++++++++++++++++++
>  test/PUC-Lua-5.1-tests/etc/ltests.h        |   92 ++
>  test/PUC-Lua-5.1-tests/events.lua          |  360 ++++++
>  test/PUC-Lua-5.1-tests/files.lua           |  324 ++++++
>  test/PUC-Lua-5.1-tests/gc.lua              |  312 ++++++
>  test/PUC-Lua-5.1-tests/libs/CMakeLists.txt |   18 +
>  test/PUC-Lua-5.1-tests/libs/lib1.c         |   40 +
>  test/PUC-Lua-5.1-tests/libs/lib11.c        |   18 +
>  test/PUC-Lua-5.1-tests/libs/lib2.c         |   28 +
>  test/PUC-Lua-5.1-tests/libs/lib21.c        |   18 +
>  test/PUC-Lua-5.1-tests/literals.lua        |  176 +++
>  test/PUC-Lua-5.1-tests/locals.lua          |  127 +++
>  test/PUC-Lua-5.1-tests/main.lua            |  159 +++
>  test/PUC-Lua-5.1-tests/math.lua            |  208 ++++
>  test/PUC-Lua-5.1-tests/nextvar.lua         |  396 +++++++
>  test/PUC-Lua-5.1-tests/pm.lua              |  273 +++++
>  test/PUC-Lua-5.1-tests/sort.lua            |   74 ++
>  test/PUC-Lua-5.1-tests/strings.lua         |  176 +++
>  test/PUC-Lua-5.1-tests/vararg.lua          |  126 +++
>  test/PUC-Lua-5.1-tests/verybig.lua         |  100 ++
>  35 files changed, 7756 insertions(+), 2 deletions(-)
>  create mode 100644 test/PUC-Lua-5.1-tests/CMakeLists.txt
>  create mode 100644 test/PUC-Lua-5.1-tests/README
>  create mode 100755 test/PUC-Lua-5.1-tests/all.lua

Minor: I doubt all.lua need to be an executable. Feel free to ignore.

>  create mode 100644 test/PUC-Lua-5.1-tests/api.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/attrib.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/big.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/calls.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/checktable.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/closure.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/code.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/constructs.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/db.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/errors.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/etc/ltests.c
>  create mode 100644 test/PUC-Lua-5.1-tests/etc/ltests.h
>  create mode 100644 test/PUC-Lua-5.1-tests/events.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/files.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/gc.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/libs/CMakeLists.txt
>  create mode 100644 test/PUC-Lua-5.1-tests/libs/lib1.c
>  create mode 100644 test/PUC-Lua-5.1-tests/libs/lib11.c
>  create mode 100644 test/PUC-Lua-5.1-tests/libs/lib2.c
>  create mode 100644 test/PUC-Lua-5.1-tests/libs/lib21.c
>  create mode 100644 test/PUC-Lua-5.1-tests/literals.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/locals.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/main.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/math.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/nextvar.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/pm.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/sort.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/strings.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/vararg.lua
>  create mode 100644 test/PUC-Lua-5.1-tests/verybig.lua
> 

<snipped>

> diff --git a/test/PUC-Lua-5.1-tests/CMakeLists.txt b/test/PUC-Lua-5.1-tests/CMakeLists.txt
> new file mode 100644
> index 0000000..773db0d
> --- /dev/null
> +++ b/test/PUC-Lua-5.1-tests/CMakeLists.txt
> @@ -0,0 +1,45 @@
> +# Test suite that has been added from PUC-Rio Lua 5.1 test archive
> +# in scope of https://github.com/tarantool/tarantool/issues/5845.
> +
> +# See the rationale in the root CMakeLists.txt.
> +cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
> +
> +# XXX: There are two ways to set up the proper environment
> +# described in the suite's README:
> +# * set LUA_PATH to "?;./?.lua"
> +# * or, better yet, set LUA_PATH to "./?.lua;;" and LUA_INIT to
> +#   "package.path = '?;'..package.path"
> +# Unfortunately, Tarantool doesn't support LUA_INIT and most
> +# likely it never will. For more info, see
> +# https://github.com/tarantool/tarantool/issues/5744
> +# Hence, there is no way other than set LUA_PATH environment
> +# variable as proposed in the first case.
> +set(LUA_PATH "?\;${CMAKE_CURRENT_SOURCE_DIR}/?.lua")
> +
> +# Set PUC-Lua-5.1-tests-prepare target that creates <libs/P1>

Minor: IMHO, "set" fits worse here than "create" or "introduce". Feel
free to ignore.

> +# subdirectory.
> +add_subdirectory(libs)
> +
> +# TODO: PUC-Rio Lua 5.1 test suite also has special header
> +# <ltests.h> and <ltests.c> translation unit to check some
> +# internal behaviour of the Lua implementation (see etc/
> +# directory). It modifies realloc function to check memory
> +# consistency and also contains tests for yield in hooks
> +# and for the Lua C API.
> +# But, unfortunately, <ltests.c> depends on specific PUC-Rio
> +# Lua 5.1 internal headers and should be adapted for LuaJIT.
> +
> +add_custom_target(PUC-Lua-5.1-tests
> +  DEPENDS ${LUAJIT_TEST_BINARY} PUC-Lua-5.1-tests-prepare
> +)
> +
> +add_custom_command(TARGET PUC-Lua-5.1-tests
> +  COMMENT "Running PUC-Rio Lua 5.1 tests"
> +  COMMAND
> +  env
> +    LUA_PATH="${LUA_PATH}\;\;"
> +    ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/all.lua
> +  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
> +)
> +
> +# vim: expandtab tabstop=2 shiftwidth=2

<snipped>

> diff --git a/test/PUC-Lua-5.1-tests/libs/CMakeLists.txt b/test/PUC-Lua-5.1-tests/libs/CMakeLists.txt
> new file mode 100644
> index 0000000..f24e7f3
> --- /dev/null
> +++ b/test/PUC-Lua-5.1-tests/libs/CMakeLists.txt
> @@ -0,0 +1,18 @@
> +# Test suite that has been added from PUC-Rio Lua 5.1 test archive
> +# in scope of https://github.com/tarantool/tarantool/issues/5845.
> +
> +# See the rationale in the root CMakeLists.txt.
> +cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
> +

Minor: What about TODO for building libs/*.c sources? Anyway, you did it
in the following patch, so feel free to ignore.

> +# The original tarball contains subdirectory "libs" with an empty
> +# subdirectory "libs/P1", to be used by tests.
> +# Instead of tracking empty directory with some anchor-file for
> +# git, create this directory via CMake.
> +add_custom_target(PUC-Lua-5.1-tests-prepare)
> +add_custom_command(TARGET PUC-Lua-5.1-tests-prepare
> +  COMMENT "Create directory for PUC-Rio Lua 5.1 tests"
> +  COMMAND ${CMAKE_COMMAND} -E make_directory P1
> +  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
> +)
> +
> +# vim: expandtab tabstop=2 shiftwidth=2

<snipped>

> -- 
> 2.31.0
> 

-- 
Best regards,
IM


More information about the Tarantool-patches mailing list