Skip to content

Commit

Permalink
test: introduce routine to build error message
Browse files Browse the repository at this point in the history
LuaJIT modules yield the plain errors, but LuaJIT binary adds 'luajit:'
prefix to it, so 411-luajit.t test in lua-Harness suite expects the
error message with the aforementioned prefix in the corresponding
assertions. At the same time, Tarantool doesn't prepend errors produced
by the LuaJIT module with anything.

To tweak the pattern to be used within the 411-luajit.t chunk, the
auxiliary error building function is introduced in this patch.

Reviewed-by: Maxim Kokryashkin <[email protected]>
Reviewed-by: Sergey Kaplun <[email protected]>
Signed-off-by: Sergey Kaplun <[email protected]>
  • Loading branch information
igormunkin authored and Buristan committed Feb 27, 2024
1 parent 003d97c commit f90f7e0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions test/lua-Harness-tests/411-luajit.t
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ if not jit or ujit or _TARANTOOL then
skip_all("only with LuaJIT")
end

-- XXX: Unfortunately, Lua patterns do not support optional
-- capture groups, so the helper below implements poor man's
-- optional capture groups for the patterns matching LuaJIT CLI
-- error messages.
local function errbuild(message)
local errprefix = _TARANTOOL and "" or "[^:]+: "
return table.concat({"^", errprefix, message})
end

local lua = _retrieve_progname()

if not pcall(io.popen, lua .. [[ -e "a=1"]]) then
Expand Down Expand Up @@ -158,13 +167,13 @@ f = io.popen(cmd)
if compiled_with_jit then
equals(f:read'*l', 'Hello World', "-jon")
else
matches(f:read'*l', "^[^:]+: JIT compiler permanently disabled by build option", "no jit")
matches(f:read'*l', errbuild("JIT compiler permanently disabled by build option"), "no jit")
end
f:close()

cmd = lua .. " -j bad hello-411.lua 2>&1"
f = io.popen(cmd)
matches(f:read'*l', "^[^:]+: unknown luaJIT command or jit%.%* modules not installed", "-j bad")
matches(f:read'*l', errbuild("unknown luaJIT command or jit%.%* modules not installed"), "-j bad")
f:close()

if compiled_with_jit then
Expand All @@ -190,12 +199,12 @@ if compiled_with_jit then

cmd = lua .. " -O+bad hello-411.lua 2>&1"
f = io.popen(cmd)
matches(f:read'*l', "^[^:]+: unknown or malformed optimization flag '%+bad'", "-O+bad")
matches(f:read'*l', errbuild("unknown or malformed optimization flag '%+bad'"), "-O+bad")
f:close()
else
cmd = lua .. " -O0 hello-411.lua 2>&1"
f = io.popen(cmd)
matches(f:read'*l', "^[^:]+: attempt to index a nil value")
matches(f:read'*l', errbuild("attempt to index a nil value"))
f:close()
end

Expand Down

0 comments on commit f90f7e0

Please sign in to comment.