Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH luajit] test: adapt disabled tests from PUC-Rio
@ 2021-09-24 13:58 Maxim Kokryashkin via Tarantool-patches
  2021-09-24 14:34 ` Максим Корякшин via Tarantool-patches
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Maxim Kokryashkin via Tarantool-patches @ 2021-09-24 13:58 UTC (permalink / raw)
  To: tarantool-patches, imun, skaplun

Version and status are printed in stdout instead stderr
since LuaJIT-2.0.0-beta11 (as it is not an error message). This behavior
is the same as in Lua 5.2, so necessary changes in tests can be
adapted from PUC-Rio Lua 5.2 test suite.

Closes tarantool/tarantool#5687
---
Issue: https://github.com/tarantool/tarantool/issues/5687
Branch: https://github.com/tarantool/luajit/tree/fckxorg/gh-5687-adapt-tests-output-PUC-Rio

 test/PUC-Rio-Lua-5.1-tests/main.lua | 53 +++++++++++++++++++----------
 1 file changed, 35 insertions(+), 18 deletions(-)

diff --git a/test/PUC-Rio-Lua-5.1-tests/main.lua b/test/PUC-Rio-Lua-5.1-tests/main.lua
index 07facc4c..34e028f5 100644
--- a/test/PUC-Rio-Lua-5.1-tests/main.lua
+++ b/test/PUC-Rio-Lua-5.1-tests/main.lua
@@ -24,11 +24,33 @@ local prepfile = function (s, p)
   assert(io.close())
 end
 
-function checkout (s)
+-- Taken from PUC-Rio Lua 5.2 test suite.
+-- See comment for checkprogout().
+function getoutput ()
   io.input(out)
   local t = io.read("*a")
   io.input():close()
   assert(os.remove(out))
+  return t
+end
+
+-- Version and status are printed in stdout instead stderr since
+-- LuaJIT-2.0.0-beta11 (as it is not an error message).
+-- See commit 0bd1a66f2f055211ef55834ccebca3b82d03c735
+-- (Print version and JIT status to stdout, not stderr.).
+-- This behavior is the same as in Lua 5.2.
+-- See also https://github.com/tarantool/tarantool/issues/5687.
+-- This function is adapted from PUC-Rio Lua 5.2 test suite.
+-- It is used for test commands with -i flag.
+function checkprogout (s)
+  local t = getoutput()
+  for line in string.gmatch(s, ".-\n") do
+    assert(string.find(t, line, 1, true))
+  end
+end
+
+function checkout (s)
+  local t = getoutput()
   if s ~= t then print(string.format("'%s' - '%s'\n", s, t)) end
   assert(s == t)
   return t
@@ -117,37 +139,32 @@ prepfile[[
 RUN("lua - < %s > %s", prog, out)
 checkout("1\tnil\n")
 
--- FIXME: Version and status are printed to stdout instead of
--- stderr since LuaJIT-2.0.0-beta11 (as it is not an error
--- message). See commit 0bd1a66f2f055211ef55834ccebca3b82d03c735
--- (Print version and JIT status to stdout, not stderr.).
--- This behavior is the same as in Lua 5.2.
--- In Lua 5.2 this feature was introduced via commit
--- 9e7de9473c65baee1f567852a778f2d33a47ea83.
--- See also https://github.com/tarantool/tarantool/issues/5687.
+-- Test is adapted from PUC-Rio Lua 5.2 test suite.
+-- See comment for checkprogout().
 prepfile[[
 = (6*2-6) -- ===
 a
 = 10
 print(a)
 = a]]
--- FIXME: Behavior is different for LuaJIT. See the comment above.
--- RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out)
--- checkout("6\n10\n10\n\n")
+RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out)
+checkprogout("6\n10\n10\n\n")
 
+-- Test is adapted from PUC-Rio Lua 5.2 test suite.
+-- See comment for checkprogout().
 prepfile("a = [[b\nc\nd\ne]]\n=a")
 print(prog)
--- FIXME: Behavior is different for LuaJIT. See the comment above.
--- RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out)
--- checkout("b\nc\nd\ne\n\n")
+RUN([[lua -e"_PROMPT='' _PROMPT2=''" -i < %s > %s]], prog, out)
+checkprogout("b\nc\nd\ne\n\n")
 
+-- Test is adapted from PUC-Rio Lua 5.2 test suite.
+-- See comment for checkprogout().
 prompt = "alo"
 prepfile[[ --
 a = 2
 ]]
--- FIXME: Behavior is different for LuaJIT. See the comment above.
--- RUN([[lua "-e_PROMPT='%s'" -i < %s > %s]], prompt, prog, out)
--- checkout(string.rep(prompt, 3).."\n")
+RUN([[lua "-e_PROMPT='%s'" -i < %s > %s]], prompt, prog, out)
+checkprogout(string.rep(prompt, 3).."\n")
 
 s = [=[ --
 function f ( x )
-- 
2.33.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-02-17 16:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-24 13:58 [Tarantool-patches] [PATCH luajit] test: adapt disabled tests from PUC-Rio Maxim Kokryashkin via Tarantool-patches
2021-09-24 14:34 ` Максим Корякшин via Tarantool-patches
2021-10-08  8:58   ` Sergey Kaplun via Tarantool-patches
2021-10-13 15:55     ` [Tarantool-patches] [PATCH luajit v2] " Maxim Kokryashkin via Tarantool-patches
2021-12-16 15:04       ` Sergey Kaplun via Tarantool-patches
2022-01-21 11:41         ` Максим Корякшин via Tarantool-patches
2022-02-16 10:37           ` Igor Munkin via Tarantool-patches
2022-02-16 10:37         ` Igor Munkin via Tarantool-patches
2022-02-17 12:01           ` Maxim Kokryashkin via Tarantool-patches
2022-02-16 10:37       ` Igor Munkin via Tarantool-patches
2021-10-08  8:54 ` [Tarantool-patches] [PATCH luajit] " Sergey Kaplun via Tarantool-patches
2022-02-17 16:38 ` Igor Munkin via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox