[Tarantool-patches] [PATCH luajit 1/2] test: introduce routine to build error message
Maxim Kokryashkin
m.kokryashkin at tarantool.org
Sun Feb 25 14:37:59 MSK 2024
Hi, Igor!
Thanks for the patch!
LGTM, except for a few comments below.
On Sun, Feb 25, 2024 at 10:41:06AM +0000, Igor Munkin wrote:
> LuaJIT modules yields the plain errors, but LuaJIT binary adds 'luajit:'
Typo: s/yields/yield/
> 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 prepends nothing to the error
Typo: s/prepends/adds/
Or, alternatively, you can say:
| Tarantool doesn't prepend errors produced by the LuaJIT module with
| anything.
> produced by LuaJIT module.
Typo: s/LuaJIT/the LuaJIT/
>
> To tweak the pattern to be used within the 411-luajit.t chunk, the
> auxiliary error building function is introduced in this patch.
>
> Signed-off-by: Igor Munkin <imun at tarantool.org>
> ---
> test/lua-Harness-tests/411-luajit.t | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/test/lua-Harness-tests/411-luajit.t b/test/lua-Harness-tests/411-luajit.t
> index 6cfd6837..1b2da729 100755
> --- a/test/lua-Harness-tests/411-luajit.t
> +++ b/test/lua-Harness-tests/411-luajit.t
> @@ -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 patters matching LuaJIT CLI
Typo: s/patters/patterns/
> +-- error messages.
> +local function errbuild(message)
> + local eprefix = _TARANTOOL and "" or "[^:]+: "
IMO, `errprefix` or `err_prefix` would be better.
Feel free to ignore, though.
> + return table.concat({"^", eprefix, message})
> +end
> +
> local lua = _retrieve_progname()
>
> if not pcall(io.popen, lua .. [[ -e "a=1"]]) then
> @@ -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
> @@ -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
>
> --
> 2.39.2
>
More information about the Tarantool-patches
mailing list