diff options
author | luukvbaal <luukvbaal@gmail.com> | 2025-03-24 00:12:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-23 16:12:50 -0700 |
commit | 958df63606687fff6f805255ff3848dd34f33082 (patch) | |
tree | 9cae101fbc0df59de743e75f8a756d24d241d892 /test/functional/lua/ui_event_spec.lua | |
parent | 9516997eb0ad20146ddddb48ba48c905d512998c (diff) | |
download | rneovim-958df63606687fff6f805255ff3848dd34f33082.tar.gz rneovim-958df63606687fff6f805255ff3848dd34f33082.tar.bz2 rneovim-958df63606687fff6f805255ff3848dd34f33082.zip |
test(log): use tempfile for expected error logs #33017
Diffstat (limited to 'test/functional/lua/ui_event_spec.lua')
-rw-r--r-- | test/functional/lua/ui_event_spec.lua | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/test/functional/lua/ui_event_spec.lua b/test/functional/lua/ui_event_spec.lua index 1b3f128b9d..096280f563 100644 --- a/test/functional/lua/ui_event_spec.lua +++ b/test/functional/lua/ui_event_spec.lua @@ -32,7 +32,6 @@ describe('vim.ui_attach', function() ]] screen = Screen.new(40, 5) - screen:add_extra_attr_ids({ [100] = { bold = true, foreground = Screen.colors.SeaGreen } }) end) local function expect_events(expected) @@ -216,7 +215,7 @@ describe('vim.ui_attach', function() }, messages = { { - content = { { '\nSave changes?\n', 100, 10 } }, + content = { { '\nSave changes?\n', 6, 10 } }, history = false, kind = 'confirm', }, @@ -316,16 +315,38 @@ describe('vim.ui_attach', function() }, }) end) +end) + +describe('vim.ui_attach', function() + before_each(function() + clear({ env = { NVIM_LOG_FILE = testlog } }) + end) + + after_each(function() + check_close() + os.remove(testlog) + end) + + it('error in callback is logged', function() + exec_lua([[ + local ns = vim.api.nvim_create_namespace('test') + vim.ui_attach(ns, { ext_popupmenu = true }, function() error(42) end) + ]]) + feed('ifoo<CR>foobar<CR>fo<C-X><C-N>') + assert_log('Error in "popupmenu_show" UI event handler %(ns=test%):', testlog, 100) + assert_log('Error executing lua: .*: 42', testlog, 100) + end) it('detaches after excessive errors', function() - screen:try_resize(86, 10) + local screen = Screen.new(86, 10) + screen:add_extra_attr_ids({ [100] = { bold = true, foreground = Screen.colors.SeaGreen } }) exec_lua([[ vim.ui_attach(vim.api.nvim_create_namespace(''), { ext_messages = true }, function(ev) if ev:find('msg') then vim.api.nvim_buf_set_lines(0, -2, -1, false, { err[1] }) end end) - ]]) + ]]) local s1 = [[ ^ | {1:~ }|*9 @@ -418,27 +439,6 @@ describe('vim.ui_attach', function() {9:Excessive errors in vim.ui_attach() callback (ns=(UNKNOWN PLUGIN))} | ]]) end) -end) - -describe('vim.ui_attach', function() - before_each(function() - clear({ env = { NVIM_LOG_FILE = testlog } }) - end) - - after_each(function() - check_close() - os.remove(testlog) - end) - - it('error in callback is logged', function() - exec_lua([[ - local ns = vim.api.nvim_create_namespace('test') - vim.ui_attach(ns, { ext_popupmenu = true }, function() error(42) end) - ]]) - feed('ifoo<CR>foobar<CR>fo<C-X><C-N>') - assert_log('Error in "popupmenu_show" UI event handler %(ns=test%):', testlog, 100) - assert_log('Error executing lua: .*: 42', testlog, 100) - end) it('sourcing invalid file does not crash #32166', function() exec_lua([[ |