From 60ef7889a2c5e26a7e543a3d411934486ee022b2 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 1 Jul 2018 16:35:35 +0200 Subject: [PATCH 1/3] test: buffer_updates: 10s timeout --- test/functional/api/buffer_updates_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua index 1d5e31fee4..b48abb156b 100644 --- a/test/functional/api/buffer_updates_spec.lua +++ b/test/functional/api/buffer_updates_spec.lua @@ -482,7 +482,7 @@ describe('API: buffer events:', function() local function wantn(sessionid, name, args) local session = sessions[sessionid] - eq({'notification', name, args}, session:next_message()) + eq({'notification', name, args}, session:next_message(10000)) end -- Edit a new file, but don't enable buffer events. From b4fcf02316eafae8615653324e7afd1179254d81 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 1 Jul 2018 12:42:19 +0200 Subject: [PATCH 2/3] test: nvim_buf_attach response after initial delay ref #8634 --- test/functional/api/buffer_updates_spec.lua | 33 ++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua index b48abb156b..2e3844e24e 100644 --- a/test/functional/api/buffer_updates_spec.lua +++ b/test/functional/api/buffer_updates_spec.lua @@ -1,9 +1,11 @@ local helpers = require('test.functional.helpers')(after_each) +local clear = helpers.clear local eq, ok = helpers.eq, helpers.ok local buffer, command, eval, nvim, next_msg = helpers.buffer, helpers.command, helpers.eval, helpers.nvim, helpers.next_msg local expect_err = helpers.expect_err local nvim_prog = helpers.nvim_prog +local sleep = helpers.sleep local write_file = helpers.write_file local origlines = {"original line 1", @@ -51,7 +53,7 @@ local function editoriginal(activate, lines) lines = origlines end -- load up the file with the correct contents - helpers.clear() + clear() return open(activate, lines) end @@ -435,8 +437,7 @@ describe('API: buffer events:', function() expectn('nvim_buf_changedtick_event', {b3, tick3}) end) - it('does not get confused if enabled/disabled many times', - function() + it('does not get confused if enabled/disabled many times', function() local channel = nvim('get_api_info')[1] local b, tick = editoriginal(false) @@ -462,7 +463,7 @@ describe('API: buffer events:', function() end) it('can notify several channels at once', function() - helpers.clear() + clear() -- create several new sessions, in addition to our main API local sessions = {} @@ -710,10 +711,9 @@ describe('API: buffer events:', function() expectn('nvim_buf_lines_event', {b, tick, 0, 1, {'AA'}, false}) end) - it('detaches if the buffer is unloaded/deleted/wiped', - function() + it('detaches if the buffer is unloaded/deleted/wiped', function() -- start with a blank nvim - helpers.clear() + clear() -- need to make a new window with a buffer because :bunload doesn't let you -- unload the last buffer for _, cmd in ipairs({'bunload', 'bdelete', 'bwipeout'}) do @@ -729,23 +729,36 @@ describe('API: buffer events:', function() end) it('does not send the buffer content if not requested', function() - helpers.clear() + clear() local b, tick = editoriginal(false) ok(buffer('attach', b, false, {})) expectn('nvim_buf_changedtick_event', {b, tick}) end) it('returns a proper error on nonempty options dict', function() - helpers.clear() + clear() local b = editoriginal(false) expect_err("dict isn't empty", buffer, 'attach', b, false, {builtin="asfd"}) end) + it('nvim_buf_attach returns response after delay #8634', function() + clear() + sleep(1000) + -- response + eq(true, helpers.request('nvim_buf_attach', 0, false, {})) + -- notification + eq({ + [1] = 'notification', + [2] = 'nvim_buf_changedtick_event', + [3] = { + [1] = { id = 1 }, + [2] = 2 }, }, next_msg()) + end) end) describe('API: buffer events:', function() before_each(function() - helpers.clear() + clear() end) local function lines_subset(first, second) From f65a751d8249531c94b1aa7b1062477f9c516c8a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 2 Jul 2018 20:47:28 +0200 Subject: [PATCH 3/3] test: nvim_buf_attach: reduce delay This test is mostly a demo/reference for: https://github.com/neovim/neovim/issues/8634#issuecomment-400940467 so let's not pay a 1s penalty. --- test/functional/api/buffer_updates_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/api/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua index 2e3844e24e..e5cc747f8a 100644 --- a/test/functional/api/buffer_updates_spec.lua +++ b/test/functional/api/buffer_updates_spec.lua @@ -743,7 +743,7 @@ describe('API: buffer events:', function() it('nvim_buf_attach returns response after delay #8634', function() clear() - sleep(1000) + sleep(250) -- response eq(true, helpers.request('nvim_buf_attach', 0, false, {})) -- notification