From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 953296EC56; Wed, 17 Mar 2021 17:55:49 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 953296EC56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1615992949; bh=QjN9VG0W5aSR8oCCEAYarrnB/BGBaifF+rA6N6zahZ8=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UxHKMAWzIDKiBgXmQ3hh+6xilnfi6o5tYkZytM39rhHJzSZoo2cEZHHwnm2cRCu3N Yn82blIvLxLQ+MKciAz7sUsCeiZZd0ZtgxTH/wNhnaYJFtzVaoK5YCEASxyXeP1cPI I8QxZKvDu71vj8mGqQ5kY/RzF9HECZ1WJsnlmDv0= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 514806EC56 for ; Wed, 17 Mar 2021 17:55:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 514806EC56 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lMXaM-00022O-Ff; Wed, 17 Mar 2021 17:55:47 +0300 Date: Wed, 17 Mar 2021 17:55:38 +0300 To: Sergey Kaplun Message-ID: <20210317145538.GB29703@tarantool.org> References: <19e526eec5407d656bbb667870a7a2527ab509a7.1615472551.git.skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <19e526eec5407d656bbb667870a7a2527ab509a7.1615472551.git.skaplun@tarantool.org> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.10.1 (2018-07-13) X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD96485A7A9FC1318933D9BB3A6B6EC3969033B83865BA14179182A05F538085040FB7E81685A6358A9A2D13C65B852E67934AD4DFB55DA47C0735A777D96314C6A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7E245C2B74AF15DC8EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063788758EA7442DD2858638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95CF89CA98302ED496FCFF8B054AA5612BE2CCD3464C08D605DA471835C12D1D9774AD6D5ED66289B5278DA827A17800CE71AE4D56B06699BBC9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C327ED053E960B195E117882F4460429728AD0CFFFB425014E868A13BD56FB6657A7F4EDE966BC389F9E8FC8737B5C224902CFACCC19C6E7D3089D37D7C0E48F6CCF19DD082D7633A0E7DDDDC251EA7DABAAAE862A0553A39223F8577A6DFFEA7CE1AEB6AF2DA18B6243847C11F186F3C5E7DDDDC251EA7DABCC89B49CDF41148FA8EF81845B15A4842623479134186CDE6BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A521116CACD24A67663A42E0A0FDE502B9E5EEEEC6739A985CD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75F04B387B5D7535DE410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3468964757141B82E0AC0C49DF46CB9A2A827C5FF21F566FD7AE3BB5A436EF181B9D58F368A426E06C1D7E09C32AA3244CD0973AFC7D75FC6F564CD586372FC1EC1DD47778AE04E04D927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojwV/GgY7Z4vVnSCRAQMLzmA== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822B04F4BB70AEC595B7C27E67CB4260F8EA7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/3] test: add PUC-Rio Lua 5.1 test suite X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sergey, Thanks for the patch! On 12.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 from Unfortunately, this is not true. Consider the following: | $ md5sum lua5.1-tests.tar.gz | b376d315ada7bd9d379ec820d6cc27ed lua5.1-tests.tar.gz | <...> | $ pwd | /lua5.1-tests | $ find . -type f | sort | xargs md5sum > ~/vanilla | <...> | $ pwd | /tarantool-luajit/test/PUC-Lua-5.1-tests | $ git remote -v | origin git@github.com:tarantool/luajit (fetch) | origin git@github.com:tarantool/luajit (push) | $ git lo -1 | 19e526e (HEAD) test: add PUC-Rio Lua 5.1 test suite | $ find . -type f | sort | xargs md5sum > ~/tarantool | $ diff ~/vanilla ~/tarantool | 2,3c2,3 | < 70085c31a4cd70096dea1636e8fb3d9d ./api.lua | < b863b536cfb6114ec70d846c2f2c1a5f ./attrib.lua | --- | > 9e9888c13bce8de45b470370cb6f5d11 ./api.lua | > f2e3148cbdacf6bd8a06c1744dea3a16 ./attrib.lua | 7,12c7,13 | < 428b214012380dbb8922b70f8e3a174f ./closure.lua | < 580aeb1bf3efd526c8b62efcbb7b7ff2 ./code.lua | < f11d5bc5a7809d5d34a4fe0b0a86905b ./constructs.lua | < 29c56553a51f06ec14ebd45ea2789eaa ./db.lua | < 62ef206224896aac4e5998f78305083a ./errors.lua | < 2b2a4688858d7b01ead2d94217705c4f ./etc/ltests.c | --- | > 2fe3dc8ae11397c08c8343cad6f251ab ./closure.lua | > cbeb7f7013161dd2d558a7b1adc77327 ./CMakeLists.txt | > d72539840341a07aae459cac9991e41f ./code.lua | > 0f0bdf9e2e0cf758e0e76600f7afc700 ./constructs.lua | > 596f4340c66fd9f0ff6ecacef955ade0 ./db.lua | > a2b968868f2d4b7165f561076639c98b ./errors.lua | > 2b901df9ba9024f0279a7bbfeaf47f1f ./etc/ltests.c | 15c16 | < fae357bb29cc0ea5ec380a2678674330 ./files.lua | --- | > 77d39dbfac5abc7a9dcd8e9595ccf517 ./files.lua | 18c19 | < b0536a009fd46b3c54759ce447883cd8 ./libs/lib1.c | --- | > 1efd07d7bd4efe1b334cc3e11ce83115 ./libs/lib1.c | 20,21c21 | < e27b1cfafb3a4f60cee764beaa761059 ./libs/lib2.c | < aa964093a6483e66e434a5ae22816a24 ./libs/makefile | --- | > b2ac9185c54826707cce0ab1bbfb1289 ./libs/lib2.c | 23,24c23,24 | < e3c8a3668564606e8387ce695229c24f ./locals.lua | < a83fe79ec8c8c21dac7ee4f882344178 ./main.lua | --- | > e3fdc6da784973cf96d19861f79908b3 ./locals.lua | > f99dc272fedc3e9bf21344f06e6fa6b7 ./main.lua | 26c26 | < 41119d8062a9f66b89c30b4ff87a7a1f ./nextvar.lua | --- | > 52e9e6bbac229d72a46672aff5e84874 ./nextvar.lua Well, as you mentioned in the cover letter, you removed the trailing whitespace. Just for the history, I collected everything to the list: * api.lua: 1 occurrence * attrib.lua: 1 occurrence * closure.lua: 1 occurrence * code.lua: 1 occurrence * constructs.lua: 2 occurrences * db.lua: 4 occurrences * errors.lua: 2 occurrences * etc/ltests.c: 3 occurrences * files.lua: 3 occurrences * lib/lib1.c: 2 occurrences + luaL_reg fix * lib/lib2.c: luaL_reg fix * locals.lua: 2 occurrences * main.lua: 5 occurrences * nextvar.lua: 2 occurrences IMHO, this is so neglible, that we can move suite intact, but if it makes you happier, I believe we can relax the adopting rule for the case with such tiny whitespace changes. At the same time there are also a couple of *functional* changes: you adjusted auxiliary C sources regarding LuaJIT specifics. This violates the rule we discussed so much. As you mentioned below, tests still fail after this commit, so please move all functional changes to a separate patch. > https://www.lua.org/tests/lua5.1-tests.tar.gz. > > and is slightly modified to be consistent with the > current LuaJIT's LuaC API. > > 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 | 4 +- > test/PUC-Lua-5.1-tests/CMakeLists.txt | 89 ++ > 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/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 +++ > 34 files changed, 7783 insertions(+), 3 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 > 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/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 > > 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..08bee36 > --- /dev/null > +++ b/test/PUC-Lua-5.1-tests/CMakeLists.txt > @@ -0,0 +1,89 @@ > +# Test suite that has been added from PUC-Rio Lua 5.1 test archive > +# in scope of https://github.com/tarantool/tarantool/issues/4473. > + > +# See the rationale in the root CMakeLists.txt. > +cmake_minimum_required(VERSION 3.1 FATAL_ERROR) > + > +set(TEST_RUNNER ${CMAKE_CURRENT_SOURCE_DIR}/all.lua) I guess this variable is excess: there is no special variable for runner in LuaJIT-tests/CMakeLists.txt, so let's also follow this practice here. Moreover, the following part (from here to the line of dashes) should be moved to a new CMakeLists.txt in libs subdirectory. > +set(LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/libs) > +set(TESTLIB_PATH ${CMAKE_CURRENT_BINARY_DIR}/libs) After moving this part into a separate CMakeLists.txt this variables become excess. > + > +# XXX: -fPIC is required to linking with static library. > +if(NOT BUILDMODE STREQUAL "static") What does block you from building the libs against the static build? I don't get the reason and it looks like everything works fine (at least on my working station). > + # Build additional C libraries for tests. > + macro(build_lib lib sources) Consider CMake macro naming convention in LuaJIT. > + add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources}) > + target_include_directories(${lib} PRIVATE > + ${LUAJIT_SOURCE_DIR} > + ) > + set_target_properties(${lib} PROPERTIES > + LIBRARY_OUTPUT_DIRECTORY "${TESTLIB_PATH}" > + PREFIX "" > + ) > + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") > + set_target_properties(${lib} PROPERTIES > + LINK_FLAGS "-undefined dynamic_lookup" > + ) > + endif() > + target_link_libraries(${lib} PRIVATE libluajit_shared) This looks to be excess, doesn't it? > + list(APPEND TESTLIBS ${lib}) > + endmacro() > + > + build_lib(lib1 ${LIB_SOURCES}/lib1.c) > + build_lib(lib11 ${LIB_SOURCES}/lib1.c ${LIB_SOURCES}/lib11.c) > + build_lib(lib2 ${LIB_SOURCES}/lib2.c) > + build_lib(lib21 ${LIB_SOURCES}/lib2.c ${LIB_SOURCES}/lib21.c) > + > + set(LIB2COPY "${TESTLIB_PATH}/lib2${CMAKE_SHARED_LIBRARY_SUFFIX}") > + set(LIB_COPY "${TESTLIB_PATH}/-lib2${CMAKE_SHARED_LIBRARY_SUFFIX}") > + > + add_custom_command( > + COMMENT "Copping lib2 to -lib2 for PUC-Rio Lua 5.1 tests" > + OUTPUT ${LIB_COPY} > + DEPENDS ${TESTLIBS} > + COMMAND ${CMAKE_COMMAND} -E copy ${LIB2COPY} ${LIB_COPY} > + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} > + ) > + list(APPEND TESTLIBS ${LIB_COPY}) > +endif() > + > +set(CUSTOM_TEST_DIR ${TESTLIB_PATH}/P1) > +add_custom_command( > + COMMENT "Create directory for PUC-Rio Lua 5.1 tests" > + OUTPUT ${CUSTOM_TEST_DIR} > + COMMAND ${CMAKE_COMMAND} -E make_directory ${CUSTOM_TEST_DIR} > + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} > +) -------------------------------------------------------------------------------- > + > +set(LUA_PATH "?\;${CMAKE_CURRENT_SOURCE_DIR}/?.lua") It's worth to mention right here, why did you choose this way instead of the "better yet" (and the LUA_INIT problem). I see you referred to the well-known issue below, but IMHO it's better to group the rationale right here. > + > +# TODO: PUC-Rio Lua 5.1 test suite also has special header > +# and 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, depends on specific PUC-Rio Lua 5.1 > +# internal headers and should be adopted for LuaJIT. Typo: s/adopted/adapted/ or simply use "adjusted" here. > + > +add_custom_target(PUC-Lua-5.1-tests > + DEPENDS ${LUAJIT_TEST_BINARY} ${TESTLIBS} ${CUSTOM_TEST_DIR} > +) > + > +add_custom_command(TARGET PUC-Lua-5.1-tests > + COMMENT "Running PUC-Rio Lua 5.1 tests" > + COMMAND > + env > + # Tarantool doesn't support LUA_INIT and most likely it > + # never will. > + # See https://github.com/tarantool/tarantool/issues/5744 > + # for more info. > + # LUA_PATH="${CMAKE_CURRENT_BINARY_DIR}/?.lua\;\;" > + # LUA_INIT="package.path='?\;'..package.path" > + # So use less preferable way for tests. > + LUA_PATH="${LUA_PATH}\;\;" > + ${LUAJIT_TEST_COMMAND} ${TEST_RUNNER} > + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} > +) > + Consider the fixup patch on my branch[1] and below. I don't run CI for this revision, since the queue is overloaded. I'll push the bump in Tarantool repo a bit later. ================================================================================ commit c0c53e890252dd60dbad7d98a47e9e3c3ee55cff Author: Igor Munkin Date: Wed Mar 17 17:15:02 2021 +0300 fixup-1 diff --git a/test/PUC-Lua-5.1-tests/CMakeLists.txt b/test/PUC-Lua-5.1-tests/CMakeLists.txt index 08bee36e..da066eb8 100644 --- a/test/PUC-Lua-5.1-tests/CMakeLists.txt +++ b/test/PUC-Lua-5.1-tests/CMakeLists.txt @@ -1,61 +1,26 @@ # Test suite that has been added from PUC-Rio Lua 5.1 test archive -# in scope of https://github.com/tarantool/tarantool/issues/4473. +# 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) -set(TEST_RUNNER ${CMAKE_CURRENT_SOURCE_DIR}/all.lua) -set(LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/libs) -set(TESTLIB_PATH ${CMAKE_CURRENT_BINARY_DIR}/libs) - -# XXX: -fPIC is required to linking with static library. -if(NOT BUILDMODE STREQUAL "static") - # Build additional C libraries for tests. - macro(build_lib lib sources) - add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources}) - target_include_directories(${lib} PRIVATE - ${LUAJIT_SOURCE_DIR} - ) - set_target_properties(${lib} PROPERTIES - LIBRARY_OUTPUT_DIRECTORY "${TESTLIB_PATH}" - PREFIX "" - ) - if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set_target_properties(${lib} PROPERTIES - LINK_FLAGS "-undefined dynamic_lookup" - ) - endif() - target_link_libraries(${lib} PRIVATE libluajit_shared) - list(APPEND TESTLIBS ${lib}) - endmacro() - - build_lib(lib1 ${LIB_SOURCES}/lib1.c) - build_lib(lib11 ${LIB_SOURCES}/lib1.c ${LIB_SOURCES}/lib11.c) - build_lib(lib2 ${LIB_SOURCES}/lib2.c) - build_lib(lib21 ${LIB_SOURCES}/lib2.c ${LIB_SOURCES}/lib21.c) - - set(LIB2COPY "${TESTLIB_PATH}/lib2${CMAKE_SHARED_LIBRARY_SUFFIX}") - set(LIB_COPY "${TESTLIB_PATH}/-lib2${CMAKE_SHARED_LIBRARY_SUFFIX}") - - add_custom_command( - COMMENT "Copping lib2 to -lib2 for PUC-Rio Lua 5.1 tests" - OUTPUT ${LIB_COPY} - DEPENDS ${TESTLIBS} - COMMAND ${CMAKE_COMMAND} -E copy ${LIB2COPY} ${LIB_COPY} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - list(APPEND TESTLIBS ${LIB_COPY}) -endif() - -set(CUSTOM_TEST_DIR ${TESTLIB_PATH}/P1) -add_custom_command( - COMMENT "Create directory for PUC-Rio Lua 5.1 tests" - OUTPUT ${CUSTOM_TEST_DIR} - COMMAND ${CMAKE_COMMAND} -E make_directory ${CUSTOM_TEST_DIR} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} -) - +add_subdirectory(libs) + +# XXX: There are two ways to set up the proper environment in +# the suite 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") +# XXX: All libraries required for the tests are built in libs +# directory. To use them in the suite being run in the current +# working directory, LUA_CPATH has to be adjusted. +set(LUA_CPATH "${CMAKE_CURRENT_BINARY_DIR}/libs/?${CMAKE_SHARED_LIBRARY_SUFFIX}") # TODO: PUC-Rio Lua 5.1 test suite also has special header # and translation unit to check some @@ -64,25 +29,17 @@ set(LUA_PATH "?\;${CMAKE_CURRENT_SOURCE_DIR}/?.lua") # consistency and also contains tests for yield in hooks # and for the Lua C API. # But, unfortunately, depends on specific PUC-Rio Lua 5.1 -# internal headers and should be adopted for LuaJIT. - -add_custom_target(PUC-Lua-5.1-tests - DEPENDS ${LUAJIT_TEST_BINARY} ${TESTLIBS} ${CUSTOM_TEST_DIR} -) +# 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 - # Tarantool doesn't support LUA_INIT and most likely it - # never will. - # See https://github.com/tarantool/tarantool/issues/5744 - # for more info. - # LUA_PATH="${CMAKE_CURRENT_BINARY_DIR}/?.lua\;\;" - # LUA_INIT="package.path='?\;'..package.path" - # So use less preferable way for tests. LUA_PATH="${LUA_PATH}\;\;" - ${LUAJIT_TEST_COMMAND} ${TEST_RUNNER} + LUA_CPATH="${LUA_CPATH}\;\;" + ${LUAJIT_TEST_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/all.lua WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) 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 00000000..b7765a25 --- /dev/null +++ b/test/PUC-Lua-5.1-tests/libs/CMakeLists.txt @@ -0,0 +1,51 @@ +# 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) + +# Build additional C libraries for tests. +macro(BuildTestCLib lib sources) + add_library(${lib} SHARED EXCLUDE_FROM_ALL ${sources}) + target_include_directories(${lib} PRIVATE + ${LUAJIT_SOURCE_DIR} + ) + set_target_properties(${lib} PROPERTIES + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + PREFIX "" + ) + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set_target_properties(${lib} PROPERTIES + LINK_FLAGS "-undefined dynamic_lookup" + ) + endif() + list(APPEND TESTLIBS ${lib}) +endmacro() + +BuildTestCLib(lib1 lib1.c) +BuildTestCLib(lib11 lib1.c lib11.c) +BuildTestCLib(lib2 lib2.c) +BuildTestCLib(lib21 lib2.c lib21.c) + +# TODO: Add the rationale for this (mention the test case it is +# needed for). +set(LIB2ORIG "${CMAKE_CURRENT_BINARY_DIR}/lib2${CMAKE_SHARED_LIBRARY_SUFFIX}") +set(LIB2COPY "${CMAKE_CURRENT_BINARY_DIR}/-lib2${CMAKE_SHARED_LIBRARY_SUFFIX}") +add_custom_command( + OUTPUT ${LIB2COPY} + COMMENT "Copying lib2 to -lib2 for PUC-Rio Lua 5.1 tests" + COMMAND ${CMAKE_COMMAND} -E copy ${LIB2ORIG} ${LIB2COPY} + DEPENDS ${TESTLIBS} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +list(APPEND TESTLIBS ${LIB2COPY}) + +# TODO: Add the comment pointing to README. +add_custom_target(PUC-Lua-5.1-tests-prepare DEPENDS ${TESTLIBS}) +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 ================================================================================ > +# vim: expandtab tabstop=2 shiftwidth=2 > -- > 2.28.0 > [1]: https://github.com/tarantool/luajit/commit/c0c53e8 -- Best regards, IM