From d31ee6664d3b8d37ac4bb95b3adad397e90a8da1 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 8 Aug 2022 22:04:21 +0800 Subject: test: increse expect_exit() timeouts (#19680) A timeout of 100 milliseconds is sometimes still too short for macOS. Change it to 1000 milliseconds. --- test/functional/legacy/arglist_spec.lua | 2 +- test/functional/legacy/excmd_spec.lua | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/arglist_spec.lua b/test/functional/legacy/arglist_spec.lua index f90da16d7b..4d9e88c446 100644 --- a/test/functional/legacy/arglist_spec.lua +++ b/test/functional/legacy/arglist_spec.lua @@ -276,6 +276,6 @@ describe('argument list commands', function() 2 more files to edit. Quit anyway? | [Y]es, (N)o: ^ | ]]) - expect_exit(100, feed, 'Y') + expect_exit(1000, feed, 'Y') end) end) diff --git a/test/functional/legacy/excmd_spec.lua b/test/functional/legacy/excmd_spec.lua index 65957d85de..ece88d26bd 100644 --- a/test/functional/legacy/excmd_spec.lua +++ b/test/functional/legacy/excmd_spec.lua @@ -94,7 +94,7 @@ describe(':confirm command dialog', function() {3:Save changes to "Xbar"?} | {3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | ]]) - expect_exit(100, feed, 'A') + expect_exit(1000, feed, 'A') eq('foo2\n', read_file('Xfoo')) eq('bar2\n', read_file('Xbar')) @@ -132,7 +132,7 @@ describe(':confirm command dialog', function() {3:Save changes to "Xbar"?} | {3:[Y]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: }^ | ]]) - expect_exit(100, feed, 'D') + expect_exit(1000, feed, 'D') eq('foo2\n', read_file('Xfoo')) eq('bar2\n', read_file('Xbar')) @@ -193,7 +193,7 @@ describe(':confirm command dialog', function() {3:Save changes to "Xfoo"?} | {3:[Y]es, (N)o, (C)ancel: }^ | ]]) - expect_exit(100, feed, 'Y') + expect_exit(1000, feed, 'Y') eq('foo4\n', read_file('Xfoo')) eq('bar2\n', read_file('Xbar')) -- cgit From 53b0688ac0cad5db4840bbed1d7e5ccac3a1ee42 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Jun 2022 14:50:57 +0800 Subject: vim-patch:8.1.1189: mode is not cleared when leaving Insert mode Problem: Mode is not cleared when leaving Insert mode. Solution: Clear the mode when got_int is set. (Ozaki Kiichi, closes vim/vim#4270) https://github.com/vim/vim/commit/abc7c7fc5a098374f5543a237e6c9dd918848b34 --- test/functional/legacy/messages_spec.lua | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index 51c2406933..f3a742a3e0 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -337,6 +337,47 @@ describe('messages', function() end) end) + describe('mode is cleared when', function() + before_each(function() + screen = Screen.new(40, 6) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [2] = {bold = true}, -- ModeMsg + [3] = {bold = true, reverse=true}, -- StatusLine + }) + screen:attach() + end) + + -- oldtest: Test_mode_message_at_leaving_insert_by_ctrl_c() + it('leaving Insert mode with Ctrl-C vim-patch:8.1.1189', function() + exec([[ + func StatusLine() abort + return "" + endfunc + set statusline=%!StatusLine() + set laststatus=2 + ]]) + feed('i') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {3: }| + {2:-- INSERT --} | + ]]) + feed('') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {3: }| + | + ]]) + end) + end) + -- oldtest: Test_ask_yesno() it('y/n prompt works', function() screen = Screen.new(75, 6) -- cgit From 93ba82183122b6b6e3d388d0e0fad4a538052803 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Jun 2022 15:39:09 +0800 Subject: vim-patch:8.1.1192: mode is not cleared when leaving Insert mode with mapped Esc Problem: Mode is not cleared when leaving Insert mode with mapped Esc. Solution: Clear the mode when redraw_cmdline is set. (closes vim/vim#4269) https://github.com/vim/vim/commit/4c25bd785aa8b565bf973cbba12ed36b76daaa4f --- test/functional/legacy/messages_spec.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index f3a742a3e0..41f3007b81 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -376,6 +376,32 @@ describe('messages', function() | ]]) end) + + -- oldtest: Test_mode_message_at_leaving_insert_with_esc_mapped() + it('leaving Insert mode with ESC in the middle of a mapping vim-patch:8.1.1192', function() + exec([[ + set laststatus=2 + inoremap 00 + ]]) + feed('i') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {3:[No Name] }| + {2:-- INSERT --} | + ]]) + feed('') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {3:[No Name] }| + | + ]]) + end) end) -- oldtest: Test_ask_yesno() -- cgit From 55da52963b6e13ecc402b6574cf3bd396d11d23d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Jun 2022 15:54:00 +0800 Subject: vim-patch:8.2.5109: mode not updated after CTRL-O CTRL-C in Insert mode Problem: Mode not updated after CTRL-O CTRL-C in Insert mode. Solution: Set redraw_mode and use it. (closes vim/vim#10581) https://github.com/vim/vim/commit/7a1d32809bb5c1527314000983e75125d79192e0 --- test/functional/legacy/messages_spec.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index 41f3007b81..159cf7a551 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -402,6 +402,28 @@ describe('messages', function() | ]]) end) + + -- oldtest: Test_mode_updated_after_ctrl_c() + it('pressing Ctrl-C in i_CTRL-O', function() + feed('i') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {2:-- (insert) --} | + ]]) + feed('') + screen:expect([[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]) + end) end) -- oldtest: Test_ask_yesno() -- cgit From 76b4b1977ba3f3a1f630468a2ce89f47f2cedec4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 20 Jul 2022 08:16:02 +0800 Subject: vim-patch:8.2.1799: some Normal mode commands not fully tested Problem: Some Normal mode commands not fully tested. Solution: Add a few more tests. (Yegappan Lakshmanan, closes vim/vim#7073) https://github.com/vim/vim/commit/d1ad99b65470d3e754f6a0588a6b0dc2214a1eab Cherry-pick test_registers.vim change from patch 8.2.0644. --- test/functional/legacy/gf_spec.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 test/functional/legacy/gf_spec.lua (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/gf_spec.lua b/test/functional/legacy/gf_spec.lua new file mode 100644 index 0000000000..f1b1790ba1 --- /dev/null +++ b/test/functional/legacy/gf_spec.lua @@ -0,0 +1,15 @@ +local helpers = require('test.functional.helpers')(after_each) +local clear = helpers.clear +local command = helpers.command +local eq = helpers.eq +local pcall_err = helpers.pcall_err + +describe('gf', function() + before_each(clear) + + it('is not allowed when buffer is locked', function() + command('au OptionSet diff norm! gf') + command([[call setline(1, ['Xfile1', 'line2', 'line3', 'line4'])]]) + eq('Vim(normal):E788: Not allowed to edit another buffer now', pcall_err(command, 'diffthis')) + end) +end) -- cgit From cf3b871fa940c42e9c94257118f7d1131ebd362a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 16 Aug 2022 15:21:46 +0800 Subject: test: use poke_eventloop() instead of sleep(10) where possible (#19794) Using sleep(10) to wait for typeahead to finish is flaky, especially on macOS, where legacy/global_spec.lua has failed several times. --- test/functional/legacy/ex_mode_spec.lua | 4 ++-- test/functional/legacy/global_spec.lua | 6 +++--- test/functional/legacy/mapping_spec.lua | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/ex_mode_spec.lua b/test/functional/legacy/ex_mode_spec.lua index a8f54c6939..f21c47e175 100644 --- a/test/functional/legacy/ex_mode_spec.lua +++ b/test/functional/legacy/ex_mode_spec.lua @@ -6,7 +6,7 @@ local eq = helpers.eq local eval = helpers.eval local feed = helpers.feed local meths = helpers.meths -local sleep = helpers.sleep +local poke_eventloop = helpers.poke_eventloop before_each(clear) @@ -143,7 +143,7 @@ describe('Ex mode', function() ^ | ]]) feed('') - sleep(10) -- Wait for input to be flushed + poke_eventloop() -- Wait for input to be flushed feed('foo') screen:expect([[ Entering Ex mode. Type "visual" to go to Normal mode. | diff --git a/test/functional/legacy/global_spec.lua b/test/functional/legacy/global_spec.lua index 9f4528530c..ff02c41e6c 100644 --- a/test/functional/legacy/global_spec.lua +++ b/test/functional/legacy/global_spec.lua @@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen') local clear = helpers.clear local exec = helpers.exec local feed = helpers.feed -local sleep = helpers.sleep +local poke_eventloop = helpers.poke_eventloop before_each(clear) @@ -24,7 +24,7 @@ describe(':global', function() ]]) feed(':g/foo/norm :;') - sleep(10) -- Wait for :sleep to start + poke_eventloop() -- Wait for :sleep to start feed('') screen:expect([[ ^foo | @@ -37,7 +37,7 @@ describe(':global', function() -- Also test in Ex mode feed('gQg/foo/norm :;') - sleep(10) -- Wait for :sleep to start + poke_eventloop() -- Wait for :sleep to start feed('') screen:expect([[ {0: }| diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua index 456acc12b5..c1f23ab0a6 100644 --- a/test/functional/legacy/mapping_spec.lua +++ b/test/functional/legacy/mapping_spec.lua @@ -131,11 +131,11 @@ describe('mapping', function() command('set selectmode=mouse') command('nnoremap ') - sleep(10) + poke_eventloop() meths.input_mouse('left', 'press', '', 0, 0, 0) - sleep(10) + poke_eventloop() meths.input_mouse('left', 'drag', '', 0, 0, 1) - sleep(10) + poke_eventloop() eq('s', eval('mode()')) end) @@ -144,22 +144,22 @@ describe('mapping', function() command('inoremap let g:dragged = 1') feed('i') - sleep(10) + poke_eventloop() meths.input_mouse('left', 'press', '', 0, 0, 0) - sleep(10) + poke_eventloop() meths.input_mouse('left', 'drag', '', 0, 0, 1) - sleep(10) + poke_eventloop() eq(1, eval('g:dragged')) eq('v', eval('mode()')) feed([[]]) command([[inoremap ]]) feed('i') - sleep(10) + poke_eventloop() meths.input_mouse('left', 'press', '', 0, 0, 0) - sleep(10) + poke_eventloop() meths.input_mouse('left', 'drag', '', 0, 0, 1) - sleep(10) + poke_eventloop() eq('n', eval('mode()')) end) -- cgit From b7c86e24f7cc16e642b82a3a157fec06ddc41e51 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 19 Aug 2022 21:40:22 +0800 Subject: vim-patch:8.2.0982: insufficient testing for reading/writing files Problem: Insufficient testing for reading/writing files. Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#6257) Add "ui_delay" to test_override() and use it for the CTRL-O test. https://github.com/vim/vim/commit/b340baed9f7fc1c19a0742e2214d54982190c15e Omit test_override(). Reorder test_writefile.vim to match Vim. --- test/functional/legacy/filechanged_spec.lua | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/functional/legacy') diff --git a/test/functional/legacy/filechanged_spec.lua b/test/functional/legacy/filechanged_spec.lua index ecb861098c..1f23528d61 100644 --- a/test/functional/legacy/filechanged_spec.lua +++ b/test/functional/legacy/filechanged_spec.lua @@ -67,6 +67,15 @@ describe('file changed dialog', function() call assert_equal(1, line('$')) call assert_equal('new line', getline(1)) + " File created after starting to edit it + call delete('Xchanged_d') + new Xchanged_d + call writefile(['one'], 'Xchanged_d') + call nvim_input('L') + checktime Xchanged_d + call assert_equal(['one'], getline(1, '$')) + close! + bwipe! call delete('Xchanged_d') endfunc -- cgit