diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/autocmd/tabnew_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/helpers.lua | 19 | ||||
-rw-r--r-- | test/functional/job/job_spec.lua | 8 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 24 |
4 files changed, 36 insertions, 17 deletions
diff --git a/test/functional/autocmd/tabnew_spec.lua b/test/functional/autocmd/tabnew_spec.lua index 970ca19726..d80644cd92 100644 --- a/test/functional/autocmd/tabnew_spec.lua +++ b/test/functional/autocmd/tabnew_spec.lua @@ -4,8 +4,8 @@ local clear, nvim, buffer, curbuf, curwin, eq, neq, ok = helpers.eq, helpers.neq, helpers.ok describe('TabNew', function() + setup(clear) describe('au TabNew', function() - clear() describe('with * as <afile>', function() it('matches when opening any new tab', function() nvim('command', 'au! TabNew * echom "tabnew:".tabpagenr().":".bufnr("")') diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index 5627b1fae2..393b42dda5 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -162,15 +162,20 @@ local function rawfeed(...) end end +local function spawn(argv) + local loop = Loop.new() + local msgpack_stream = MsgpackStream.new(loop) + local async_session = AsyncSession.new(msgpack_stream) + local session = Session.new(async_session) + loop:spawn(argv) + return session +end + local function clear() if session then session:exit(0) end - local loop = Loop.new() - local msgpack_stream = MsgpackStream.new(loop) - local async_session = AsyncSession.new(msgpack_stream) - session = Session.new(async_session) - loop:spawn(nvim_argv) + session = spawn(nvim_argv) end local function insert(...) @@ -271,10 +276,9 @@ local function expect(contents) return eq(dedent(contents), curbuf_contents()) end -clear() - return { clear = clear, + spawn = spawn, dedent = dedent, source = source, rawfeed = rawfeed, @@ -292,6 +296,7 @@ return { expect = expect, ok = ok, nvim = nvim, + nvim_prog = nvim_prog, nvim_dir = nvim_dir, buffer = buffer, window = window, diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua index 0d561ec4d7..c74ae047c5 100644 --- a/test/functional/job/job_spec.lua +++ b/test/functional/job/job_spec.lua @@ -6,10 +6,14 @@ local clear, nvim, eq, neq, ok, expect, eval, next_message, run, stop, session helpers.stop, helpers.session local nvim_dir, insert = helpers.nvim_dir, helpers.insert -local channel = nvim('get_api_info')[1] describe('jobs', function() - before_each(clear) + local channel + + before_each(function() + clear() + channel = nvim('get_api_info')[1] + end) -- Creates the string to make an autocmd to notify us. local notify_str = function(expr1, expr2) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index f79d634536..c60944bbb0 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -123,16 +123,26 @@ if os.getenv('CI_TARGET') then default_screen_timeout = default_screen_timeout * 3 end -local colors = request('vim_get_color_map') -local colornames = {} -for name, rgb in pairs(colors) do +do + local spawn, nvim_prog = helpers.spawn, helpers.nvim_prog + local session = spawn({nvim_prog, '-u', 'NONE', '-N', '--embed'}) + local status, rv = session:request('vim_get_color_map') + if not status then + print('failed to get color map') + os.exit(1) + end + local colors = rv + local colornames = {} + for name, rgb in pairs(colors) do -- we disregard the case that colornames might not be unique, as -- this is just a helper to get any canonical name of a color colornames[rgb] = name + end + session:exit(0) + Screen.colors = colors + Screen.colornames = colornames end -Screen.colors = colors - function Screen.debug(command) if not command then command = 'pynvim -n -c ' @@ -497,8 +507,8 @@ function pprint_attrs(attrs) for f, v in pairs(attrs) do local desc = tostring(v) if f == "foreground" or f == "background" then - if colornames[v] ~= nil then - desc = "Screen.colors."..colornames[v] + if Screen.colornames[v] ~= nil then + desc = "Screen.colors."..Screen.colornames[v] end end table.insert(items, f.." = "..desc) |