Skip to content
Snippets Groups Projects
Commit 3fcd83ea authored by Sergey Kaplun's avatar Sergey Kaplun Committed by Igor Munkin
Browse files

test: fix fix_lua_loader_error_handling on macOS

This patch is a follow-up for the commit
b99a3541 ("lua: fix loader behaviour in
case of syntax error").

This test uses full matching of the error message and assumes that the
temporary directory is short enough, so the full patch is less than 60
symbols (size of `lua_Debug.short_src`). But for macOS, the temporary
directory has a longer path, so the error message is shrunk and isn't
equal to the expected string.

This patch replaces full matching with matching of the last part of the
error message.

Relates to tarantool/tarantool-ee#585

NO_DOC=test fix
NO_CHANGELOG=test fix
parent 38b4915c
No related branches found
No related tags found
No related merge requests found
......@@ -14,22 +14,16 @@ local g = t.group()
-- the end of the test.
local cwd = fio.cwd()
local luadir
local name = 'syntax'
-- XXX: Unfortunately, multiline literals do not interpolate
-- escape sequences, so just concatenate two lines of the error
-- message to build the final template.
local errlike = table.concat({
"error loading module '<NAME>' from file '<DIR>/<NAME>.lua':",
"<DIR>/<NAME>.lua:1: unexpected symbol near '?'",
}, "\n\t")
-- XXX: luatest uses only `string.find()` with 4th argument
-- (`plain`) unconditionally set to `true` for error matching, so
-- there is no way to use any pattern here.
local errtail = ("/%s.lua:1: unexpected symbol near '?'"):format(name)
g.before_all(function()
treegen.init(g)
treegen.add_template(g, ('^%s%%.lua$'):format(name), [[?syntax error?]])
luadir = treegen.prepare_directory(g, {('%s.lua'):format(name)})
local luadir = treegen.prepare_directory(g, {('%s.lua'):format(name)})
fio.chdir(luadir)
end)
......@@ -39,6 +33,5 @@ g.after_all(function(g)
end)
g.test_loader_error_handling = function()
local errmsg = errlike:gsub('%<(%w+)>', { DIR = luadir, NAME = name })
t.assert_error_msg_equals(errmsg, require, name)
t.assert_error_msg_contains(errtail, require, name)
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment