From: Maxim Kokryashkin via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Sergey Kaplun <skaplun@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests Date: Wed, 31 Jan 2024 14:48:52 +0300 [thread overview] Message-ID: <eigfvpvgnpwnh4624iqfqq57mdzxmu2vapo6s4uvu7dg5em3lt@3nxurnyboc6u> (raw) In-Reply-To: <5967cedfd0e3e597b34d9b873fba883c7a209518.1706520765.git.skaplun@tarantool.org> Hi, Sergey! Thanks for the patch! Please consider my comments below. On Mon, Jan 29, 2024 at 01:45:02PM +0300, Sergey Kaplun wrote: > This patch adds rules to build C and C++ libs from the > <LuaJIT-tests/src/> directory. Also, it allows these libraries to be > loaded via `require()` (since `luaL_openlib()` evolves global state). > The name of "ctest" library is changed to "libctest" to allow it to be > loaded via both `ffi.load()` and `require()`. "cpptest" library is > renamed to "libcpptest" for consistency. > > Part of tarantool/tarantool#9398 > --- > test/LuaJIT-tests/CMakeLists.txt | 29 +++++++++++++++++-- > test/LuaJIT-tests/src/CMakeLists.txt | 17 +++++++++++ > .../src/{cpptest.cpp => libcpptest.cpp} | 4 +-- > test/LuaJIT-tests/src/{ctest.c => libctest.c} | 4 +-- > test/LuaJIT-tests/test.lua | 7 +++-- > 5 files changed, 52 insertions(+), 9 deletions(-) > create mode 100644 test/LuaJIT-tests/src/CMakeLists.txt > rename test/LuaJIT-tests/src/{cpptest.cpp => libcpptest.cpp} (96%) > rename test/LuaJIT-tests/src/{ctest.c => libctest.c} (99%) > > diff --git a/test/LuaJIT-tests/CMakeLists.txt b/test/LuaJIT-tests/CMakeLists.txt > index 9cd76ee9..c52bcc71 100644 > --- a/test/LuaJIT-tests/CMakeLists.txt > +++ b/test/LuaJIT-tests/CMakeLists.txt > @@ -1,12 +1,35 @@ > # See the rationale in the root CMakeLists.txt > cmake_minimum_required(VERSION 3.1 FATAL_ERROR) > > -add_custom_target(LuaJIT-tests DEPENDS ${LUAJIT_TEST_BINARY}) > +add_subdirectory(src) > + > +add_custom_target(LuaJIT-tests > + DEPENDS ${LUAJIT_TEST_BINARY} LuaJIT-tests-prepare I think something like `LuaJIT-tests-libs` is better name for the target. > +) > + > +make_lua_path(LUA_CPATH > + PATHS > + ${CMAKE_CURRENT_BINARY_DIR}/src/?${CMAKE_SHARED_LIBRARY_SUFFIX} > +) > + > +set(LUAJIT_TESTS_ENV > + "LUA_CPATH=\"${LUA_CPATH}\"" IINM, outer quotes are redundant here. > +) > + > +set(LD_LIBRARY_PATH "${CMAKE_CURRENT_BINARY_DIR}/src/:") > + > +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") > + list(APPEND LUAJIT_TESTS_ENV DYLD_LIBRARY_PATH="${LD_LIBRARY_PATH}") > +else() > + list(APPEND LUAJIT_TESTS_ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}") > +endif() > > add_custom_command(TARGET LuaJIT-tests > COMMENT "Running LuaJIT-tests" > COMMAND > - ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua > - +slow +ffi +bit +jit > + env > + ${LUAJIT_TESTS_ENV} > + ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/test.lua > + +slow +ffi +bit +jit > WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} > ) > diff --git a/test/LuaJIT-tests/src/CMakeLists.txt b/test/LuaJIT-tests/src/CMakeLists.txt > new file mode 100644 > index 00000000..fb14d6d9 > --- /dev/null > +++ b/test/LuaJIT-tests/src/CMakeLists.txt > @@ -0,0 +1,17 @@ > +# See the rationale in the root CMakeLists.txt. > +cmake_minimum_required(VERSION 3.1 FATAL_ERROR) > + > +# Build additional C/C++ libraries for tests. > +macro(BuildTestLib lib sources) > + AddTestLib(${lib} ${sources}) > + list(APPEND TESTLIBS ${lib}) > +endmacro() See the comment about this macro in the previous patch. > + > +# Use `lib` prefix for loading via FFI and `require()`. > +BuildTestLib(libctest libctest.c) > +enable_language(CXX) > +BuildTestLib(libcpptest libcpptest.cpp) > + > +add_custom_target(LuaJIT-tests-prepare DEPENDS ${TESTLIBS}) > + > +# vim: expandtab tabstop=2 shiftwidth=2 Editor configuration should not be there. > diff --git a/test/LuaJIT-tests/src/cpptest.cpp b/test/LuaJIT-tests/src/libcpptest.cpp > similarity index 96% > rename from test/LuaJIT-tests/src/cpptest.cpp > rename to test/LuaJIT-tests/src/libcpptest.cpp > index a5893ed6..cdfb5e32 100644 > --- a/test/LuaJIT-tests/src/cpptest.cpp > +++ b/test/LuaJIT-tests/src/libcpptest.cpp > @@ -121,9 +121,9 @@ static luaL_Reg ct_funcs[] = { > }; > > extern "C" { > -LUA_API int luaopen_cpptest(lua_State *L) > +LUA_API int luaopen_libcpptest(lua_State *L) > { > - luaL_register(L, "cpptest", ct_funcs); > + luaL_register(L, "libcpptest", ct_funcs); > return 1; > } > } > diff --git a/test/LuaJIT-tests/src/ctest.c b/test/LuaJIT-tests/src/libctest.c > similarity index 99% > rename from test/LuaJIT-tests/src/ctest.c > rename to test/LuaJIT-tests/src/libctest.c > index e99f2306..aa95b57b 100644 > --- a/test/LuaJIT-tests/src/ctest.c > +++ b/test/LuaJIT-tests/src/libctest.c > @@ -332,8 +332,8 @@ static luaL_Reg ct_funcs[] = { > {NULL, NULL} > }; > > -LUA_API int luaopen_ctest(lua_State *L) > +LUA_API int luaopen_libctest(lua_State *L) > { > - luaL_register(L, "ctest", ct_funcs); > + luaL_register(L, "libctest", ct_funcs); > return 1; > } > diff --git a/test/LuaJIT-tests/test.lua b/test/LuaJIT-tests/test.lua > index b064eff7..f2450222 100644 > --- a/test/LuaJIT-tests/test.lua > +++ b/test/LuaJIT-tests/test.lua > @@ -297,8 +297,11 @@ local function append_tree_to_plan(test_tree, opts, plan, prefix) > end > > local function seal_globals() > - local sealed_mt = {__newindex = function() > - error("Tests should not mutate global state", 3) > + local sealed_mt = {__newindex = function(_, k) > + -- Allow to load C/C++ libraries for the test. > + if k ~= "libctest" and k ~= "libcpptest" then Let's change the `k` here to a more clear name. > + error("Tests should not mutate global state", 3) > + end > end} > local function seal(t) > if getmetatable(t) then return end > -- > 2.43.0 >
next prev parent reply other threads:[~2024-01-31 11:48 UTC|newest] Thread overview: 144+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-29 10:45 [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Kaplun via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 01/26] cmake: introduce AddTestLib macro Sergey Kaplun via Tarantool-patches 2024-01-31 11:25 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 11:23 ` Sergey Kaplun via Tarantool-patches 2024-02-09 14:48 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 14:20 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests Sergey Kaplun via Tarantool-patches 2024-01-31 11:48 ` Maxim Kokryashkin via Tarantool-patches [this message] 2024-02-06 11:24 ` Sergey Kaplun via Tarantool-patches 2024-02-09 14:50 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 14:23 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 03/26] test: separate LuaJIT helpers from ffi_util.inc Sergey Kaplun via Tarantool-patches 2024-01-31 11:58 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 11:47 ` Sergey Kaplun via Tarantool-patches 2024-02-09 14:51 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 15:45 ` Sergey Bronnikov via Tarantool-patches 2024-02-06 11:48 ` Sergey Kaplun via Tarantool-patches 2024-02-07 6:49 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 04/26] test: enable <ffi_arith_ptr.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches 2024-01-31 12:21 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 15:50 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 05/26] test: enable <ffi_bitfield.lua> " Sergey Kaplun via Tarantool-patches 2024-01-31 12:26 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 11:54 ` Sergey Kaplun via Tarantool-patches 2024-02-09 14:52 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 15:52 ` Sergey Bronnikov via Tarantool-patches 2024-02-06 11:55 ` Sergey Kaplun via Tarantool-patches 2024-02-07 6:50 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 06/26] test: enable <ffi_call.lua> " Sergey Kaplun via Tarantool-patches 2024-01-31 12:34 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 15:58 ` Sergey Bronnikov via Tarantool-patches 2024-02-06 12:01 ` Sergey Kaplun via Tarantool-patches 2024-02-07 6:50 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 07/26] test: enable <ffi_callback.lua> " Sergey Kaplun via Tarantool-patches 2024-01-31 13:02 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 16:01 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 08/26] test: enable <ffi_const.lua> " Sergey Kaplun via Tarantool-patches 2024-01-31 14:32 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 12:09 ` Sergey Kaplun via Tarantool-patches 2024-02-09 14:52 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 14:32 ` Sergey Bronnikov via Tarantool-patches 2024-02-06 12:10 ` Sergey Kaplun via Tarantool-patches 2024-02-07 6:52 ` Sergey Bronnikov via Tarantool-patches 2024-02-01 16:02 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 09/26] test: enable <ffi_convert.lua> " Sergey Kaplun via Tarantool-patches 2024-01-31 14:55 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 13:11 ` Sergey Kaplun via Tarantool-patches 2024-02-06 14:03 ` Sergey Kaplun via Tarantool-patches 2024-02-09 14:58 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 16:06 ` Sergey Bronnikov via Tarantool-patches 2024-02-06 13:13 ` Sergey Kaplun via Tarantool-patches 2024-02-01 16:19 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 10/26] test: enable <ffi_enum.lua> " Sergey Kaplun via Tarantool-patches 2024-01-31 14:59 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 16:07 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 11/26] test: enable <ffi_gcstep_recursive.lua> Sergey Kaplun via Tarantool-patches 2024-01-31 15:07 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 13:23 ` Sergey Kaplun via Tarantool-patches 2024-02-09 14:58 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 16:10 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 12/26] test: enable <ffi_jit_arith.lua> in LuaJIT-tests Sergey Kaplun via Tarantool-patches 2024-01-31 15:15 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 13:29 ` Sergey Kaplun via Tarantool-patches 2024-02-09 14:59 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 16:12 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 13/26] test: enable <ffi_jit_call.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 8:30 ` Maxim Kokryashkin via Tarantool-patches 2024-02-01 16:15 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 14/26] test: enable <ffi_jit_conv.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 8:32 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 12:51 ` Sergey Bronnikov via Tarantool-patches 2024-02-06 13:33 ` Sergey Kaplun via Tarantool-patches 2024-02-07 6:53 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 15/26] test: enable <ffi_lex_number.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 8:38 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 13:39 ` Sergey Kaplun via Tarantool-patches 2024-02-09 16:03 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 12:53 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 16/26] test: enable <ffi_metatype.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 8:40 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 12:58 ` Sergey Bronnikov via Tarantool-patches 2024-02-06 13:48 ` Sergey Kaplun via Tarantool-patches 2024-02-07 7:01 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 17/26] test: enable <ffi_new.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 8:43 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 13:55 ` Sergey Kaplun via Tarantool-patches 2024-02-09 16:09 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 13:03 ` Sergey Bronnikov via Tarantool-patches 2024-02-06 13:58 ` Sergey Kaplun via Tarantool-patches 2024-02-07 7:51 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 18/26] test: enable <ffi_parse_array.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 9:01 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 14:11 ` Sergey Kaplun via Tarantool-patches 2024-02-09 16:11 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 13:08 ` Sergey Bronnikov via Tarantool-patches 2024-02-06 14:12 ` Sergey Kaplun via Tarantool-patches 2024-02-07 8:04 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 19/26] test: enable <ffi_parse_basic.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 9:03 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 14:15 ` Sergey Kaplun via Tarantool-patches 2024-02-09 16:12 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 13:10 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 20/26] test: enable <ffi_parse_cdef.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 9:05 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 14:21 ` Sergey Kaplun via Tarantool-patches 2024-02-09 16:12 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 13:11 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 21/26] test: enable <ffi_parse_struct.lua> LuaJIT test Sergey Kaplun via Tarantool-patches 2024-02-01 9:16 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 14:23 ` Sergey Kaplun via Tarantool-patches 2024-02-09 16:13 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 13:14 ` Sergey Bronnikov via Tarantool-patches 2024-02-06 14:25 ` Sergey Kaplun via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 22/26] test: enable <ffi_tabov.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 9:19 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 14:37 ` Sergey Kaplun via Tarantool-patches 2024-02-09 16:13 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 13:20 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 23/26] test: enable <lightud.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 9:23 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 14:43 ` Sergey Kaplun via Tarantool-patches 2024-02-09 16:14 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 13:27 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 24/26] test: enable <api_call.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 9:25 ` Maxim Kokryashkin via Tarantool-patches 2024-02-06 14:44 ` Sergey Kaplun via Tarantool-patches 2024-02-09 16:15 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 13:28 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 25/26] test: enable <catch_wrap.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 9:31 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 13:32 ` Sergey Bronnikov via Tarantool-patches 2024-01-29 10:45 ` [Tarantool-patches] [PATCH v2 luajit 26/26] test: enable <catch_cpp.lua> " Sergey Kaplun via Tarantool-patches 2024-02-01 9:32 ` Maxim Kokryashkin via Tarantool-patches 2024-02-05 13:32 ` Sergey Bronnikov via Tarantool-patches 2024-02-01 16:32 ` [Tarantool-patches] [PATCH v2 luajit 00/26] More tests from LuaJIT-tests, part 1 Sergey Bronnikov via Tarantool-patches 2024-02-06 17:03 ` Sergey Kaplun via Tarantool-patches 2024-02-07 8:06 ` Sergey Bronnikov via Tarantool-patches 2024-02-07 8:14 ` Sergey Bronnikov via Tarantool-patches 2024-02-15 12:49 ` Sergey Kaplun via Tarantool-patches 2024-02-18 11:48 ` Maxim Kokryashkin via Tarantool-patches 2024-02-18 11:54 ` Sergey Kaplun via Tarantool-patches 2024-02-19 8:56 ` Maxim Kokryashkin via Tarantool-patches 2024-02-20 8:10 ` Sergey Bronnikov via Tarantool-patches 2024-02-28 18:25 ` Sergey Kaplun via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=eigfvpvgnpwnh4624iqfqq57mdzxmu2vapo6s4uvu7dg5em3lt@3nxurnyboc6u \ --to=tarantool-patches@dev.tarantool.org \ --cc=m.kokryashkin@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 luajit 02/26] test: prepare lauxilarily libs for LuaJIT-tests' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox