From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Sergey Ostanevich <sergos@tarantool.org>, Igor Munkin <imun@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [WIP luajit 03/15] test: adapt Lua 5.1 test suite for Tarantool Date: Thu, 4 Mar 2021 13:23:50 +0300 [thread overview] Message-ID: <f915688133c9f6303b67f169fc5fa4ef53c47790.1614847731.git.skaplun@tarantool.org> (raw) In-Reply-To: <cover.1614847731.git.skaplun@tarantool.org> In some insignificant details Tarantool's behaviour is not the same as the behaviour of Lua 5.1. This patch adds special LUAJIT_TEST_COMMAND variable to extend `progname` from main.lua with ` -e require"strict".off()` to disable strict for debug Tarantool build. Also, `progname` is not edged by '"' to be able run other test suites. Tests in the following files are disabled with corresponding comments: * gc.lua * main.lua * pm.lua Tests in the following files are adapted for testing with Tarantool's out-of-source build: * all.lua * verybig.lua Part of tarantool/tarantool#5845 Part of tarantool/tarantool#4473 --- CMakeLists.txt | 8 ++++++++ test/PUC-Lua-5.1-tests/CMakeLists.txt | 5 ++++- test/PUC-Lua-5.1-tests/all.lua | 16 ++++++++++++---- test/PUC-Lua-5.1-tests/gc.lua | 9 ++++++--- test/PUC-Lua-5.1-tests/main.lua | 24 +++++++++++++++++------- test/PUC-Lua-5.1-tests/pm.lua | 6 +++++- test/PUC-Lua-5.1-tests/verybig.lua | 4 +++- 7 files changed, 55 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9486ca6..9917b50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -288,6 +288,14 @@ set(LUAJIT_TEST_BINARY ${LUAJIT_BINARY} CACHE STRING "Lua implementation to be used for tests. Default is 'luajit'." ) +# Unfortunately we can't just use LUA_INIT enviroment variable. +# See https://github.com/tarantool/tarantool/issues/5744 for +# the details. This variable includes -e 'require"strict".off()' +# for the Tarantool. +set(LUAJIT_TEST_COMMAND ${LUAJIT_BINARY} CACHE STRING + "Lua implementation with -e command to be used for tests. Default is 'luajit'." +) + add_subdirectory(test) # --- Misc rules --------------------------------------------------------------- diff --git a/test/PUC-Lua-5.1-tests/CMakeLists.txt b/test/PUC-Lua-5.1-tests/CMakeLists.txt index ed32a84..1249cab 100644 --- a/test/PUC-Lua-5.1-tests/CMakeLists.txt +++ b/test/PUC-Lua-5.1-tests/CMakeLists.txt @@ -82,7 +82,10 @@ add_custom_command(TARGET PUC-Lua-5.1-tests # LUA_INIT="package.path='?\;'..package.path" # So use less preferable way for tests. LUA_PATH="${LUA_PATH}\;\;" - ${LUAJIT_TEST_BINARY} ${TEST_RUNNER} + # XXX: Adapt to run test on readonly file systems + # with loadfile(CUR_SOURCE_DIR..filename). + CUR_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} + ${LUAJIT_TEST_COMMAND} ${TEST_RUNNER} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) diff --git a/test/PUC-Lua-5.1-tests/all.lua b/test/PUC-Lua-5.1-tests/all.lua index 8c4afac..52a6235 100755 --- a/test/PUC-Lua-5.1-tests/all.lua +++ b/test/PUC-Lua-5.1-tests/all.lua @@ -58,9 +58,13 @@ end -- -- redefine dofile to run files through dump/undump -- -dofile = function (n) +-- Adapt test for testing with Tarantool's out-of-source build +-- on read only file system. CUR_SOURCE_DIR is set via CMake. +local path_to_sources = os.getenv('CUR_SOURCE_DIR')..'/' +dofile = function (n, prefix) + local pr = prefix or path_to_sources showmem() - local f = assert(loadfile(n)) + local f = assert(loadfile(pr..n)) local b = string.dump(f) f = assert(loadstring(b)) return f() @@ -77,7 +81,9 @@ do end end -local f = assert(loadfile('gc.lua')) +-- Adapt test for testing with Tarantool's out-of-source build +-- on read only file system. +local f = assert(loadfile(path_to_sources..'gc.lua')) f() dofile('db.lua') assert(dofile('calls.lua') == deep and deep) @@ -88,7 +94,9 @@ assert(dofile('locals.lua') == 5) dofile('constructs.lua') dofile('code.lua') do - local f = coroutine.wrap(assert(loadfile('big.lua'))) + -- Adapt test for testing with Tarantool's out-of-source build + -- on read only file system. + local f = coroutine.wrap(assert(loadfile(path_to_sources..'big.lua'))) assert(f() == 'b') assert(f() == 'a') end diff --git a/test/PUC-Lua-5.1-tests/gc.lua b/test/PUC-Lua-5.1-tests/gc.lua index b767104..6c4097a 100644 --- a/test/PUC-Lua-5.1-tests/gc.lua +++ b/test/PUC-Lua-5.1-tests/gc.lua @@ -128,9 +128,12 @@ do local a = {} until gcinfo() > 1000 collectgarbage"restart" - repeat - local a = {} - until gcinfo() < 1000 + -- Tarantool has too much objects at start. + -- gcinfo() is always greater than 1000. + -- Test is disabled for Tarantool binary. + -- repeat + -- local a = {} + -- until gcinfo() < 1000 end lim = 15 diff --git a/test/PUC-Lua-5.1-tests/main.lua b/test/PUC-Lua-5.1-tests/main.lua index 12f3981..69eb5db 100644 --- a/test/PUC-Lua-5.1-tests/main.lua +++ b/test/PUC-Lua-5.1-tests/main.lua @@ -11,7 +11,7 @@ out = os.tmpname() do local i = 0 while arg[i] do i=i-1 end - progname = '"'..arg[i+1]..'"' + progname = arg[i+1] end print(progname) @@ -50,8 +50,10 @@ end -- test 2 files prepfile("print(1); a=2") prepfile("print(a)", otherprog) -RUN("lua -l %s -l%s -lstring -l io %s > %s", prog, otherprog, otherprog, out) -checkout("1\n2\n2\n") +-- Test is disabled for Tarantool binary. +-- See https://github.com/tarantool/tarantool/issues/5747. +-- RUN("lua -l %s -l%s -lstring -l io %s > %s", prog, otherprog, otherprog, out) +-- checkout("1\n2\n2\n") local a = [[ assert(table.getn(arg) == 3 and arg[1] == 'a' and @@ -63,7 +65,10 @@ local a = [[ ]] a = string.format(a, progname) prepfile(a) -RUN('lua "-e " -- %s a b c', prog) +-- Tarantool has different command line argument parsing. +-- For example it always set itself as arg[-1]. +-- Test is disabled for Tarantool binary. +-- RUN('lua "-e " -- %s a b c', prog) -- test 'arg' availability in libraries -- LuaJIT v2.1.0-beta3 has extension from Lua 5.3: @@ -85,8 +90,10 @@ prepfile[[print(({...})[30])]] RUN("lua %s %s > %s", prog, string.rep(" a", 30), out) checkout("a\n") -RUN([[lua "-eprint(1)" -ea=3 -e "print(a)" > %s]], out) -checkout("1\n3\n") +-- Test is disabled for Tarantool binary. +-- See https://github.com/tarantool/tarantool/issues/5747. +-- RUN([[lua "-eprint(1)" -ea=3 -e "print(a)" > %s]], out) +-- checkout("1\n3\n") prepfile[[ print( @@ -177,7 +184,10 @@ assert(not os.remove(out)) RUN("lua -v") -NoRun("lua -h") +-- Tarantool returns zero status at exit with -h option, unlike +-- Lua does. +-- Test is disabled for Tarantool binary. +-- NoRun("lua -h") NoRun("lua -e") NoRun("lua -e a") NoRun("lua -f") diff --git a/test/PUC-Lua-5.1-tests/pm.lua b/test/PUC-Lua-5.1-tests/pm.lua index 366a31c..6e1b403 100644 --- a/test/PUC-Lua-5.1-tests/pm.lua +++ b/test/PUC-Lua-5.1-tests/pm.lua @@ -207,7 +207,11 @@ function rev (s) end local x = string.rep('012345', 10) -assert(rev(rev(x)) == x) +-- The first Tarantool's fiber has only 512Kb of stack. +-- It is not enough for this recursive call. +-- See also https://github.com/tarantool/tarantool/issues/5782. +-- Test is disabled for Tarantool binary. +-- assert(rev(rev(x)) == x) -- gsub with tables diff --git a/test/PUC-Lua-5.1-tests/verybig.lua b/test/PUC-Lua-5.1-tests/verybig.lua index 59e0142..bfb95df 100644 --- a/test/PUC-Lua-5.1-tests/verybig.lua +++ b/test/PUC-Lua-5.1-tests/verybig.lua @@ -93,7 +93,9 @@ for s in string.gmatch(prog, "$([^$]+)") do if not n then io.write(s) else F[n]() end end io.close() -result = dofile(file) +-- Adapt test for testing with Tarantool's out-of-source build +-- on read only file system. +result = dofile(file, "") assert(os.remove(file)) print'OK' return result -- 2.28.0
next prev parent reply other threads:[~2021-03-04 10:26 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-04 10:23 [Tarantool-patches] [WIP luajit 00/15] Adapt LuaVela test suites Sergey Kaplun via Tarantool-patches 2021-03-04 10:23 ` [Tarantool-patches] [WIP luajit 01/15] test: add PUC-Rio Lua 5.1 test suite Sergey Kaplun via Tarantool-patches 2021-03-04 10:23 ` [Tarantool-patches] [WIP luajit 02/15] test: adapt PUC-Rio Lua 5.1 test suite for LuaJIT Sergey Kaplun via Tarantool-patches 2021-03-04 10:23 ` Sergey Kaplun via Tarantool-patches [this message] 2021-03-04 10:23 ` [Tarantool-patches] [WIP luajit 04/15] test: add LuaJIT-test-cleanup test suite Sergey Kaplun via Tarantool-patches 2021-03-04 10:23 ` [Tarantool-patches] [WIP luajit 05/15] test: change tests to match de5568e Sergey Kaplun via Tarantool-patches 2021-03-04 10:23 ` [Tarantool-patches] [WIP luajit 06/15] test: change tests to match c198167 Sergey Kaplun via Tarantool-patches 2021-03-04 10:23 ` [Tarantool-patches] [WIP luajit 07/15] test: change tests to match 5a61e1a Sergey Kaplun via Tarantool-patches 2021-03-04 10:23 ` [Tarantool-patches] [WIP luajit 08/15] test: change LuaJIT suite tests to match b4e6bf0 Sergey Kaplun via Tarantool-patches 2021-03-04 10:23 ` [Tarantool-patches] [WIP luajit 09/15] test: adjust LuaJIT test suite for Tarantool Sergey Kaplun via Tarantool-patches 2021-03-04 10:23 ` [Tarantool-patches] [WIP luajit 10/15] test: add lua-Harness test suite Sergey Kaplun via Tarantool-patches 2021-03-04 10:23 ` [Tarantool-patches] [WIP luajit 11/15] test: adjust lua-Harness test suite for Tarantool Sergey Kaplun via Tarantool-patches 2021-03-04 10:23 ` [Tarantool-patches] [WIP luajit 12/15] test: disable 305-utf8 of lua-Harness suite Sergey Kaplun via Tarantool-patches 2021-03-04 10:24 ` [Tarantool-patches] [WIP luajit 13/15] test: disable 241-standalone " Sergey Kaplun via Tarantool-patches 2021-03-04 10:24 ` [Tarantool-patches] [WIP luajit 14/15] test: disable 411-luajit " Sergey Kaplun via Tarantool-patches 2021-03-04 10:24 ` [Tarantool-patches] [WIP luajit 15/15] test: skip test for getenv in 309-os.t Sergey Kaplun via Tarantool-patches 2021-03-04 16:24 ` [Tarantool-patches] [WIP luajit 00/15] Adapt LuaVela test suites Sergey Ostanevich via Tarantool-patches 2021-03-04 19:58 ` Sergey Kaplun via Tarantool-patches 2021-03-05 10:48 ` Sergey Ostanevich via Tarantool-patches 2021-03-16 11:21 ` Igor Munkin via Tarantool-patches 2021-03-09 23:59 ` Igor Munkin via Tarantool-patches 2021-03-10 8:09 ` Sergey Kaplun via Tarantool-patches 2021-03-10 10:39 ` Igor Munkin via Tarantool-patches 2021-03-10 9:46 ` Sergey Ostanevich via Tarantool-patches 2021-03-10 10:43 ` Igor Munkin via Tarantool-patches 2021-03-10 16:25 ` Igor Munkin 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=f915688133c9f6303b67f169fc5fa4ef53c47790.1614847731.git.skaplun@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=imun@tarantool.org \ --cc=sergos@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [WIP luajit 03/15] test: adapt Lua 5.1 test suite for Tarantool' \ /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