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 E8F456B950; Tue, 13 Apr 2021 16:29:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E8F456B950 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1618320599; bh=SsW/LAQ5W9/Cj2y4gLtmTG6fn1bynkDaEIEKG1BK/wo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=GkqP9MeWOQtZ1D7l2tg/yycmol7wHy9Z8rOWYhsE2EA9VYPuiMsu0xqYhrwMGZqjh r0Y6nUMCFhaihoO50je67WyenI47+a0TkqS9o+gej5Ldvb6zhuHt9DuJ4KkJqqS67o 5odBOachzNSXpiQ1x7dm0U48887auCTPMmCXLVaY= Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (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 DA53D6B950 for ; Tue, 13 Apr 2021 16:28:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DA53D6B950 Received: by smtp48.i.mail.ru with esmtpa (envelope-from ) id 1lWJ5j-0000dj-2M; Tue, 13 Apr 2021 16:28:31 +0300 To: Sergey Ostanevich , Igor Munkin Date: Tue, 13 Apr 2021 16:27:03 +0300 Message-Id: X-Mailer: git-send-email 2.31.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92FFCB8E6708E748094FADAEB10E66ADA4C48BE3C291E66DA182A05F5380850401200237305508AEA90773909D4721B230F61884F82F7442A98F896A6401D2C57 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7705F446BE41E38A1EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637EE76DA0D7A2874C78638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2F87F791CF3EEB9EFE50E4279B2F6AF7E06708AB62ED68B8ED2E47CDBA5A96583C09775C1D3CA48CF90D92131081DE748117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE7BEE62E5629C982429FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA73A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E73525A4AB119743A3B3C4224003CC83647689D4C264860C145E X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CB69F9342289A40B3B337CF719EAE2D7B4C1ADAD9EB69DC879C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF0417BEADF48D1460699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348F1757F8DFBC5C33151617C7F6DE2EFE1D4522A507C5A32AF518F7C727CE5FD9B1C409CF4B1C46881D7E09C32AA3244C2AFC8BE2555AA1B73EAD034EC5FA9290853296C06374E602927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnA7/qPBUIXEzeQyLYNEWug== X-Mailru-Sender: 3B9A0136629DC91206CBC582EFEF4CB47E05B3A27DF9C8BF0CB0C4669B49AB2C744E639442548C94F2400F607609286E924004A7DEC283833C7120B22964430C52B393F8C72A41A89437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit v3 03/29] test: adapt PUC-Rio suite for out-of-source build 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: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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 `loadfile()` and `dofile()` by default and can be overloaded via running lua code from LUAJIT_TEST_INIT. This patch introduces the 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 # 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) diff --git a/test/PUC-Rio-Lua-5.1-tests/all.lua b/test/PUC-Rio-Lua-5.1-tests/all.lua index 8c4aface..7460a677 100755 --- a/test/PUC-Rio-Lua-5.1-tests/all.lua +++ b/test/PUC-Rio-Lua-5.1-tests/all.lua @@ -66,7 +66,12 @@ dofile = function (n) return f() end -dofile('main.lua') +-- LuaJIT: Adapt tests for testing with out-of-source build. +-- See the comment in . +local _dofile = _dofile or dofile +local _loadstring = _loadstring or loadstring + +_dofile('main.lua') do local u = newproxy(true) @@ -77,32 +82,34 @@ do end end -local f = assert(loadfile('gc.lua')) +-- LuaJIT: Adapt tests for testing with out-of-source build. +-- See the comment in . +local f = assert(_loadfile('gc.lua')) f() -dofile('db.lua') -assert(dofile('calls.lua') == deep and deep) -dofile('strings.lua') -dofile('literals.lua') -assert(dofile('attrib.lua') == 27) -assert(dofile('locals.lua') == 5) -dofile('constructs.lua') -dofile('code.lua') +_dofile('db.lua') +assert(_dofile('calls.lua') == deep and deep) +_dofile('strings.lua') +_dofile('literals.lua') +assert(_dofile('attrib.lua') == 27) +assert(_dofile('locals.lua') == 5) +_dofile('constructs.lua') +_dofile('code.lua') do - local f = coroutine.wrap(assert(loadfile('big.lua'))) + local f = coroutine.wrap(assert(_loadfile('big.lua'))) assert(f() == 'b') assert(f() == 'a') end -dofile('nextvar.lua') -dofile('pm.lua') -dofile('api.lua') -assert(dofile('events.lua') == 12) -dofile('vararg.lua') -dofile('closure.lua') -dofile('errors.lua') -dofile('math.lua') -dofile('sort.lua') -assert(dofile('verybig.lua') == 10); collectgarbage() -dofile('files.lua') +_dofile('nextvar.lua') +_dofile('pm.lua') +_dofile('api.lua') +assert(_dofile('events.lua') == 12) +_dofile('vararg.lua') +_dofile('closure.lua') +_dofile('errors.lua') +_dofile('math.lua') +_dofile('sort.lua') +assert(_dofile('verybig.lua') == 10); collectgarbage() +_dofile('files.lua') if #msgs > 0 then print("\ntests not performed:") 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 +-- files If the variable is not defined then suite uses +-- `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