mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(tests): fixes for using vim.mpack and more ASAN
This commit is contained in:
parent
d6279f9392
commit
f8f82901cd
@ -644,7 +644,13 @@ static void lmpack_unparse_enter(mpack_parser_t *parser, mpack_node_t *node)
|
|||||||
mpack_node_t *n;
|
mpack_node_t *n;
|
||||||
|
|
||||||
int has_meta = lua_getmetatable(L, -1);
|
int has_meta = lua_getmetatable(L, -1);
|
||||||
if (packer->ext != LUA_NOREF && has_meta) {
|
int has_mtdict = false;
|
||||||
|
if (has_meta && packer->mtdict != LUA_NOREF) {
|
||||||
|
lmpack_geti(L, packer->reg, packer->mtdict); // [table, metatable, mtdict]
|
||||||
|
has_mtdict = lua_rawequal(L, -1, -2);
|
||||||
|
lua_pop(L, 1); // [table, metatable];
|
||||||
|
}
|
||||||
|
if (packer->ext != LUA_NOREF && has_meta && !has_mtdict) {
|
||||||
/* check if there's a handler for this metatable */
|
/* check if there's a handler for this metatable */
|
||||||
lmpack_geti(L, packer->reg, packer->ext);
|
lmpack_geti(L, packer->reg, packer->ext);
|
||||||
lua_pushvalue(L, -2);
|
lua_pushvalue(L, -2);
|
||||||
@ -701,14 +707,7 @@ static void lmpack_unparse_enter(mpack_parser_t *parser, mpack_node_t *node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_array = 1;
|
|
||||||
if (has_meta) {
|
if (has_meta) {
|
||||||
// stack: [table, metatable]
|
|
||||||
if (packer->mtdict != LUA_NOREF) {
|
|
||||||
lmpack_geti(L, packer->reg, packer->mtdict); // [table, metatable, mtdict]
|
|
||||||
is_array = !lua_rawequal(L, -1, -2);
|
|
||||||
lua_pop(L, 1); // [table, metatable];
|
|
||||||
}
|
|
||||||
lua_pop(L, 1); // [table]
|
lua_pop(L, 1); // [table]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -726,6 +725,7 @@ static void lmpack_unparse_enter(mpack_parser_t *parser, mpack_node_t *node)
|
|||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int is_array = !has_mtdict;
|
||||||
len = lmpack_objlen(L, &is_array);
|
len = lmpack_objlen(L, &is_array);
|
||||||
if (is_array) {
|
if (is_array) {
|
||||||
node->tok = mpack_pack_array(len);
|
node->tok = mpack_pack_array(len);
|
||||||
|
@ -128,8 +128,11 @@ MPACK_API int mpack_unparse(mpack_parser_t *parser, char **buf, size_t *buflen,
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
MPACK_API void mpack_parser_copy(mpack_parser_t *dst, mpack_parser_t *src)
|
MPACK_API void mpack_parser_copy(mpack_parser_t *d, mpack_parser_t *s)
|
||||||
{
|
{
|
||||||
|
// workaround UBSAN being NOT happy with a flexible array member with arr[N>1] initial size
|
||||||
|
mpack_one_parser_t *dst = (mpack_one_parser_t *)d;
|
||||||
|
mpack_one_parser_t *src = (mpack_one_parser_t *)s;
|
||||||
mpack_uint32_t i;
|
mpack_uint32_t i;
|
||||||
mpack_uint32_t dst_capacity = dst->capacity;
|
mpack_uint32_t dst_capacity = dst->capacity;
|
||||||
assert(src->capacity <= dst_capacity);
|
assert(src->capacity <= dst_capacity);
|
||||||
@ -148,8 +151,9 @@ static int mpack_parser_full(mpack_parser_t *parser)
|
|||||||
return parser->size == parser->capacity;
|
return parser->size == parser->capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
static mpack_node_t *mpack_parser_push(mpack_parser_t *parser)
|
static mpack_node_t *mpack_parser_push(mpack_parser_t *p)
|
||||||
{
|
{
|
||||||
|
mpack_one_parser_t *parser = (mpack_one_parser_t *)p;
|
||||||
mpack_node_t *top;
|
mpack_node_t *top;
|
||||||
assert(parser->size < parser->capacity);
|
assert(parser->size < parser->capacity);
|
||||||
top = parser->items + parser->size + 1;
|
top = parser->items + parser->size + 1;
|
||||||
@ -162,8 +166,9 @@ static mpack_node_t *mpack_parser_push(mpack_parser_t *parser)
|
|||||||
return top;
|
return top;
|
||||||
}
|
}
|
||||||
|
|
||||||
static mpack_node_t *mpack_parser_pop(mpack_parser_t *parser)
|
static mpack_node_t *mpack_parser_pop(mpack_parser_t *p)
|
||||||
{
|
{
|
||||||
|
mpack_one_parser_t *parser = (mpack_one_parser_t *)p;
|
||||||
mpack_node_t *top, *parent;
|
mpack_node_t *top, *parent;
|
||||||
assert(parser->size);
|
assert(parser->size);
|
||||||
top = parser->items + parser->size;
|
top = parser->items + parser->size;
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
package.path = arg[1]
|
package.path = arg[1]
|
||||||
package.cpath = arg[2]
|
package.cpath = arg[2]
|
||||||
|
|
||||||
local mpack = require('mpack')
|
local StdioStream = require'test.client.uv_stream'.StdioStream
|
||||||
local StdioStream = require('nvim.stdio_stream')
|
local Session = require'test.client.session'
|
||||||
local Session = require('nvim.session')
|
|
||||||
|
|
||||||
local stdio_stream = StdioStream.open()
|
local stdio_stream = StdioStream.open()
|
||||||
local session = Session.new(stdio_stream)
|
local session = Session.new(stdio_stream)
|
||||||
@ -19,7 +18,7 @@ local function on_request(method, args)
|
|||||||
return "done!"
|
return "done!"
|
||||||
elseif method == "exit" then
|
elseif method == "exit" then
|
||||||
session:stop()
|
session:stop()
|
||||||
return mpack.NIL
|
return vim.NIL
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ describe('server -> client', function()
|
|||||||
\ }
|
\ }
|
||||||
]])
|
]])
|
||||||
meths.set_var("args", {
|
meths.set_var("args", {
|
||||||
helpers.test_lua_prg,
|
nvim_prog, '-ll',
|
||||||
'test/functional/api/rpc_fixture.lua',
|
'test/functional/api/rpc_fixture.lua',
|
||||||
package.path,
|
package.path,
|
||||||
package.cpath,
|
package.cpath,
|
||||||
|
@ -59,7 +59,7 @@ describe('API', function()
|
|||||||
|
|
||||||
-- XXX: This must be the last one, else next one will fail:
|
-- XXX: This must be the last one, else next one will fail:
|
||||||
-- "Packer instance already working. Use another Packer ..."
|
-- "Packer instance already working. Use another Packer ..."
|
||||||
matches("can't serialize object$",
|
matches("can't serialize object of type .$",
|
||||||
pcall_err(request, nil))
|
pcall_err(request, nil))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -126,11 +126,11 @@ describe('ShaDa support code', function()
|
|||||||
wshada(s .. table.concat(msgpack, e .. s) .. e)
|
wshada(s .. table.concat(msgpack, e .. s) .. e)
|
||||||
eq(0, exc_exec('wshada ' .. shada_fname))
|
eq(0, exc_exec('wshada ' .. shada_fname))
|
||||||
local found = 0
|
local found = 0
|
||||||
local typ = mpack.unpack(s)
|
local typ = mpack.decode(s)
|
||||||
for _, v in ipairs(read_shada_file(shada_fname)) do
|
for _, v in ipairs(read_shada_file(shada_fname)) do
|
||||||
if v.type == typ then
|
if v.type == typ then
|
||||||
found = found + 1
|
found = found + 1
|
||||||
eq(mpack.unpack(msgpack[found]), v.timestamp)
|
eq(mpack.decode(msgpack[found]), v.timestamp)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
eq(#msgpack, found)
|
eq(#msgpack, found)
|
||||||
|
Loading…
Reference in New Issue
Block a user