[Tarantool-patches] [PATCH luajit v3 03/29] test: adapt PUC-Rio suite for out-of-source build

Igor Munkin imun at tarantool.org
Wed Apr 14 00:05:14 MSK 2021


Sergey,

Thanks for the patch! LGTM with the following nits: I fixed them on your
branch[1] and guess no re-testing is needed.

On 13.04.21, Sergey Kaplun wrote:
> The redefined `dofile()` function failed to find the test file to load,
> when tests are run out-of-source. So, fullpath is detected considering
> `arg[0]` value. Moreover, some tests use `loadfile()` instead, so their
> argument has to be adjusted to the full path to the files.
> 
> Usage of functions invoking source test files was changed to
> `_loadfile()` and `_dofile()` correspondingly. They equal

Typo: s/They equal/They equal to/.

> `loadfile()` and `dofile()` by default and can be overloaded via running
> lua code from LUAJIT_TEST_INIT. This patch introduces the

Typo: s/lua/Lua/.

> <test/luajit-test-init.lua> file to be executed before tests and
> redefines the functions considering the path from `arg[0]` variable.
> 
> Part of tarantool/tarantool#5845
> Part of tarantool/tarantool#4473
> ---
>  CMakeLists.txt                     |  4 +--
>  test/PUC-Rio-Lua-5.1-tests/all.lua | 51 +++++++++++++++++-------------
>  test/luajit-test-init.lua          | 18 +++++++++++
>  3 files changed, 49 insertions(+), 24 deletions(-)
>  create mode 100644 test/luajit-test-init.lua
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index eb562923..df82d57c 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -302,8 +302,8 @@ set(LUAJIT_TEST_BINARY ${LUAJIT_BINARY} CACHE STRING
>  # tweaked, the introduced option can be used.
>  # XXX: The default behaviour is nop, so /dev/null is the best

Comment need to be adjusted.

>  # option for this.
> -set(LUAJIT_TEST_INIT "/dev/null" CACHE STRING
> -  "Lua code need to be run before tests are started. Default is nop."
> +set(LUAJIT_TEST_INIT "${PROJECT_SOURCE_DIR}/test/luajit-test-init.lua" CACHE STRING
> +  "Lua code need to be run before tests are started."
>  )
>  
>  add_subdirectory(test)

<snipped>

> diff --git a/test/luajit-test-init.lua b/test/luajit-test-init.lua
> new file mode 100644
> index 00000000..aadd15af
> --- /dev/null
> +++ b/test/luajit-test-init.lua
> @@ -0,0 +1,18 @@
> +-- XXX: PUC Rio Lua 5.1 test suite checks that global variable
> +-- `_loadfile()` exists and use it for code loading from test

Typo: s/use/uses/.

> +-- files If the variable is not defined then suite uses

Typo: s/files/files./.

> +-- `loadfile()` as default. Same for the `_dofile()`.
> +
> +-- XXX: Some tests in PUC Rio Lua 5.1 test suite clean `arg`
> +-- variable, so evaluate this once and use later.
> +local path_to_sources = arg[0]:gsub("[^/]+$", "")
> +
> +-- luacheck: no global
> +function _loadfile(filename)
> +  return loadfile(path_to_sources..filename)
> +end
> +
> +-- luacheck: no global
> +function _dofile(filename)
> +  return dofile(path_to_sources..filename)
> +end
> -- 
> 2.31.0
> 

[1]: https://github.com/tarantool/luajit/commit/c28985b

-- 
Best regards,
IM


More information about the Tarantool-patches mailing list