diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/api/vim_spec.lua | 10 | ||||
-rw-r--r-- | test/functional/helpers.lua | 8 |
2 files changed, 18 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 6261458f2a..ddf5575e31 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -14,6 +14,7 @@ local ok, nvim_async, feed = helpers.ok, helpers.nvim_async, helpers.feed local os_name = helpers.os_name local request = helpers.request local source = helpers.source +local next_msg = helpers.next_msg local expect_err = global_helpers.expect_err local format_string = global_helpers.format_string @@ -46,6 +47,15 @@ describe('API', function() request, nil) end) + it('handles errors in async requests', function() + local error_types = meths.get_api_info()[2].error_types + nvim_async("bogus") + eq({'notification', 'nvim_error_event', + {error_types.Exception.id, 'Invalid method: nvim_bogus'}}, next_msg()) + -- error didn't close channel. + eq(2, eval('1+1')) + end) + describe('nvim_command', function() it('works', function() local fname = helpers.tmpname() diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua index db90cb559f..a94e977cd0 100644 --- a/test/functional/helpers.lua +++ b/test/functional/helpers.lua @@ -757,6 +757,14 @@ return function(after_each) end check_logs() check_cores('build/bin/nvim') + if session then + local msg = session:next_message(0) + if msg then + if msg[1] == "notification" and msg[2] == "nvim_error_event" then + error(msg[3][2]) + end + end + end end) end return module |