mirror of
https://github.com/neovim/neovim
synced 2025-07-20 13:22:26 +00:00
feat(lua): enable stack traces in error output (#16228)
This commit is contained in:
@ -605,7 +605,7 @@ do
|
|||||||
function vim.validate(opt)
|
function vim.validate(opt)
|
||||||
local ok, err_msg = is_valid(opt)
|
local ok, err_msg = is_valid(opt)
|
||||||
if not ok then
|
if not ok then
|
||||||
error(debug.traceback(err_msg, 2), 2)
|
error(err_msg, 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -85,6 +85,27 @@ static void nlua_error(lua_State *const lstate, const char *const msg)
|
|||||||
lua_pop(lstate, 1);
|
lua_pop(lstate, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Like lua_pcall, but use debug.traceback as errfunc.
|
||||||
|
///
|
||||||
|
/// @param lstate Lua interpreter state
|
||||||
|
/// @param[in] nargs Number of arguments expected by the function being called.
|
||||||
|
/// @param[in] nresults Number of results the function returns.
|
||||||
|
static int nlua_pcall(lua_State *lstate, int nargs, int nresults)
|
||||||
|
{
|
||||||
|
lua_getglobal(lstate, "debug");
|
||||||
|
lua_getfield(lstate, -1, "traceback");
|
||||||
|
lua_remove(lstate, -2);
|
||||||
|
lua_insert(lstate, -2 - nargs);
|
||||||
|
int status = lua_pcall(lstate, nargs, nresults, -2 - nargs);
|
||||||
|
if (status) {
|
||||||
|
lua_remove(lstate, -2);
|
||||||
|
} else {
|
||||||
|
lua_remove(lstate, -1 - nresults);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Gets the version of the current Nvim build.
|
/// Gets the version of the current Nvim build.
|
||||||
///
|
///
|
||||||
/// @param lstate Lua interpreter state.
|
/// @param lstate Lua interpreter state.
|
||||||
@ -115,7 +136,7 @@ static int nlua_luv_cfpcall(lua_State *lstate, int nargs, int nresult, int flags
|
|||||||
in_fast_callback++;
|
in_fast_callback++;
|
||||||
|
|
||||||
int top = lua_gettop(lstate);
|
int top = lua_gettop(lstate);
|
||||||
int status = lua_pcall(lstate, nargs, nresult, 0);
|
int status = nlua_pcall(lstate, nargs, nresult);
|
||||||
if (status) {
|
if (status) {
|
||||||
if (status == LUA_ERRMEM && !(flags & LUVF_CALLBACK_NOEXIT)) {
|
if (status == LUA_ERRMEM && !(flags & LUVF_CALLBACK_NOEXIT)) {
|
||||||
// consider out of memory errors unrecoverable, just like xmalloc()
|
// consider out of memory errors unrecoverable, just like xmalloc()
|
||||||
@ -146,7 +167,7 @@ static void nlua_schedule_event(void **argv)
|
|||||||
lua_State *const lstate = global_lstate;
|
lua_State *const lstate = global_lstate;
|
||||||
nlua_pushref(lstate, cb);
|
nlua_pushref(lstate, cb);
|
||||||
nlua_unref(lstate, cb);
|
nlua_unref(lstate, cb);
|
||||||
if (lua_pcall(lstate, 0, 0, 0)) {
|
if (nlua_pcall(lstate, 0, 0)) {
|
||||||
nlua_error(lstate, _("Error executing vim.schedule lua callback: %.*s"));
|
nlua_error(lstate, _("Error executing vim.schedule lua callback: %.*s"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,7 +204,7 @@ static void dummy_timer_close_cb(TimeWatcher *tw, void *data)
|
|||||||
static bool nlua_wait_condition(lua_State *lstate, int *status, bool *callback_result)
|
static bool nlua_wait_condition(lua_State *lstate, int *status, bool *callback_result)
|
||||||
{
|
{
|
||||||
lua_pushvalue(lstate, 2);
|
lua_pushvalue(lstate, 2);
|
||||||
*status = lua_pcall(lstate, 0, 1, 0);
|
*status = nlua_pcall(lstate, 0, 1);
|
||||||
if (*status) {
|
if (*status) {
|
||||||
return true; // break on error, but keep error on stack
|
return true; // break on error, but keep error on stack
|
||||||
}
|
}
|
||||||
@ -385,7 +406,7 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
|||||||
{
|
{
|
||||||
const char *code = (char *)&shared_module[0];
|
const char *code = (char *)&shared_module[0];
|
||||||
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim/shared.lua")
|
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim/shared.lua")
|
||||||
|| lua_pcall(lstate, 0, 0, 0)) {
|
|| nlua_pcall(lstate, 0, 0)) {
|
||||||
nlua_error(lstate, _("E5106: Error while creating shared module: %.*s"));
|
nlua_error(lstate, _("E5106: Error while creating shared module: %.*s"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -397,7 +418,7 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
|||||||
|
|
||||||
const char *code = (char *)&inspect_module[0];
|
const char *code = (char *)&inspect_module[0];
|
||||||
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim/inspect.lua")
|
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim/inspect.lua")
|
||||||
|| lua_pcall(lstate, 0, 1, 0)) {
|
|| nlua_pcall(lstate, 0, 1)) {
|
||||||
nlua_error(lstate, _("E5106: Error while creating inspect module: %.*s"));
|
nlua_error(lstate, _("E5106: Error while creating inspect module: %.*s"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -406,7 +427,7 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
|||||||
|
|
||||||
code = (char *)&lua_F_module[0];
|
code = (char *)&lua_F_module[0];
|
||||||
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim/F.lua")
|
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim/F.lua")
|
||||||
|| lua_pcall(lstate, 0, 1, 0)) {
|
|| nlua_pcall(lstate, 0, 1)) {
|
||||||
nlua_error(lstate, _("E5106: Error while creating vim.F module: %.*s"));
|
nlua_error(lstate, _("E5106: Error while creating vim.F module: %.*s"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -419,7 +440,7 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
|||||||
{
|
{
|
||||||
const char *code = (char *)&vim_module[0];
|
const char *code = (char *)&vim_module[0];
|
||||||
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim.lua")
|
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim.lua")
|
||||||
|| lua_pcall(lstate, 0, 0, 0)) {
|
|| nlua_pcall(lstate, 0, 0)) {
|
||||||
nlua_error(lstate, _("E5106: Error while creating vim module: %.*s"));
|
nlua_error(lstate, _("E5106: Error while creating vim module: %.*s"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -431,7 +452,7 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL
|
|||||||
|
|
||||||
const char *code = (char *)&lua_meta_module[0];
|
const char *code = (char *)&lua_meta_module[0];
|
||||||
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim/_meta.lua")
|
if (luaL_loadbuffer(lstate, code, strlen(code), "@vim/_meta.lua")
|
||||||
|| lua_pcall(lstate, 0, 1, 0)) {
|
|| nlua_pcall(lstate, 0, 1)) {
|
||||||
nlua_error(lstate, _("E5106: Error while creating vim._meta module: %.*s"));
|
nlua_error(lstate, _("E5106: Error while creating vim._meta module: %.*s"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -549,6 +570,7 @@ static int nlua_print(lua_State *const lstate)
|
|||||||
for (; curargidx <= nargs; curargidx++) {
|
for (; curargidx <= nargs; curargidx++) {
|
||||||
lua_pushvalue(lstate, -1); // tostring
|
lua_pushvalue(lstate, -1); // tostring
|
||||||
lua_pushvalue(lstate, curargidx); // arg
|
lua_pushvalue(lstate, curargidx); // arg
|
||||||
|
// Do not use nlua_pcall here to avoid duplicate stack trace information
|
||||||
if (lua_pcall(lstate, 1, 1, 0)) {
|
if (lua_pcall(lstate, 1, 1, 0)) {
|
||||||
errmsg = lua_tolstring(lstate, -1, &errmsg_len);
|
errmsg = lua_tolstring(lstate, -1, &errmsg_len);
|
||||||
goto nlua_print_error;
|
goto nlua_print_error;
|
||||||
@ -616,7 +638,7 @@ static int nlua_debug(lua_State *lstate)
|
|||||||
if (luaL_loadbuffer(lstate, (const char *)input.vval.v_string,
|
if (luaL_loadbuffer(lstate, (const char *)input.vval.v_string,
|
||||||
STRLEN(input.vval.v_string), "=(debug command)")) {
|
STRLEN(input.vval.v_string), "=(debug command)")) {
|
||||||
nlua_error(lstate, _("E5115: Error while loading debug string: %.*s"));
|
nlua_error(lstate, _("E5115: Error while loading debug string: %.*s"));
|
||||||
} else if (lua_pcall(lstate, 0, 0, 0)) {
|
} else if (nlua_pcall(lstate, 0, 0)) {
|
||||||
nlua_error(lstate, _("E5116: Error while calling debug string: %.*s"));
|
nlua_error(lstate, _("E5116: Error while calling debug string: %.*s"));
|
||||||
}
|
}
|
||||||
tv_clear(&input);
|
tv_clear(&input);
|
||||||
@ -909,7 +931,7 @@ static void nlua_typval_exec(const char *lcmd, size_t lcmd_len, const char *name
|
|||||||
|
|
||||||
PUSH_ALL_TYPVALS(lstate, args, argcount, special);
|
PUSH_ALL_TYPVALS(lstate, args, argcount, special);
|
||||||
|
|
||||||
if (lua_pcall(lstate, argcount, ret_tv ? 1 : 0, 0)) {
|
if (nlua_pcall(lstate, argcount, ret_tv ? 1 : 0)) {
|
||||||
nlua_error(lstate, _("E5108: Error executing lua %.*s"));
|
nlua_error(lstate, _("E5108: Error executing lua %.*s"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -964,7 +986,7 @@ int typval_exec_lua_callable(lua_State *lstate, LuaCallable lua_cb, int argcount
|
|||||||
|
|
||||||
PUSH_ALL_TYPVALS(lstate, argvars, argcount, false);
|
PUSH_ALL_TYPVALS(lstate, argvars, argcount, false);
|
||||||
|
|
||||||
if (lua_pcall(lstate, argcount, 1, 0)) {
|
if (nlua_pcall(lstate, argcount, 1)) {
|
||||||
nlua_print(lstate);
|
nlua_print(lstate);
|
||||||
return ERROR_OTHER;
|
return ERROR_OTHER;
|
||||||
}
|
}
|
||||||
@ -999,7 +1021,7 @@ Object nlua_exec(const String str, const Array args, Error *err)
|
|||||||
nlua_push_Object(lstate, args.items[i], false);
|
nlua_push_Object(lstate, args.items[i], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lua_pcall(lstate, (int)args.size, 1, 0)) {
|
if (nlua_pcall(lstate, (int)args.size, 1)) {
|
||||||
size_t len;
|
size_t len;
|
||||||
const char *errstr = lua_tolstring(lstate, -1, &len);
|
const char *errstr = lua_tolstring(lstate, -1, &len);
|
||||||
api_set_error(err, kErrorTypeException,
|
api_set_error(err, kErrorTypeException,
|
||||||
@ -1032,7 +1054,7 @@ Object nlua_call_ref(LuaRef ref, const char *name, Array args, bool retval, Erro
|
|||||||
nlua_push_Object(lstate, args.items[i], false);
|
nlua_push_Object(lstate, args.items[i], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lua_pcall(lstate, nargs, retval ? 1 : 0, 0)) {
|
if (nlua_pcall(lstate, nargs, retval ? 1 : 0)) {
|
||||||
// if err is passed, the caller will deal with the error.
|
// if err is passed, the caller will deal with the error.
|
||||||
if (err) {
|
if (err) {
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -1126,7 +1148,7 @@ void ex_luado(exarg_T *const eap)
|
|||||||
if (lcmd_len >= IOSIZE) {
|
if (lcmd_len >= IOSIZE) {
|
||||||
xfree(lcmd);
|
xfree(lcmd);
|
||||||
}
|
}
|
||||||
if (lua_pcall(lstate, 0, 1, 0)) {
|
if (nlua_pcall(lstate, 0, 1)) {
|
||||||
nlua_error(lstate, _("E5110: Error executing lua: %.*s"));
|
nlua_error(lstate, _("E5110: Error executing lua: %.*s"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1138,7 +1160,7 @@ void ex_luado(exarg_T *const eap)
|
|||||||
const char *old_line = (const char *)ml_get_buf(curbuf, l, false);
|
const char *old_line = (const char *)ml_get_buf(curbuf, l, false);
|
||||||
lua_pushstring(lstate, old_line);
|
lua_pushstring(lstate, old_line);
|
||||||
lua_pushnumber(lstate, (lua_Number)l);
|
lua_pushnumber(lstate, (lua_Number)l);
|
||||||
if (lua_pcall(lstate, 2, 1, 0)) {
|
if (nlua_pcall(lstate, 2, 1)) {
|
||||||
nlua_error(lstate, _("E5111: Error calling lua: %.*s"));
|
nlua_error(lstate, _("E5111: Error calling lua: %.*s"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1189,7 +1211,7 @@ bool nlua_exec_file(const char *path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lua_pcall(lstate, 0, 0, 0)) {
|
if (nlua_pcall(lstate, 0, 0)) {
|
||||||
nlua_error(lstate, _("E5113: Error while calling lua chunk: %.*s"));
|
nlua_error(lstate, _("E5113: Error while calling lua chunk: %.*s"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1241,7 +1263,7 @@ int nlua_expand_pat(expand_T *xp, char_u *pat, int *num_results, char_u ***resul
|
|||||||
// [ vim, vim._on_key, buf ]
|
// [ vim, vim._on_key, buf ]
|
||||||
lua_pushlstring(lstate, (const char *)pat, STRLEN(pat));
|
lua_pushlstring(lstate, (const char *)pat, STRLEN(pat));
|
||||||
|
|
||||||
if (lua_pcall(lstate, 1, 2, 0) != 0) {
|
if (nlua_pcall(lstate, 1, 2) != 0) {
|
||||||
nlua_error(lstate,
|
nlua_error(lstate,
|
||||||
_("Error executing vim._expand_pat: %.*s"));
|
_("Error executing vim._expand_pat: %.*s"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -1394,7 +1416,7 @@ void nlua_execute_on_key(int c)
|
|||||||
// [ vim, vim._on_key, buf ]
|
// [ vim, vim._on_key, buf ]
|
||||||
lua_pushlstring(lstate, (const char *)buf, buf_len);
|
lua_pushlstring(lstate, (const char *)buf, buf_len);
|
||||||
|
|
||||||
if (lua_pcall(lstate, 1, 0, 0)) {
|
if (nlua_pcall(lstate, 1, 0)) {
|
||||||
nlua_error(lstate,
|
nlua_error(lstate,
|
||||||
_("Error executing vim.on_key Lua callback: %.*s"));
|
_("Error executing vim.on_key Lua callback: %.*s"));
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
local helpers = require('test.functional.helpers')(after_each)
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
|
||||||
local exc_exec = helpers.exc_exec
|
local exc_exec = helpers.exc_exec
|
||||||
|
local remove_trace = helpers.remove_trace
|
||||||
local funcs = helpers.funcs
|
local funcs = helpers.funcs
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
@ -159,44 +160,44 @@ describe('luaeval(vim.api.…)', function()
|
|||||||
it('errors out correctly when working with API', function()
|
it('errors out correctly when working with API', function()
|
||||||
-- Conversion errors
|
-- Conversion errors
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Cannot convert given lua type',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Cannot convert given lua type',
|
||||||
exc_exec([[call luaeval("vim.api.nvim__id(vim.api.nvim__id)")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id(vim.api.nvim__id)")]])))
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Cannot convert given lua table',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Cannot convert given lua table',
|
||||||
exc_exec([[call luaeval("vim.api.nvim__id({1, foo=42})")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id({1, foo=42})")]])))
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Cannot convert given lua type',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Cannot convert given lua type',
|
||||||
exc_exec([[call luaeval("vim.api.nvim__id({42, vim.api.nvim__id})")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id({42, vim.api.nvim__id})")]])))
|
||||||
-- Errors in number of arguments
|
-- Errors in number of arguments
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected 1 argument',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected 1 argument',
|
||||||
exc_exec([[call luaeval("vim.api.nvim__id()")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id()")]])))
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected 1 argument',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected 1 argument',
|
||||||
exc_exec([[call luaeval("vim.api.nvim__id(1, 2)")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id(1, 2)")]])))
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected 2 arguments',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected 2 arguments',
|
||||||
exc_exec([[call luaeval("vim.api.nvim_set_var(1, 2, 3)")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim_set_var(1, 2, 3)")]])))
|
||||||
-- Error in argument types
|
-- Error in argument types
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua string',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua string',
|
||||||
exc_exec([[call luaeval("vim.api.nvim_set_var(1, 2)")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim_set_var(1, 2)")]])))
|
||||||
|
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua number',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua number',
|
||||||
exc_exec([[call luaeval("vim.api.nvim_buf_get_lines(0, 'test', 1, false)")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim_buf_get_lines(0, 'test', 1, false)")]])))
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Number is not integral',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Number is not integral',
|
||||||
exc_exec([[call luaeval("vim.api.nvim_buf_get_lines(0, 1.5, 1, false)")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim_buf_get_lines(0, 1.5, 1, false)")]])))
|
||||||
|
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table',
|
||||||
exc_exec([[call luaeval("vim.api.nvim__id_float('test')")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_float('test')")]])))
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Unexpected type',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Unexpected type',
|
||||||
exc_exec([[call luaeval("vim.api.nvim__id_float({[vim.type_idx]=vim.types.dictionary})")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_float({[vim.type_idx]=vim.types.dictionary})")]])))
|
||||||
|
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table',
|
||||||
exc_exec([[call luaeval("vim.api.nvim__id_array(1)")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_array(1)")]])))
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Unexpected type',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Unexpected type',
|
||||||
exc_exec([[call luaeval("vim.api.nvim__id_array({[vim.type_idx]=vim.types.dictionary})")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_array({[vim.type_idx]=vim.types.dictionary})")]])))
|
||||||
|
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table',
|
||||||
exc_exec([[call luaeval("vim.api.nvim__id_dictionary(1)")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_dictionary(1)")]])))
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Unexpected type',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Unexpected type',
|
||||||
exc_exec([[call luaeval("vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.array})")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.array})")]])))
|
||||||
|
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table',
|
||||||
exc_exec([[call luaeval("vim.api.nvim_set_keymap('', '', '', '')")]]))
|
remove_trace(exc_exec([[call luaeval("vim.api.nvim_set_keymap('', '', '', '')")]])))
|
||||||
|
|
||||||
-- TODO: check for errors with Tabpage argument
|
-- TODO: check for errors with Tabpage argument
|
||||||
-- TODO: check for errors with Window argument
|
-- TODO: check for errors with Window argument
|
||||||
|
@ -17,6 +17,7 @@ local pcall_err = helpers.pcall_err
|
|||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
local exec_capture = helpers.exec_capture
|
local exec_capture = helpers.exec_capture
|
||||||
local curbufmeths = helpers.curbufmeths
|
local curbufmeths = helpers.curbufmeths
|
||||||
|
local remove_trace = helpers.remove_trace
|
||||||
|
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
@ -46,9 +47,9 @@ describe(':lua command', function()
|
|||||||
eq([[Vim(lua):E5107: Error loading lua [string ":lua"]:0: unexpected symbol near ')']],
|
eq([[Vim(lua):E5107: Error loading lua [string ":lua"]:0: unexpected symbol near ')']],
|
||||||
pcall_err(command, 'lua ()'))
|
pcall_err(command, 'lua ()'))
|
||||||
eq([[Vim(lua):E5108: Error executing lua [string ":lua"]:1: TEST]],
|
eq([[Vim(lua):E5108: Error executing lua [string ":lua"]:1: TEST]],
|
||||||
exc_exec('lua error("TEST")'))
|
remove_trace(exc_exec('lua error("TEST")')))
|
||||||
eq([[Vim(lua):E5108: Error executing lua [string ":lua"]:1: Invalid buffer id: -10]],
|
eq([[Vim(lua):E5108: Error executing lua [string ":lua"]:1: Invalid buffer id: -10]],
|
||||||
exc_exec('lua vim.api.nvim_buf_set_lines(-10, 1, 1, false, {"TEST"})'))
|
remove_trace(exc_exec('lua vim.api.nvim_buf_set_lines(-10, 1, 1, false, {"TEST"})')))
|
||||||
eq({''}, curbufmeths.get_lines(0, 100, false))
|
eq({''}, curbufmeths.get_lines(0, 100, false))
|
||||||
end)
|
end)
|
||||||
it('works with NULL errors', function()
|
it('works with NULL errors', function()
|
||||||
@ -95,15 +96,15 @@ describe(':lua command', function()
|
|||||||
|
|
||||||
feed(':lua error("fail\\nmuch error\\nsuch details")<cr>')
|
feed(':lua error("fail\\nmuch error\\nsuch details")<cr>')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{2: }|
|
{2: }|
|
||||||
{3:E5108: Error executing lua [string ":lua}|
|
{3:E5108: Error executing lua [string ":lua}|
|
||||||
{3:"]:1: fail} |
|
{3:"]:1: fail} |
|
||||||
{3:much error} |
|
{3:much error} |
|
||||||
{3:such details} |
|
{3:such details} |
|
||||||
|
{3:stack traceback:} |
|
||||||
|
{3: [C]: in function 'error'} |
|
||||||
|
{3: [string ":lua"]:1: in main chunk}|
|
||||||
|
|
|
||||||
{4:Press ENTER or type command to continue}^ |
|
{4:Press ENTER or type command to continue}^ |
|
||||||
]]}
|
]]}
|
||||||
feed('<cr>')
|
feed('<cr>')
|
||||||
@ -119,24 +120,24 @@ describe(':lua command', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
|
|
|
|
||||||
]]}
|
]]}
|
||||||
eq('E5108: Error executing lua [string ":lua"]:1: fail\nmuch error\nsuch details', eval('v:errmsg'))
|
eq('E5108: Error executing lua [string ":lua"]:1: fail\nmuch error\nsuch details', remove_trace(eval('v:errmsg')))
|
||||||
|
|
||||||
local status, err = pcall(command,'lua error("some error\\nin a\\nAPI command")')
|
local status, err = pcall(command,'lua error("some error\\nin a\\nAPI command")')
|
||||||
local expected = 'Vim(lua):E5108: Error executing lua [string ":lua"]:1: some error\nin a\nAPI command'
|
local expected = 'Vim(lua):E5108: Error executing lua [string ":lua"]:1: some error\nin a\nAPI command'
|
||||||
eq(false, status)
|
eq(false, status)
|
||||||
eq(expected, string.sub(err, -string.len(expected)))
|
eq(expected, string.sub(remove_trace(err), -string.len(expected)))
|
||||||
|
|
||||||
feed(':messages<cr>')
|
feed(':messages<cr>')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{2: }|
|
{2: }|
|
||||||
{3:E5108: Error executing lua [string ":lua}|
|
{3:E5108: Error executing lua [string ":lua}|
|
||||||
{3:"]:1: fail} |
|
{3:"]:1: fail} |
|
||||||
{3:much error} |
|
{3:much error} |
|
||||||
{3:such details} |
|
{3:such details} |
|
||||||
|
{3:stack traceback:} |
|
||||||
|
{3: [C]: in function 'error'} |
|
||||||
|
{3: [string ":lua"]:1: in main chunk}|
|
||||||
|
|
|
||||||
{4:Press ENTER or type command to continue}^ |
|
{4:Press ENTER or type command to continue}^ |
|
||||||
]]}
|
]]}
|
||||||
end)
|
end)
|
||||||
@ -219,7 +220,7 @@ describe(':luafile', function()
|
|||||||
exc_exec('luafile ' .. fname))
|
exc_exec('luafile ' .. fname))
|
||||||
write_file(fname, 'vimm.api.nvim_buf_set_lines(1, 1, 2, false, {"ETTS"})')
|
write_file(fname, 'vimm.api.nvim_buf_set_lines(1, 1, 2, false, {"ETTS"})')
|
||||||
eq(("Vim(luafile):E5113: Error while calling lua chunk: %s:1: attempt to index global 'vimm' (a nil value)"):format(fname),
|
eq(("Vim(luafile):E5113: Error while calling lua chunk: %s:1: attempt to index global 'vimm' (a nil value)"):format(fname),
|
||||||
exc_exec('luafile ' .. fname))
|
remove_trace(exc_exec('luafile ' .. fname)))
|
||||||
end)
|
end)
|
||||||
it('works with NULL errors', function()
|
it('works with NULL errors', function()
|
||||||
write_file(fname, 'error(nil)')
|
write_file(fname, 'error(nil)')
|
||||||
|
@ -84,14 +84,14 @@ describe('vim.loop', function()
|
|||||||
|
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{1:~ }|
|
|
||||||
{2: }|
|
{2: }|
|
||||||
{3:Error executing luv callback:} |
|
{3:Error executing luv callback:} |
|
||||||
{3:[string "<nvim>"]:5: E5560: nvim_set_var must not }|
|
{3:[string "<nvim>"]:5: E5560: nvim_set_var must not }|
|
||||||
{3:be called in a lua loop callback} |
|
{3:be called in a lua loop callback} |
|
||||||
|
{3:stack traceback:} |
|
||||||
|
{3: [C]: in function 'nvim_set_var'} |
|
||||||
|
{3: [string "<nvim>"]:5: in function <[string }|
|
||||||
|
{3:"<nvim>"]:2>} |
|
||||||
{4:Press ENTER or type command to continue}^ |
|
{4:Press ENTER or type command to continue}^ |
|
||||||
]])
|
]])
|
||||||
feed('<cr>')
|
feed('<cr>')
|
||||||
|
@ -4,6 +4,7 @@ local Screen = require('test.functional.ui.screen')
|
|||||||
|
|
||||||
local pcall_err = helpers.pcall_err
|
local pcall_err = helpers.pcall_err
|
||||||
local exc_exec = helpers.exc_exec
|
local exc_exec = helpers.exc_exec
|
||||||
|
local remove_trace = helpers.remove_trace
|
||||||
local exec_lua = helpers.exec_lua
|
local exec_lua = helpers.exec_lua
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
@ -424,11 +425,11 @@ describe('luaeval()', function()
|
|||||||
it('errors out correctly when doing incorrect things in lua', function()
|
it('errors out correctly when doing incorrect things in lua', function()
|
||||||
-- Conversion errors
|
-- Conversion errors
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: attempt to call field \'xxx_nonexistent_key_xxx\' (a nil value)',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: attempt to call field \'xxx_nonexistent_key_xxx\' (a nil value)',
|
||||||
exc_exec([[call luaeval("vim.xxx_nonexistent_key_xxx()")]]))
|
remove_trace(exc_exec([[call luaeval("vim.xxx_nonexistent_key_xxx()")]])))
|
||||||
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: ERROR',
|
eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: ERROR',
|
||||||
exc_exec([[call luaeval("error('ERROR')")]]))
|
remove_trace(exc_exec([[call luaeval("error('ERROR')")]])))
|
||||||
eq('Vim(call):E5108: Error executing lua [NULL]',
|
eq('Vim(call):E5108: Error executing lua [NULL]',
|
||||||
exc_exec([[call luaeval("error(nil)")]]))
|
remove_trace(exc_exec([[call luaeval("error(nil)")]])))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not leak memory when called with too long line',
|
it('does not leak memory when called with too long line',
|
||||||
|
@ -157,9 +157,6 @@ describe('debug.debug', function()
|
|||||||
]])
|
]])
|
||||||
feed('<C-c>')
|
feed('<C-c>')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
@ -170,6 +167,9 @@ describe('debug.debug', function()
|
|||||||
|
|
|
|
||||||
{E:E5108: Error executing lua [string ":lua"]:5: attempt}|
|
{E:E5108: Error executing lua [string ":lua"]:5: attempt}|
|
||||||
{E: to perform arithmetic on local 'a' (a nil value)} |
|
{E: to perform arithmetic on local 'a' (a nil value)} |
|
||||||
|
{E:stack traceback:} |
|
||||||
|
{E: [string ":lua"]:5: in function 'Test'} |
|
||||||
|
{E: [string ":lua"]:1: in main chunk} |
|
||||||
Interrupt: {cr:Press ENTER or type command to continue}^ |
|
Interrupt: {cr:Press ENTER or type command to continue}^ |
|
||||||
]]}
|
]]}
|
||||||
feed('<C-l>:lua Test()\n')
|
feed('<C-l>:lua Test()\n')
|
||||||
@ -197,13 +197,13 @@ describe('debug.debug', function()
|
|||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
{0:~ }|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
|
||||||
{0:~ }|
|
|
||||||
nil |
|
nil |
|
||||||
lua_debug> |
|
lua_debug> |
|
||||||
{E:E5108: Error executing lua [string ":lua"]:5: attempt}|
|
{E:E5108: Error executing lua [string ":lua"]:5: attempt}|
|
||||||
{E: to perform arithmetic on local 'a' (a nil value)} |
|
{E: to perform arithmetic on local 'a' (a nil value)} |
|
||||||
|
{E:stack traceback:} |
|
||||||
|
{E: [string ":lua"]:5: in function 'Test'} |
|
||||||
|
{E: [string ":lua"]:1: in main chunk} |
|
||||||
{cr:Press ENTER or type command to continue}^ |
|
{cr:Press ENTER or type command to continue}^ |
|
||||||
]]}
|
]]}
|
||||||
end)
|
end)
|
||||||
|
@ -4,7 +4,6 @@ local Screen = require('test.functional.ui.screen')
|
|||||||
|
|
||||||
local funcs = helpers.funcs
|
local funcs = helpers.funcs
|
||||||
local meths = helpers.meths
|
local meths = helpers.meths
|
||||||
local dedent = helpers.dedent
|
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local insert = helpers.insert
|
local insert = helpers.insert
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
@ -19,6 +18,7 @@ local source = helpers.source
|
|||||||
local NIL = helpers.NIL
|
local NIL = helpers.NIL
|
||||||
local retry = helpers.retry
|
local retry = helpers.retry
|
||||||
local next_msg = helpers.next_msg
|
local next_msg = helpers.next_msg
|
||||||
|
local remove_trace = helpers.remove_trace
|
||||||
|
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
@ -121,11 +121,6 @@ describe('lua stdlib', function()
|
|||||||
eq(1, funcs.luaeval('vim.stricmp("\\0C\\0", "\\0B\\0")'))
|
eq(1, funcs.luaeval('vim.stricmp("\\0C\\0", "\\0B\\0")'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- for brevity, match only the error header (not the traceback)
|
|
||||||
local function pcall_header(...)
|
|
||||||
return string.gsub(string.gsub(pcall_err(exec_lua, ...), '[\r\n].*', ''), '^Error executing lua: ', '')
|
|
||||||
end
|
|
||||||
|
|
||||||
it('vim.startswith', function()
|
it('vim.startswith', function()
|
||||||
eq(true, funcs.luaeval('vim.startswith("123", "1")'))
|
eq(true, funcs.luaeval('vim.startswith("123", "1")'))
|
||||||
eq(true, funcs.luaeval('vim.startswith("123", "")'))
|
eq(true, funcs.luaeval('vim.startswith("123", "")'))
|
||||||
@ -136,8 +131,10 @@ describe('lua stdlib', function()
|
|||||||
eq(false, funcs.luaeval('vim.startswith("123", "2")'))
|
eq(false, funcs.luaeval('vim.startswith("123", "2")'))
|
||||||
eq(false, funcs.luaeval('vim.startswith("123", "1234")'))
|
eq(false, funcs.luaeval('vim.startswith("123", "1234")'))
|
||||||
|
|
||||||
eq("vim/shared.lua:0: prefix: expected string, got nil", pcall_header 'return vim.startswith("123", nil)')
|
eq("Error executing lua: vim/shared.lua:0: prefix: expected string, got nil",
|
||||||
eq("vim/shared.lua:0: s: expected string, got nil", pcall_header 'return vim.startswith(nil, "123")')
|
pcall_err(exec_lua, 'return vim.startswith("123", nil)'))
|
||||||
|
eq("Error executing lua: vim/shared.lua:0: s: expected string, got nil",
|
||||||
|
pcall_err(exec_lua, 'return vim.startswith(nil, "123")'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('vim.endswith', function()
|
it('vim.endswith', function()
|
||||||
@ -150,8 +147,10 @@ describe('lua stdlib', function()
|
|||||||
eq(false, funcs.luaeval('vim.endswith("123", "2")'))
|
eq(false, funcs.luaeval('vim.endswith("123", "2")'))
|
||||||
eq(false, funcs.luaeval('vim.endswith("123", "1234")'))
|
eq(false, funcs.luaeval('vim.endswith("123", "1234")'))
|
||||||
|
|
||||||
eq("vim/shared.lua:0: suffix: expected string, got nil", pcall_header 'return vim.endswith("123", nil)')
|
eq("Error executing lua: vim/shared.lua:0: suffix: expected string, got nil",
|
||||||
eq("vim/shared.lua:0: s: expected string, got nil", pcall_header 'return vim.endswith(nil, "123")')
|
pcall_err(exec_lua, 'return vim.endswith("123", nil)'))
|
||||||
|
eq("Error executing lua: vim/shared.lua:0: s: expected string, got nil",
|
||||||
|
pcall_err(exec_lua, 'return vim.endswith(nil, "123")'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("vim.str_utfindex/str_byteindex", function()
|
it("vim.str_utfindex/str_byteindex", function()
|
||||||
@ -233,7 +232,7 @@ describe('lua stdlib', function()
|
|||||||
]])
|
]])
|
||||||
|
|
||||||
feed("<cr>")
|
feed("<cr>")
|
||||||
eq('Error executing vim.schedule lua callback: [string "<nvim>"]:2: big failure\nvery async', eval("v:errmsg"))
|
eq('Error executing vim.schedule lua callback: [string "<nvim>"]:2: big failure\nvery async', remove_trace(eval("v:errmsg")))
|
||||||
|
|
||||||
local screen = Screen.new(60,5)
|
local screen = Screen.new(60,5)
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
@ -259,10 +258,10 @@ describe('lua stdlib', function()
|
|||||||
end)
|
end)
|
||||||
]])
|
]])
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
|
|
{3:stack traceback:} |
|
||||||
{2: }|
|
{3: [C]: in function 'nvim_command'} |
|
||||||
{3:Error executing vim.schedule lua callback: [string "<nvim>"]}|
|
{3: [string "<nvim>"]:2: in function <[string "<nvim>"]:}|
|
||||||
{3::2: Vim(echo):E115: Missing quote: 'err} |
|
{3:1>} |
|
||||||
{4:Press ENTER or type command to continue}^ |
|
{4:Press ENTER or type command to continue}^ |
|
||||||
]]}
|
]]}
|
||||||
end)
|
end)
|
||||||
@ -306,22 +305,11 @@ describe('lua stdlib', function()
|
|||||||
|
|
||||||
-- Validates args.
|
-- Validates args.
|
||||||
eq(true, pcall(split, 'string', 'string'))
|
eq(true, pcall(split, 'string', 'string'))
|
||||||
eq(dedent([[
|
eq('Error executing lua: vim/shared.lua:0: s: expected string, got number',
|
||||||
Error executing lua: vim/shared.lua:0: s: expected string, got number
|
|
||||||
stack traceback:
|
|
||||||
vim/shared.lua:0: in function 'gsplit'
|
|
||||||
vim/shared.lua:0: in function <vim/shared.lua:0>]]),
|
|
||||||
pcall_err(split, 1, 'string'))
|
pcall_err(split, 1, 'string'))
|
||||||
eq(dedent([[
|
eq('Error executing lua: vim/shared.lua:0: sep: expected string, got number',
|
||||||
Error executing lua: vim/shared.lua:0: sep: expected string, got number
|
|
||||||
stack traceback:
|
|
||||||
vim/shared.lua:0: in function 'gsplit'
|
|
||||||
vim/shared.lua:0: in function <vim/shared.lua:0>]]),
|
|
||||||
pcall_err(split, 'string', 1))
|
pcall_err(split, 'string', 1))
|
||||||
eq(dedent([[
|
eq('Error executing lua: vim/shared.lua:0: kwargs: expected table, got number',
|
||||||
Error executing lua: vim/shared.lua:0: kwargs: expected table, got number
|
|
||||||
stack traceback:
|
|
||||||
vim/shared.lua:0: in function <vim/shared.lua:0>]]),
|
|
||||||
pcall_err(split, 'string', 'string', 1))
|
pcall_err(split, 'string', 'string', 1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -342,10 +330,7 @@ describe('lua stdlib', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Validates args.
|
-- Validates args.
|
||||||
eq(dedent([[
|
eq('Error executing lua: vim/shared.lua:0: s: expected string, got number',
|
||||||
Error executing lua: vim/shared.lua:0: s: expected string, got number
|
|
||||||
stack traceback:
|
|
||||||
vim/shared.lua:0: in function <vim/shared.lua:0>]]),
|
|
||||||
pcall_err(trim, 2))
|
pcall_err(trim, 2))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -424,10 +409,7 @@ describe('lua stdlib', function()
|
|||||||
eq('foo%%%-bar', exec_lua([[return vim.pesc(vim.pesc('foo-bar'))]]))
|
eq('foo%%%-bar', exec_lua([[return vim.pesc(vim.pesc('foo-bar'))]]))
|
||||||
|
|
||||||
-- Validates args.
|
-- Validates args.
|
||||||
eq(dedent([[
|
eq('Error executing lua: vim/shared.lua:0: s: expected string, got number',
|
||||||
Error executing lua: vim/shared.lua:0: s: expected string, got number
|
|
||||||
stack traceback:
|
|
||||||
vim/shared.lua:0: in function <vim/shared.lua:0>]]),
|
|
||||||
pcall_err(exec_lua, [[return vim.pesc(2)]]))
|
pcall_err(exec_lua, [[return vim.pesc(2)]]))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -710,10 +692,7 @@ describe('lua stdlib', function()
|
|||||||
|
|
||||||
it('vim.list_extend', function()
|
it('vim.list_extend', function()
|
||||||
eq({1,2,3}, exec_lua [[ return vim.list_extend({1}, {2,3}) ]])
|
eq({1,2,3}, exec_lua [[ return vim.list_extend({1}, {2,3}) ]])
|
||||||
eq(dedent([[
|
eq('Error executing lua: vim/shared.lua:0: src: expected table, got nil',
|
||||||
Error executing lua: vim/shared.lua:0: src: expected table, got nil
|
|
||||||
stack traceback:
|
|
||||||
vim/shared.lua:0: in function <vim/shared.lua:0>]]),
|
|
||||||
pcall_err(exec_lua, [[ return vim.list_extend({1}, nil) ]]))
|
pcall_err(exec_lua, [[ return vim.list_extend({1}, nil) ]]))
|
||||||
eq({1,2}, exec_lua [[ return vim.list_extend({1}, {2;a=1}) ]])
|
eq({1,2}, exec_lua [[ return vim.list_extend({1}, {2;a=1}) ]])
|
||||||
eq(true, exec_lua [[ local a = {1} return vim.list_extend(a, {2;a=1}) == a ]])
|
eq(true, exec_lua [[ local a = {1} return vim.list_extend(a, {2;a=1}) == a ]])
|
||||||
@ -845,12 +824,12 @@ describe('lua stdlib', function()
|
|||||||
end)
|
end)
|
||||||
]])
|
]])
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
foo |
|
|
||||||
{1:~ }|
|
|
||||||
{2: }|
|
|
||||||
{3:Error executing luv callback:} |
|
|
||||||
{3:[string "<nvim>"]:6: E5560: rpcrequest must not be}|
|
{3:[string "<nvim>"]:6: E5560: rpcrequest must not be}|
|
||||||
{3: called in a lua loop callback} |
|
{3: called in a lua loop callback} |
|
||||||
|
{3:stack traceback:} |
|
||||||
|
{3: [C]: in function 'rpcrequest'} |
|
||||||
|
{3: [string "<nvim>"]:6: in function <[string }|
|
||||||
|
{3:"<nvim>"]:2>} |
|
||||||
{4:Press ENTER or type command to continue}^ |
|
{4:Press ENTER or type command to continue}^ |
|
||||||
]]}
|
]]}
|
||||||
feed('<cr>')
|
feed('<cr>')
|
||||||
@ -914,76 +893,37 @@ describe('lua stdlib', function()
|
|||||||
exec_lua("vim.validate{arg1={{}, 't' }, arg2={ 'foo', 's' }}")
|
exec_lua("vim.validate{arg1={{}, 't' }, arg2={ 'foo', 's' }}")
|
||||||
exec_lua("vim.validate{arg1={2, function(a) return (a % 2) == 0 end, 'even number' }}")
|
exec_lua("vim.validate{arg1={2, function(a) return (a % 2) == 0 end, 'even number' }}")
|
||||||
|
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: opt[1]: expected table, got number',
|
||||||
Error executing lua: [string "<nvim>"]:0: opt[1]: expected table, got number
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{ 1, 'x' }"))
|
pcall_err(exec_lua, "vim.validate{ 1, 'x' }"))
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: invalid type name: x',
|
||||||
Error executing lua: [string "<nvim>"]:0: invalid type name: x
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{ arg1={ 1, 'x' }}"))
|
pcall_err(exec_lua, "vim.validate{ arg1={ 1, 'x' }}"))
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: invalid type name: 1',
|
||||||
Error executing lua: [string "<nvim>"]:0: invalid type name: 1
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{ arg1={ 1, 1 }}"))
|
pcall_err(exec_lua, "vim.validate{ arg1={ 1, 1 }}"))
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: invalid type name: nil',
|
||||||
Error executing lua: [string "<nvim>"]:0: invalid type name: nil
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{ arg1={ 1 }}"))
|
pcall_err(exec_lua, "vim.validate{ arg1={ 1 }}"))
|
||||||
|
|
||||||
-- Validated parameters are required by default.
|
-- Validated parameters are required by default.
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: arg1: expected string, got nil',
|
||||||
Error executing lua: [string "<nvim>"]:0: arg1: expected string, got nil
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{ arg1={ nil, 's' }}"))
|
pcall_err(exec_lua, "vim.validate{ arg1={ nil, 's' }}"))
|
||||||
-- Explicitly required.
|
-- Explicitly required.
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: arg1: expected string, got nil',
|
||||||
Error executing lua: [string "<nvim>"]:0: arg1: expected string, got nil
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{ arg1={ nil, 's', false }}"))
|
pcall_err(exec_lua, "vim.validate{ arg1={ nil, 's', false }}"))
|
||||||
|
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: arg1: expected table, got number',
|
||||||
Error executing lua: [string "<nvim>"]:0: arg1: expected table, got number
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{arg1={1, 't'}}"))
|
pcall_err(exec_lua, "vim.validate{arg1={1, 't'}}"))
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: arg2: expected string, got number',
|
||||||
Error executing lua: [string "<nvim>"]:0: arg2: expected string, got number
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{arg1={{}, 't'}, arg2={1, 's'}}"))
|
pcall_err(exec_lua, "vim.validate{arg1={{}, 't'}, arg2={1, 's'}}"))
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: arg2: expected string, got nil',
|
||||||
Error executing lua: [string "<nvim>"]:0: arg2: expected string, got nil
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{arg1={{}, 't'}, arg2={nil, 's'}}"))
|
pcall_err(exec_lua, "vim.validate{arg1={{}, 't'}, arg2={nil, 's'}}"))
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: arg2: expected string, got nil',
|
||||||
Error executing lua: [string "<nvim>"]:0: arg2: expected string, got nil
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{arg1={{}, 't'}, arg2={nil, 's'}}"))
|
pcall_err(exec_lua, "vim.validate{arg1={{}, 't'}, arg2={nil, 's'}}"))
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: arg1: expected even number, got 3',
|
||||||
Error executing lua: [string "<nvim>"]:0: arg1: expected even number, got 3
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{arg1={3, function(a) return a == 1 end, 'even number'}}"))
|
pcall_err(exec_lua, "vim.validate{arg1={3, function(a) return a == 1 end, 'even number'}}"))
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: arg1: expected ?, got 3',
|
||||||
Error executing lua: [string "<nvim>"]:0: arg1: expected ?, got 3
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{arg1={3, function(a) return a == 1 end}}"))
|
pcall_err(exec_lua, "vim.validate{arg1={3, function(a) return a == 1 end}}"))
|
||||||
|
|
||||||
-- Pass an additional message back.
|
-- Pass an additional message back.
|
||||||
eq(dedent([[
|
eq('Error executing lua: [string "<nvim>"]:0: arg1: expected ?, got 3. Info: TEST_MSG',
|
||||||
Error executing lua: [string "<nvim>"]:0: arg1: expected ?, got 3. Info: TEST_MSG
|
|
||||||
stack traceback:
|
|
||||||
[string "<nvim>"]:0: in main chunk]]),
|
|
||||||
pcall_err(exec_lua, "vim.validate{arg1={3, function(a) return a == 1, 'TEST_MSG' end}}"))
|
pcall_err(exec_lua, "vim.validate{arg1={3, function(a) return a == 1, 'TEST_MSG' end}}"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -2133,9 +2073,10 @@ describe('lua stdlib', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('should not crash when callback errors', function()
|
it('should not crash when callback errors', function()
|
||||||
eq({false, '[string "<nvim>"]:1: As Expected'}, exec_lua [[
|
local result = exec_lua [[
|
||||||
return {pcall(function() vim.wait(1000, function() error("As Expected") end) end)}
|
return {pcall(function() vim.wait(1000, function() error("As Expected") end) end)}
|
||||||
]])
|
]]
|
||||||
|
eq({false, '[string "<nvim>"]:1: As Expected'}, {result[1], remove_trace(result[2])})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('if callback is passed, it must be a function', function()
|
it('if callback is passed, it must be a function', function()
|
||||||
|
@ -134,7 +134,7 @@ describe('health.vim', function()
|
|||||||
command("checkhealth test_plug*")
|
command("checkhealth test_plug*")
|
||||||
local buf_lines = helpers.curbuf('get_lines', 0, -1, true)
|
local buf_lines = helpers.curbuf('get_lines', 0, -1, true)
|
||||||
-- avoid dealing with path separators
|
-- avoid dealing with path separators
|
||||||
local received = table.concat(buf_lines, '\n', 1, #buf_lines - 2)
|
local received = table.concat(buf_lines, '\n', 1, #buf_lines - 5)
|
||||||
local expected = helpers.dedent([[
|
local expected = helpers.dedent([[
|
||||||
|
|
||||||
test_plug: require("test_plug.health").check()
|
test_plug: require("test_plug.health").check()
|
||||||
@ -175,10 +175,10 @@ describe('health.vim', function()
|
|||||||
it("gracefully handles broken lua healthcheck", function()
|
it("gracefully handles broken lua healthcheck", function()
|
||||||
command("checkhealth test_plug.submodule_failed")
|
command("checkhealth test_plug.submodule_failed")
|
||||||
local buf_lines = helpers.curbuf('get_lines', 0, -1, true)
|
local buf_lines = helpers.curbuf('get_lines', 0, -1, true)
|
||||||
local received = table.concat(buf_lines, '\n', 1, #buf_lines - 2)
|
local received = table.concat(buf_lines, '\n', 1, #buf_lines - 5)
|
||||||
-- avoid dealing with path separators
|
-- avoid dealing with path separators
|
||||||
local lua_err = "attempt to perform arithmetic on a nil value"
|
local lua_err = "attempt to perform arithmetic on a nil value"
|
||||||
local last_line = buf_lines[#buf_lines - 1]
|
local last_line = buf_lines[#buf_lines - 4]
|
||||||
assert(string.find(last_line, lua_err) ~= nil, "Lua error not present")
|
assert(string.find(last_line, lua_err) ~= nil, "Lua error not present")
|
||||||
|
|
||||||
local expected = global_helpers.dedent([[
|
local expected = global_helpers.dedent([[
|
||||||
|
@ -1153,15 +1153,9 @@ describe('LSP', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('should invalid cmd argument', function()
|
it('should invalid cmd argument', function()
|
||||||
eq(dedent([[
|
eq('Error executing lua: .../lsp.lua:0: cmd: expected list, got nvim',
|
||||||
Error executing lua: .../lsp.lua:0: cmd: expected list, got nvim
|
|
||||||
stack traceback:
|
|
||||||
.../lsp.lua:0: in function <.../lsp.lua:0>]]),
|
|
||||||
pcall_err(_cmd_parts, 'nvim'))
|
pcall_err(_cmd_parts, 'nvim'))
|
||||||
eq(dedent([[
|
eq('Error executing lua: .../lsp.lua:0: cmd argument: expected string, got number',
|
||||||
Error executing lua: .../lsp.lua:0: cmd argument: expected string, got number
|
|
||||||
stack traceback:
|
|
||||||
.../lsp.lua:0: in function <.../lsp.lua:0>]]),
|
|
||||||
pcall_err(_cmd_parts, {'nvim', 1}))
|
pcall_err(_cmd_parts, {'nvim', 1}))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -494,6 +494,8 @@ describe('TUI', function()
|
|||||||
it('paste: recovers from vim.paste() failure', function()
|
it('paste: recovers from vim.paste() failure', function()
|
||||||
child_session:request('nvim_exec_lua', [[
|
child_session:request('nvim_exec_lua', [[
|
||||||
_G.save_paste_fn = vim.paste
|
_G.save_paste_fn = vim.paste
|
||||||
|
-- Stack traces for this test are non-deterministic, so disable them
|
||||||
|
_G.debug.traceback = function(msg) return msg end
|
||||||
vim.paste = function(lines, phase) error("fake fail") end
|
vim.paste = function(lines, phase) error("fake fail") end
|
||||||
]], {})
|
]], {})
|
||||||
-- Prepare something for dot-repeat/redo.
|
-- Prepare something for dot-repeat/redo.
|
||||||
@ -514,7 +516,7 @@ describe('TUI', function()
|
|||||||
foo |
|
foo |
|
||||||
|
|
|
|
||||||
{5: }|
|
{5: }|
|
||||||
{8:paste: Error executing lua: [string "<nvim>"]:2: f}|
|
{8:paste: Error executing lua: [string "<nvim>"]:4: f}|
|
||||||
{8:ake fail} |
|
{8:ake fail} |
|
||||||
{10:Press ENTER or type command to continue}{1: } |
|
{10:Press ENTER or type command to continue}{1: } |
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
@ -579,12 +581,16 @@ describe('TUI', function()
|
|||||||
|
|
||||||
it("paste: 'nomodifiable' buffer", function()
|
it("paste: 'nomodifiable' buffer", function()
|
||||||
child_session:request('nvim_command', 'set nomodifiable')
|
child_session:request('nvim_command', 'set nomodifiable')
|
||||||
|
child_session:request('nvim_exec_lua', [[
|
||||||
|
-- Stack traces for this test are non-deterministic, so disable them
|
||||||
|
_G.debug.traceback = function(msg) return msg end
|
||||||
|
]], {})
|
||||||
feed_data('\027[200~fail 1\nfail 2\n\027[201~')
|
feed_data('\027[200~fail 1\nfail 2\n\027[201~')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
|
|
|
|
||||||
{4:~ }|
|
{4:~ }|
|
||||||
{5: }|
|
{5: }|
|
||||||
{MATCH:paste: Error executing lua: vim.lua:%d+: Vim:E21: }|
|
{8:paste: Error executing lua: vim.lua:243: Vim:E21: }|
|
||||||
{8:Cannot make changes, 'modifiable' is off} |
|
{8:Cannot make changes, 'modifiable' is off} |
|
||||||
{10:Press ENTER or type command to continue}{1: } |
|
{10:Press ENTER or type command to continue}{1: } |
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
@ -671,8 +677,8 @@ describe('TUI', function()
|
|||||||
item 2997 |
|
item 2997 |
|
||||||
item 2998 |
|
item 2998 |
|
||||||
item 2999 |
|
item 2999 |
|
||||||
item 3000 en{1:d}d |
|
item 3000 en{1:d} |
|
||||||
{5:[No Name] [+] 5999,13 Bot}|
|
{5:[No Name] [+] 3000,13 Bot}|
|
||||||
|
|
|
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
|
@ -750,8 +750,13 @@ describe('ui/ext_messages', function()
|
|||||||
{1:~ }|
|
{1:~ }|
|
||||||
{1:~ }|
|
{1:~ }|
|
||||||
]], messages={{
|
]], messages={{
|
||||||
content = {{'E5108: Error executing lua [string ":lua"]:1: such\nmultiline\nerror', 2}},
|
content = {{[[E5108: Error executing lua [string ":lua"]:1: such
|
||||||
kind = "lua_error"
|
multiline
|
||||||
|
error
|
||||||
|
stack traceback:
|
||||||
|
[C]: in function 'error'
|
||||||
|
[string ":lua"]:1: in main chunk]], 2}},
|
||||||
|
kind = "lua_error",
|
||||||
}}}
|
}}}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -1048,12 +1053,12 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
|
|||||||
-- edge case: just covers statusline
|
-- edge case: just covers statusline
|
||||||
feed(':set colorcolumn=5 | lua error("x\\n\\nx")<cr>')
|
feed(':set colorcolumn=5 | lua error("x\\n\\nx")<cr>')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
|
|
|
||||||
{1:~ }|
|
|
||||||
{3: }|
|
|
||||||
{2:E5108: Error executing lua [string ":lua"]:1: x} |
|
{2:E5108: Error executing lua [string ":lua"]:1: x} |
|
||||||
|
|
|
|
||||||
{2:x} |
|
{2:x} |
|
||||||
|
{2:stack traceback:} |
|
||||||
|
{2: [C]: in function 'error'} |
|
||||||
|
{2: [string ":lua"]:1: in main chunk} |
|
||||||
{4:Press ENTER or type command to continue}^ |
|
{4:Press ENTER or type command to continue}^ |
|
||||||
]]}
|
]]}
|
||||||
|
|
||||||
@ -1071,24 +1076,24 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim
|
|||||||
-- edge case: just covers lowest window line
|
-- edge case: just covers lowest window line
|
||||||
feed(':set colorcolumn=5 | lua error("x\\n\\n\\nx")<cr>')
|
feed(':set colorcolumn=5 | lua error("x\\n\\n\\nx")<cr>')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
|
|
|
||||||
{3: }|
|
|
||||||
{2:E5108: Error executing lua [string ":lua"]:1: x} |
|
{2:E5108: Error executing lua [string ":lua"]:1: x} |
|
||||||
|
|
|
|
||||||
|
|
|
|
||||||
{2:x} |
|
{2:x} |
|
||||||
{4:Press ENTER or type command to continue}^ |
|
{2:stack traceback:} |
|
||||||
|
{2: [C]: in function 'error'} |
|
||||||
|
{4:-- More --}^ |
|
||||||
]]}
|
]]}
|
||||||
|
|
||||||
feed('<cr>')
|
feed('<cr>')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
|
|
|
|
||||||
{1:~ }|
|
|
||||||
{8:[No Name] }|
|
|
||||||
^ {9: } |
|
|
||||||
{1:~ }|
|
|
||||||
{3:[No Name] }|
|
|
||||||
|
|
|
|
||||||
|
{2:x} |
|
||||||
|
{2:stack traceback:} |
|
||||||
|
{2: [C]: in function 'error'} |
|
||||||
|
{2: [string ":lua"]:1: in main chunk} |
|
||||||
|
{4:Press ENTER or type command to continue}^ |
|
||||||
]]}
|
]]}
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
@ -1360,14 +1365,14 @@ aliquip ex ea commodo consequat.]])
|
|||||||
]]}
|
]]}
|
||||||
feed('d')
|
feed('d')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
|
{2:mpor} |
|
||||||
{2:incididunt ut labore et dolore magn}|
|
{2:incididunt ut labore et dolore magn}|
|
||||||
{2:a aliqua.} |
|
{2:a aliqua.} |
|
||||||
{2:Ut enim ad minim veniam, quis nostr}|
|
{2:Ut enim ad minim veniam, quis nostr}|
|
||||||
{2:ud xercitation} |
|
{2:ud xercitation} |
|
||||||
{2:ullamco laboris nisi ut} |
|
{2:ullamco laboris nisi ut} |
|
||||||
{2:aliquip ex ea commodo consequat.} |
|
{2:aliquip ex ea commodo consequat.} |
|
||||||
{4:Press ENTER or type command to cont}|
|
{4:-- More --}^ |
|
||||||
{4:inue}^ |
|
|
||||||
]]}
|
]]}
|
||||||
feed('u')
|
feed('u')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
@ -1460,14 +1465,14 @@ aliquip ex ea commodo consequat.]])
|
|||||||
]]}
|
]]}
|
||||||
feed('d')
|
feed('d')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
|
{3:mpor}{5: }|
|
||||||
{3:incididunt ut labore et dolore magn}|
|
{3:incididunt ut labore et dolore magn}|
|
||||||
{3:a aliqua.}{5: }|
|
{3:a aliqua.}{5: }|
|
||||||
{3:Ut enim ad minim veniam, quis nostr}|
|
{3:Ut enim ad minim veniam, quis nostr}|
|
||||||
{3:ud xercitation}{5: }|
|
{3:ud xercitation}{5: }|
|
||||||
{3:ullamco laboris nisi ut}{5: }|
|
{3:ullamco laboris nisi ut}{5: }|
|
||||||
{3:aliquip ex ea commodo consequat.}{5: }|
|
{3:aliquip ex ea commodo consequat.}{5: }|
|
||||||
{6:Press ENTER or type command to cont}|
|
{6:-- More --}{5:^ }|
|
||||||
{6:inue}{5:^ }|
|
|
||||||
]]}
|
]]}
|
||||||
feed('u')
|
feed('u')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
@ -1667,6 +1672,7 @@ aliquip ex ea commodo consequat.]])
|
|||||||
-- wrapped at the new screen size.
|
-- wrapped at the new screen size.
|
||||||
feed('<cr>')
|
feed('<cr>')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
|
{2:":lua"]:1: Lorem ipsum dolor s}|
|
||||||
{2:et, consectetur} |
|
{2:et, consectetur} |
|
||||||
{2:adipisicing elit, sed do eiusm}|
|
{2:adipisicing elit, sed do eiusm}|
|
||||||
{2:mpore} |
|
{2:mpore} |
|
||||||
@ -1677,8 +1683,7 @@ aliquip ex ea commodo consequat.]])
|
|||||||
{2:ullamco laboris nisi ut} |
|
{2:ullamco laboris nisi ut} |
|
||||||
{2:aliquip ex ea commodo consequa}|
|
{2:aliquip ex ea commodo consequa}|
|
||||||
{2:t.} |
|
{2:t.} |
|
||||||
{4:Press ENTER or type command to}|
|
{4:-- More --}^ |
|
||||||
{4: continue}^ |
|
|
||||||
]]}
|
]]}
|
||||||
|
|
||||||
feed('q')
|
feed('q')
|
||||||
|
@ -155,12 +155,20 @@ function module.pcall_err_withfile(fn, ...)
|
|||||||
return errmsg
|
return errmsg
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.pcall_err(fn, ...)
|
function module.pcall_err_withtrace(fn, ...)
|
||||||
local errmsg = module.pcall_err_withfile(fn, ...)
|
local errmsg = module.pcall_err_withfile(fn, ...)
|
||||||
|
|
||||||
return errmsg:gsub('.../helpers.lua:0: ', '')
|
return errmsg:gsub('.../helpers.lua:0: ', '')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function module.pcall_err(...)
|
||||||
|
return module.remove_trace(module.pcall_err_withtrace(...))
|
||||||
|
end
|
||||||
|
|
||||||
|
function module.remove_trace(s)
|
||||||
|
return (s:gsub("\n%s*stack traceback:.*", ""))
|
||||||
|
end
|
||||||
|
|
||||||
-- initial_path: directory to recurse into
|
-- initial_path: directory to recurse into
|
||||||
-- re: include pattern (string)
|
-- re: include pattern (string)
|
||||||
-- exc_re: exclude pattern(s) (string or table)
|
-- exc_re: exclude pattern(s) (string or table)
|
||||||
|
Reference in New Issue
Block a user