From df40d973cccd06142bd1c3378a8b828428ef8b27 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 2 Jan 2021 18:37:37 -0500 Subject: vim-patch:8.2.0456: Test_confirm_cmd is flaky Problem: Test_confirm_cmd is flaky. Solution: Add a term_wait() call. (closes vim/vim#5854) https://github.com/vim/vim/commit/72749f062f15c7147f512bc581695c25ad78fb4e Cherry-pick Test_confirm_cmd() from patch v8.2.0203 because that patch modifies multiple files. Copied code is based on Test_confirm_cmd() as of patch v8.2.0456. N/A patches for version.c: vim-patch:8.2.2274: badge for Travis is outdated Problem: badge for Travis is outdated. Solution: Update badge for move from travis-ci.org to travis-ci.com. https://github.com/vim/vim/commit/2f91e2f8da572123e53ae7579dde57c750137def vim-patch:8.2.2277: missing backslash Problem: Missing backslash. Solution: Add backslash. https://github.com/vim/vim/commit/9281c6cae4e1cec2c661487d761d407bad7c6ad6 --- src/nvim/testdir/test_excmd.vim | 75 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim index 4a027c3864..28ac2f65f6 100644 --- a/src/nvim/testdir/test_excmd.vim +++ b/src/nvim/testdir/test_excmd.vim @@ -1,5 +1,7 @@ " Tests for various Ex commands. +source check.vim + func Test_ex_delete() new call setline(1, ['a', 'b', 'c']) @@ -40,3 +42,76 @@ func Test_buffers_lastused() bwipeout bufb bwipeout bufc endfunc + +" Test for the :confirm command dialog +func Test_confirm_cmd() + CheckNotGui + CheckRunVimInTerminal + call writefile(['foo1'], 'foo') + call writefile(['bar1'], 'bar') + " Test for saving all the modified buffers + let buf = RunVimInTerminal('', {'rows': 20}) + call term_sendkeys(buf, ":set nomore\n") + call term_sendkeys(buf, ":new foo\n") + call term_sendkeys(buf, ":call setline(1, 'foo2')\n") + call term_sendkeys(buf, ":new bar\n") + call term_sendkeys(buf, ":call setline(1, 'bar2')\n") + call term_sendkeys(buf, ":wincmd b\n") + call term_sendkeys(buf, ":confirm qall\n") + call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ', term_getline(buf, 20))}, 1000) + call term_sendkeys(buf, "A") + call StopVimInTerminal(buf) + call assert_equal(['foo2'], readfile('foo')) + call assert_equal(['bar2'], readfile('bar')) + " Test for discarding all the changes to modified buffers + let buf = RunVimInTerminal('', {'rows': 20}) + call term_sendkeys(buf, ":set nomore\n") + call term_sendkeys(buf, ":new foo\n") + call term_sendkeys(buf, ":call setline(1, 'foo3')\n") + call term_sendkeys(buf, ":new bar\n") + call term_sendkeys(buf, ":call setline(1, 'bar3')\n") + call term_sendkeys(buf, ":wincmd b\n") + call term_sendkeys(buf, ":confirm qall\n") + call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ', term_getline(buf, 20))}, 1000) + call term_sendkeys(buf, "D") + call StopVimInTerminal(buf) + call assert_equal(['foo2'], readfile('foo')) + call assert_equal(['bar2'], readfile('bar')) + " Test for saving and discarding changes to some buffers + let buf = RunVimInTerminal('', {'rows': 20}) + call term_sendkeys(buf, ":set nomore\n") + call term_sendkeys(buf, ":new foo\n") + call term_sendkeys(buf, ":call setline(1, 'foo4')\n") + call term_sendkeys(buf, ":new bar\n") + call term_sendkeys(buf, ":call setline(1, 'bar4')\n") + call term_sendkeys(buf, ":wincmd b\n") + call term_sendkeys(buf, ":confirm qall\n") + call WaitForAssert({-> assert_match('\[Y\]es, (N)o, Save (A)ll, (D)iscard All, (C)ancel: ', term_getline(buf, 20))}, 1000) + call term_sendkeys(buf, "N") + call WaitForAssert({-> assert_match('\[Y\]es, (N)o, (C)ancel: ', term_getline(buf, 20))}, 1000) + call term_sendkeys(buf, "Y") + call StopVimInTerminal(buf) + call assert_equal(['foo4'], readfile('foo')) + call assert_equal(['bar2'], readfile('bar')) + + call delete('foo') + call delete('bar') +endfunc + +func Test_confirm_cmd_cancel() + " Test for closing a window with a modified buffer + let buf = RunVimInTerminal('', {'rows': 20}) + call term_sendkeys(buf, ":set nomore\n") + call term_sendkeys(buf, ":new\n") + call term_sendkeys(buf, ":call setline(1, 'abc')\n") + call term_sendkeys(buf, ":confirm close\n") + call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$', + \ term_getline(buf, 20))}, 1000) + call term_sendkeys(buf, "C") + call term_wait(buf, 50) + call term_sendkeys(buf, ":confirm close\n") + call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$', + \ term_getline(buf, 20))}, 1000) + call term_sendkeys(buf, "N") + call StopVimInTerminal(buf) +endfunc -- cgit From d216314e5bc223bad49b1ae49011194f8edf60f2 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 2 Jan 2021 18:46:39 -0500 Subject: vim-patch:8.2.0458: missing feature check in test function Problem: Missing feature check in test function. Solution: Add check commands. https://github.com/vim/vim/commit/bea9023d4260349c130faf447aa8d4cbadeffab2 --- src/nvim/testdir/test_excmd.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim index 28ac2f65f6..62c35c9f53 100644 --- a/src/nvim/testdir/test_excmd.vim +++ b/src/nvim/testdir/test_excmd.vim @@ -99,6 +99,9 @@ func Test_confirm_cmd() endfunc func Test_confirm_cmd_cancel() + CheckNotGui + CheckRunVimInTerminal + " Test for closing a window with a modified buffer let buf = RunVimInTerminal('', {'rows': 20}) call term_sendkeys(buf, ":set nomore\n") -- cgit From 30e8c1779f3b07e7d1cb76e0b880c8fb71e3cebf Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 2 Jan 2021 18:47:48 -0500 Subject: vim-patch:8.2.0461: confirm test fails on amd64 system Problem: Confirm test fails on amd64 system. (Alimar Riesebieter) Solution: Add an extra WaitForAssert(). (Dominique Pelle) https://github.com/vim/vim/commit/9207d1f523c2e2fb1c8749ec6f84ab5ecc2c62f4 --- src/nvim/testdir/test_excmd.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim index 62c35c9f53..1b4859ad6d 100644 --- a/src/nvim/testdir/test_excmd.vim +++ b/src/nvim/testdir/test_excmd.vim @@ -116,5 +116,7 @@ func Test_confirm_cmd_cancel() call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$', \ term_getline(buf, 20))}, 1000) call term_sendkeys(buf, "N") + call WaitForAssert({-> assert_match('^ *0,0-1 All$', + \ term_getline(buf, 20))}, 1000) call StopVimInTerminal(buf) endfunc -- cgit From c3931495b28776dc8eec4814aa469522e37b179b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 2 Jan 2021 18:49:21 -0500 Subject: vim-patch:8.2.0470: Test_confirm_cmd_cancel() can fail on a slow system Problem: Test_confirm_cmd_cancel() can fail on a slow system. Solution: Use WaitForAssert(). (Ozaki Kiichi, closes vim/vim#5861) https://github.com/vim/vim/commit/7b1b36b1cb744e87adfbef88b7ce26c863b0594a --- src/nvim/testdir/test_excmd.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim index 1b4859ad6d..9afb2b3b66 100644 --- a/src/nvim/testdir/test_excmd.vim +++ b/src/nvim/testdir/test_excmd.vim @@ -111,7 +111,7 @@ func Test_confirm_cmd_cancel() call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$', \ term_getline(buf, 20))}, 1000) call term_sendkeys(buf, "C") - call term_wait(buf, 50) + call WaitForAssert({-> assert_equal('', term_getline(buf, 20))}, 1000) call term_sendkeys(buf, ":confirm close\n") call WaitForAssert({-> assert_match('^\[Y\]es, (N)o, (C)ancel: *$', \ term_getline(buf, 20))}, 1000) -- cgit