aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/vim_spec.lua2
-rw-r--r--test/functional/ex_cmds/oldfiles_spec.lua3
-rw-r--r--test/functional/ex_cmds/wundo_spec.lua2
-rw-r--r--test/functional/ex_cmds/wviminfo_spec.lua2
-rw-r--r--test/functional/helpers.lua21
-rw-r--r--test/functional/plugin/helpers.lua2
-rw-r--r--test/functional/plugin/shada_spec.lua45
-rw-r--r--test/functional/shada/compatibility_spec.lua2
-rw-r--r--test/functional/shada/helpers.lua20
-rw-r--r--test/functional/shada/registers_spec.lua18
-rw-r--r--test/functional/shada/shada_spec.lua16
-rw-r--r--test/functional/terminal/cursor_spec.lua2
-rw-r--r--test/functional/ui/screen.lua2
13 files changed, 50 insertions, 87 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 99f67fe43a..699a0bd588 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -80,7 +80,7 @@ describe('vim_* functions', function()
it('set_var returns the old value', function()
local val1 = {1, 2, {['3'] = 1}}
local val2 = {4, 7}
- eq(nil, nvim('set_var', 'lua', val1))
+ eq(NIL, nvim('set_var', 'lua', val1))
eq(val1, nvim('set_var', 'lua', val2))
end)
diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua
index dac6757a97..3d90d20ab3 100644
--- a/test/functional/ex_cmds/oldfiles_spec.lua
+++ b/test/functional/ex_cmds/oldfiles_spec.lua
@@ -62,6 +62,9 @@ describe(':oldfiles!', function()
_clear()
execute('rshada! ' .. shada_file)
+ -- Ensure nvim is out of "Press ENTER..." screen
+ feed('<cr>')
+
-- Ensure v:oldfiles isn't busted. Since things happen so fast,
-- the ordering of v:oldfiles is unstable (it uses qsort() under-the-hood).
-- Let's verify the contents and the length of v:oldfiles before moving on.
diff --git a/test/functional/ex_cmds/wundo_spec.lua b/test/functional/ex_cmds/wundo_spec.lua
index c3147e1c0f..969dfea3d9 100644
--- a/test/functional/ex_cmds/wundo_spec.lua
+++ b/test/functional/ex_cmds/wundo_spec.lua
@@ -24,6 +24,6 @@ describe('u_* functions', function()
'-c', 'set undodir=. undofile'})
set_session(session)
execute('echo "True"') -- Should not error out due to crashed Neovim
- session:exit(0)
+ session:close()
end)
end)
diff --git a/test/functional/ex_cmds/wviminfo_spec.lua b/test/functional/ex_cmds/wviminfo_spec.lua
index 207d94124f..21f14be62c 100644
--- a/test/functional/ex_cmds/wviminfo_spec.lua
+++ b/test/functional/ex_cmds/wviminfo_spec.lua
@@ -9,7 +9,7 @@ describe(':wshada', function()
before_each(function()
if session then
- session:exit(0)
+ session:close()
end
-- Override the default session because we need 'swapfile' for these tests.
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 4e294029ab..a382641cff 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -1,9 +1,8 @@
require('coxpcall')
+NIL = require('mpack').NIL
local lfs = require('lfs')
local assert = require('luassert')
-local Loop = require('nvim.loop')
-local MsgpackStream = require('nvim.msgpack_stream')
-local AsyncSession = require('nvim.async_session')
+local ChildProcessStream = require('nvim.child_process_stream')
local Session = require('nvim.session')
local nvim_prog = os.getenv('NVIM_PROG') or 'build/bin/nvim'
@@ -59,6 +58,9 @@ end
local session, loop_running, last_error
local function set_session(s)
+ if session then
+ session:close()
+ end
session = s
end
@@ -209,24 +211,17 @@ local function merge_args(...)
end
local function spawn(argv, merge)
- local loop = Loop.new()
- local msgpack_stream = MsgpackStream.new(loop)
- local async_session = AsyncSession.new(msgpack_stream)
- local sess = Session.new(async_session)
- loop:spawn(merge and merge_args(prepend_argv, argv) or argv)
- return sess
+ local child_stream = ChildProcessStream.spawn(merge and merge_args(prepend_argv, argv) or argv)
+ return Session.new(child_stream)
end
local function clear(extra_cmd)
- if session then
- session:exit(0)
- end
local args = {unpack(nvim_argv)}
if extra_cmd ~= nil then
table.insert(args, '--cmd')
table.insert(args, extra_cmd)
end
- session = spawn(args)
+ set_session(spawn(args))
end
local function insert(...)
diff --git a/test/functional/plugin/helpers.lua b/test/functional/plugin/helpers.lua
index cc76794267..5b6ea88c34 100644
--- a/test/functional/plugin/helpers.lua
+++ b/test/functional/plugin/helpers.lua
@@ -25,7 +25,7 @@ local session = nil
local reset = function(...)
if session then
- session:exit(0)
+ session:close()
end
session = spawn(nvim_argv(...))
set_session(session)
diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua
index a3f617eeb0..aad0e366bf 100644
--- a/test/functional/plugin/shada_spec.lua
+++ b/test/functional/plugin/shada_spec.lua
@@ -4,7 +4,7 @@ local eq, nvim_eval, nvim_command, nvim, exc_exec, funcs, nvim_feed, curbuf =
helpers.funcs, helpers.feed, helpers.curbuf
local neq = helpers.neq
-local msgpack = require('MessagePack')
+local mpack = require('mpack')
local plugin_helpers = require('test.functional.plugin.helpers')
local reset = plugin_helpers.reset
@@ -15,13 +15,13 @@ local get_shada_rw = shada_helpers.get_shada_rw
local mpack_eq = function(expected, mpack_result)
local mpack_keys = {'type', 'timestamp', 'length', 'value'}
- local unpacker = msgpack.unpacker(mpack_result)
+ local unpack = mpack.Unpacker()
local actual = {}
- local cur
+ local cur, val
local i = 0
- while true do
- local off, val = unpacker()
- if not off then break end
+ local off = 1
+ while off <= #mpack_result do
+ val, off = unpack(mpack_result, off)
if i % 4 == 0 then
cur = {}
actual[#actual + 1] = cur
@@ -78,36 +78,6 @@ describe('In autoload/shada.vim', function()
return ('{"_TYPE": v:msgpack_types.%s, "_VAL": %s}'):format(typ, val)
end
- local st_meta = {
- __pairs=function(table)
- local ret = {}
- local next_key = nil
- local num_keys = 0
- while true do
- next_key = next(table, next_key)
- if next_key == nil then
- break
- end
- num_keys = num_keys + 1
- ret[num_keys] = {next_key, table[next_key]}
- end
- table.sort(ret, function(a, b)
- return a[1] < b[1]
- end)
- local state = {i=0}
- return (function(state_, _)
- state_.i = state_.i + 1
- if ret[state_.i] then
- return table.unpack(ret[state_.i])
- end
- end), state
- end
- }
-
- local st = function(table)
- return setmetatable(table, st_meta)
- end
-
describe('function shada#mpack_to_sd', function()
local mpack2sd = function(arg)
return ('shada#mpack_to_sd(%s)'):format(arg)
@@ -184,7 +154,7 @@ describe('In autoload/shada.vim', function()
' + b 2',
' + c column 3',
' + d 4',
- }, {{type=1, timestamp=0, data=st({a=1, b=2, c=3, d=4})}})
+ }, {{type=1, timestamp=0, data={a=1, b=2, c=3, d=4}}})
sd2strings_eq({
'Header with timestamp ' .. epoch .. ':',
' % Key Value',
@@ -2848,3 +2818,4 @@ describe('syntax/shada.vim', function()
eq(exp, act)
end)
end)
+
diff --git a/test/functional/shada/compatibility_spec.lua b/test/functional/shada/compatibility_spec.lua
index 2ca0b16e75..774a1f1346 100644
--- a/test/functional/shada/compatibility_spec.lua
+++ b/test/functional/shada/compatibility_spec.lua
@@ -272,7 +272,7 @@ describe('ShaDa forward compatibility support code', function()
eq(0, exc_exec(sdrcmd(true)))
-- getreg may return empty list as list with NULL pointer which API
-- translates into nil for some reason.
- eq({}, funcs.getreg('a', 1, 1) or {})
+ eq(NIL, funcs.getreg('a', 1, 1) or {})
eq('', funcs.getregtype('a'))
nvim_command('wshada ' .. shada_fname)
local found = 0
diff --git a/test/functional/shada/helpers.lua b/test/functional/shada/helpers.lua
index 146ae8d51e..d4eb7f57bd 100644
--- a/test/functional/shada/helpers.lua
+++ b/test/functional/shada/helpers.lua
@@ -3,7 +3,7 @@ local spawn, set_session, meths, nvim_prog =
helpers.spawn, helpers.set_session, helpers.meths, helpers.nvim_prog
local write_file, merge_args = helpers.write_file, helpers.merge_args
-local msgpack = require('MessagePack')
+local mpack = require('mpack')
local tmpname = os.tmpname()
local additional_cmd = ''
@@ -20,14 +20,8 @@ local function nvim_argv()
end
end
-local session = nil
-
local reset = function()
- if session then
- session:exit(0)
- end
- session = spawn(nvim_argv())
- set_session(session)
+ set_session(spawn(nvim_argv()))
meths.set_var('tmpname', tmpname)
end
@@ -66,13 +60,13 @@ local read_shada_file = function(fname)
local fd = io.open(fname, 'r')
local mstring = fd:read('*a')
fd:close()
- local unpacker = msgpack.unpacker(mstring)
+ local unpack = mpack.Unpacker()
local ret = {}
- local cur
+ local cur, val
local i = 0
- while true do
- local off, val = unpacker()
- if not off then break end
+ local off = 1
+ while off <= #mstring do
+ val, off = unpack(mstring, off)
if i % 4 == 0 then
cur = {}
ret[#ret + 1] = cur
diff --git a/test/functional/shada/registers_spec.lua b/test/functional/shada/registers_spec.lua
index f0133b1086..d3af35cf7f 100644
--- a/test/functional/shada/registers_spec.lua
+++ b/test/functional/shada/registers_spec.lua
@@ -43,9 +43,9 @@ describe('ShaDa support code', function()
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
nvim_command('qall')
reset()
- eq({nil, ''}, getreg('c'))
- eq({nil, ''}, getreg('l'))
- eq({nil, ''}, getreg('b'))
+ eq({NIL, ''}, getreg('c'))
+ eq({NIL, ''}, getreg('l'))
+ eq({NIL, ''}, getreg('b'))
end)
it('does restore registers with zero <', function()
@@ -67,9 +67,9 @@ describe('ShaDa support code', function()
setreg('b', {'bca', 'abc', 'cba'}, 'b3')
nvim_command('qall')
reset()
- eq({nil, ''}, getreg('c'))
- eq({nil, ''}, getreg('l'))
- eq({nil, ''}, getreg('b'))
+ eq({NIL, ''}, getreg('c'))
+ eq({NIL, ''}, getreg('l'))
+ eq({NIL, ''}, getreg('b'))
end)
it('does restore registers with zero "', function()
@@ -103,7 +103,7 @@ describe('ShaDa support code', function()
nvim_command('qall')
reset()
eq({{'d'}, 'v'}, getreg('o'))
- eq({nil, ''}, getreg('t'))
+ eq({NIL, ''}, getreg('t'))
end)
it('does limit number of lines according to "', function()
@@ -113,7 +113,7 @@ describe('ShaDa support code', function()
nvim_command('qall')
reset()
eq({{'d'}, 'v'}, getreg('o'))
- eq({nil, ''}, getreg('t'))
+ eq({NIL, ''}, getreg('t'))
end)
it('does limit number of lines according to < rather then "', function()
@@ -125,7 +125,7 @@ describe('ShaDa support code', function()
reset()
eq({{'d'}, 'v'}, getreg('o'))
eq({{'a', 'b', 'cde'}, 'V'}, getreg('t'))
- eq({nil, ''}, getreg('h'))
+ eq({NIL, ''}, getreg('h'))
end)
it('dumps and loads register correctly when &encoding is not UTF-8',
diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua
index 822ab3913c..683d520627 100644
--- a/test/functional/shada/shada_spec.lua
+++ b/test/functional/shada/shada_spec.lua
@@ -8,7 +8,7 @@ local write_file, spawn, set_session, nvim_prog, exc_exec =
local lfs = require('lfs')
local paths = require('test.config.paths')
-local msgpack = require('MessagePack')
+local mpack = require('mpack')
local shada_helpers = require('test.functional.shada.helpers')
local reset, clear, get_shada_rw =
@@ -107,7 +107,7 @@ describe('ShaDa support code', function()
end)
it('reads correctly various timestamps', function()
- local mpack = {
+ local msgpack = {
'\100', -- Positive fixnum 100
'\204\255', -- uint 8 255
'\205\010\003', -- uint 16 2563
@@ -116,23 +116,23 @@ describe('ShaDa support code', function()
}
local s = '\100'
local e = '\001\192'
- wshada(s .. table.concat(mpack, e .. s) .. e)
+ wshada(s .. table.concat(msgpack, e .. s) .. e)
eq(0, exc_exec('wshada ' .. shada_fname))
local found = 0
- local typ = select(2, msgpack.unpacker(s)())
+ local typ = mpack.unpack(s)
for _, v in ipairs(read_shada_file(shada_fname)) do
if v.type == typ then
found = found + 1
- eq(select(2, msgpack.unpacker(mpack[found])()), v.timestamp)
+ eq(mpack.unpack(msgpack[found]), v.timestamp)
end
end
- eq(#mpack, found)
+ eq(#msgpack, found)
end)
it('does not write NONE file', function()
local session = spawn({nvim_prog, '-u', 'NONE', '-i', 'NONE', '--embed',
'--cmd', 'qall'}, true)
- session:exit(0)
+ session:close()
eq(nil, lfs.attributes('NONE'))
eq(nil, lfs.attributes('NONE.tmp.a'))
end)
@@ -143,7 +143,7 @@ describe('ShaDa support code', function()
true)
set_session(session)
eq('', funcs.getreg('a'))
- session:exit(0)
+ session:close()
os.remove('NONE')
end)
diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua
index e9cb010003..c15da2f760 100644
--- a/test/functional/terminal/cursor_spec.lua
+++ b/test/functional/terminal/cursor_spec.lua
@@ -59,7 +59,7 @@ describe('terminal cursor', function()
]])
end)
- it('is positioned correctly when focused', function()
+ pending('is positioned correctly when focused', function()
feed('i')
screen:expect([[
1 tty ready |
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index b35e0cde69..a11fab18a2 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -138,7 +138,7 @@ do
-- this is just a helper to get any canonical name of a color
colornames[rgb] = name
end
- session:exit(0)
+ session:close()
Screen.colors = colors
Screen.colornames = colornames
end