From d0e07c043b9ad935b46d5625854ad57d1093ad46 Mon Sep 17 00:00:00 2001 From: lonerover Date: Sun, 20 May 2018 10:16:50 +0800 Subject: vim-patch:8.0.0489: clipboard and "* register is not tested Problem: Clipboard and "* register is not tested. Solution: Add a test for Mac and X11. (Kazunobu Kuriyama) https://github.com/vim/vim/commit/7dd4850698e37c3ed4a3c3b23f4cdbf1ae6542f8 --- src/nvim/testdir/runtest.vim | 1 + src/nvim/testdir/test_quotestar.vim | 139 ++++++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 src/nvim/testdir/test_quotestar.vim (limited to 'src') diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index 5c98455909..f2cd84f556 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -238,6 +238,7 @@ let s:flaky = [ \ 'Test_out_cb()', \ 'Test_paused()', \ 'Test_quoteplus()', + \ 'Test_quotestar()', \ 'Test_reltime()', \ 'Test_terminal_composing_unicode()', \ 'Test_terminal_redir_file()', diff --git a/src/nvim/testdir/test_quotestar.vim b/src/nvim/testdir/test_quotestar.vim new file mode 100644 index 0000000000..300a964731 --- /dev/null +++ b/src/nvim/testdir/test_quotestar.vim @@ -0,0 +1,139 @@ +" *-register (quotestar) tests + +if !has('clipboard') + finish +endif + +source shared.vim + +let s:where = 0 +func Abort(id) + call assert_report('Test timed out at ' . s:where) + call FinishTesting() +endfunc + +func Do_test_quotestar_for_macunix() + if empty(exepath('pbcopy')) || empty(exepath('pbpaste')) + return 'Test requires pbcopy(1) and pbpaste(1)' + endif + + let @* = '' + + " Test #1: Pasteboard to Vim + let test_msg = "text from pasteboard to vim via quotestar" + " Write a piece of text to the pasteboard. + call system('/bin/echo -n "' . test_msg . '" | pbcopy') + " See if the *-register is changed as expected. + call assert_equal(test_msg, @*) + + " Test #2: Vim to Pasteboard + let test_msg = "text from vim to pasteboard via quotestar" + " Write a piece of text to the *-register. + let @* = test_msg + " See if the pasteboard is changed as expected. + call assert_equal(test_msg, system('pbpaste')) + + return '' +endfunc + +func Do_test_quotestar_for_x11() + if !has('clientserver') || !has('job') + return 'Test requires the client-server and job features' + endif + + let cmd = GetVimCommand() + if cmd == '' + return 'GetVimCommand() failed' + endif + + " Some of these commands may hang when failing. + call timer_start(10000, 'Abort') + + let s:where = 1 + let name = 'XVIMCLIPBOARD' + let cmd .= ' --servername ' . name + let g:job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'}) + call WaitFor('job_status(g:job) == "run"') + if job_status(g:job) != 'run' + call assert_report('Cannot run the Vim server') + return '' + endif + let s:where = 2 + + " Takes a short while for the server to be active. + call WaitFor('serverlist() =~ "' . name . '"') + call assert_match(name, serverlist()) + let s:where = 3 + + " Clear the *-register of this vim instance. + let @* = '' + + " Try to change the *-register of the server. + call remote_foreground(name) + let s:where = 4 + call remote_send(name, ":let @* = 'yes'\") + let s:where = 5 + call WaitFor('remote_expr("' . name . '", "@*") == "yes"') + let s:where = 6 + call assert_equal('yes', remote_expr(name, "@*")) + let s:where = 7 + + " Check that the *-register of this vim instance is changed as expected. + call assert_equal('yes', @*) + + if has('unix') && has('gui') && !has('gui_running') + let @* = '' + + " Running in a terminal and the GUI is avaiable: Tell the server to open + " the GUI and check that the remote command still works. + " Need to wait for the GUI to start up, otherwise the send hangs in trying + " to send to the terminal window. + if has('gui_athena') || has('gui_motif') + " For those GUIs, ignore the 'failed to create input context' error. + call remote_send(name, ":call test_ignore_error('E285') | gui -f\") + else + call remote_send(name, ":gui -f\") + endif + let s:where = 8 + sleep 500m + call remote_send(name, ":let @* = 'maybe'\") + let s:where = 9 + call WaitFor('remote_expr("' . name . '", "@*") == "maybe"') + let s:where = 10 + call assert_equal('maybe', remote_expr(name, "@*")) + let s:where = 11 + + call assert_equal('maybe', @*) + endif + + call remote_send(name, ":qa!\") + let s:where = 12 + call WaitFor('job_status(g:job) == "dead"') + let s:where = 13 + if job_status(g:job) != 'dead' + call assert_report('Server did not exit') + call job_stop(g:job, 'kill') + endif + + return '' +endfunc + +func Test_quotestar() + let skipped = '' + + let quotestar_saved = @* + + if has('macunix') + let skipped = Do_test_quotestar_for_macunix() + elseif !empty("$DISPLAY") + let skipped = Do_test_quotestar_for_x11() + else + let skipped = "Test is not implemented yet for this platform." + endif + + let @* = quotestar_saved + + if !empty(skipped) + throw skipped + endif +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 779fd57a54..87a8b53bb6 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1150,7 +1150,7 @@ static const int included_patches[] = { // 492, // 491, 490, - // 489, + 489, // 488, 487, 486, -- cgit From 3046f4499bdbe8dd3c79aee987498e644a5d6a4a Mon Sep 17 00:00:00 2001 From: lonerover Date: Sun, 20 May 2018 10:21:32 +0800 Subject: vim-patch:8.0.0491: quotestar test fails when features are missing Problem: The quotestar test fails when a required feature is missing. Solution: Prepend "Skipped" to the thrown exception. https://github.com/vim/vim/commit/bfd830d3e2dbd1e9b14c65625f18773074e6ac67 --- src/nvim/testdir/test_quotestar.vim | 2 +- src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_quotestar.vim b/src/nvim/testdir/test_quotestar.vim index 300a964731..111a226b65 100644 --- a/src/nvim/testdir/test_quotestar.vim +++ b/src/nvim/testdir/test_quotestar.vim @@ -134,6 +134,6 @@ func Test_quotestar() let @* = quotestar_saved if !empty(skipped) - throw skipped + throw 'Skipped: ' . skipped endif endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 87a8b53bb6..53931bfb50 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1148,7 +1148,7 @@ static const int included_patches[] = { // 494, // 493, // 492, - // 491, + 491, 490, 489, // 488, -- cgit From 4dd614e51ac4f2ae0c40637c81d58f731faa63b3 Mon Sep 17 00:00:00 2001 From: lonerover Date: Sun, 20 May 2018 10:27:03 +0800 Subject: vim-patch:8.0.0495: quotestar test uses timer instead of timeout Problem: The quotestar test uses a timer instead of a timeout, thus it cannot be rerun like a flaky test. Solution: Remove the timer and add a timeout. (Kazunobu Kuriyama) https://github.com/vim/vim/commit/f5610da7a8a5908e747d1ae39dbed1408bbd2644 --- src/nvim/testdir/test_quotestar.vim | 34 +++++++--------------------------- src/nvim/version.c | 2 +- 2 files changed, 8 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_quotestar.vim b/src/nvim/testdir/test_quotestar.vim index 111a226b65..5212b9bc62 100644 --- a/src/nvim/testdir/test_quotestar.vim +++ b/src/nvim/testdir/test_quotestar.vim @@ -6,12 +6,6 @@ endif source shared.vim -let s:where = 0 -func Abort(id) - call assert_report('Test timed out at ' . s:where) - call FinishTesting() -endfunc - func Do_test_quotestar_for_macunix() if empty(exepath('pbcopy')) || empty(exepath('pbpaste')) return 'Test requires pbcopy(1) and pbpaste(1)' @@ -46,10 +40,6 @@ func Do_test_quotestar_for_x11() return 'GetVimCommand() failed' endif - " Some of these commands may hang when failing. - call timer_start(10000, 'Abort') - - let s:where = 1 let name = 'XVIMCLIPBOARD' let cmd .= ' --servername ' . name let g:job = job_start(cmd, {'stoponexit': 'kill', 'out_io': 'null'}) @@ -58,25 +48,19 @@ func Do_test_quotestar_for_x11() call assert_report('Cannot run the Vim server') return '' endif - let s:where = 2 " Takes a short while for the server to be active. call WaitFor('serverlist() =~ "' . name . '"') call assert_match(name, serverlist()) - let s:where = 3 " Clear the *-register of this vim instance. let @* = '' " Try to change the *-register of the server. call remote_foreground(name) - let s:where = 4 call remote_send(name, ":let @* = 'yes'\") - let s:where = 5 - call WaitFor('remote_expr("' . name . '", "@*") == "yes"') - let s:where = 6 - call assert_equal('yes', remote_expr(name, "@*")) - let s:where = 7 + call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "yes"') + call assert_equal('yes', remote_expr(name, "@*", "", 2)) " Check that the *-register of this vim instance is changed as expected. call assert_equal('yes', @*) @@ -94,22 +78,18 @@ func Do_test_quotestar_for_x11() else call remote_send(name, ":gui -f\") endif - let s:where = 8 - sleep 500m + " Wait for the server to be up and answering requests. + call WaitFor('remote_expr("' . name . '", "v:version", "", 1) != ""') + call remote_send(name, ":let @* = 'maybe'\") - let s:where = 9 - call WaitFor('remote_expr("' . name . '", "@*") == "maybe"') - let s:where = 10 - call assert_equal('maybe', remote_expr(name, "@*")) - let s:where = 11 + call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "maybe"') + call assert_equal('maybe', remote_expr(name, "@*", "", 2)) call assert_equal('maybe', @*) endif call remote_send(name, ":qa!\") - let s:where = 12 call WaitFor('job_status(g:job) == "dead"') - let s:where = 13 if job_status(g:job) != 'dead' call assert_report('Server did not exit') call job_stop(g:job, 'kill') diff --git a/src/nvim/version.c b/src/nvim/version.c index 53931bfb50..1267759970 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1144,7 +1144,7 @@ static const int included_patches[] = { 498, // 497, // 496, - // 495, + 495, // 494, // 493, // 492, -- cgit From fd5cc7dd0a63e00200a4517d3b6d81f2f8e6863b Mon Sep 17 00:00:00 2001 From: lonerover Date: Sun, 20 May 2018 10:30:43 +0800 Subject: vim-patch:8.0.0500: quotestar test is still a bit flaky Problem: Quotestar test is still a bit flaky. Solution: Add a slower check for v:version. https://github.com/vim/vim/commit/4889ad7c6cd46368f553cc1140ca17508e8beaaa --- src/nvim/testdir/test_quotestar.vim | 8 ++++++-- src/nvim/version.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_quotestar.vim b/src/nvim/testdir/test_quotestar.vim index 5212b9bc62..d0dd04f91d 100644 --- a/src/nvim/testdir/test_quotestar.vim +++ b/src/nvim/testdir/test_quotestar.vim @@ -53,6 +53,10 @@ func Do_test_quotestar_for_x11() call WaitFor('serverlist() =~ "' . name . '"') call assert_match(name, serverlist()) + " Wait for the server to be up and answering requests. One second is not + " always sufficient. + call WaitFor('remote_expr("' . name . '", "v:version", "", 2) != ""') + " Clear the *-register of this vim instance. let @* = '' @@ -78,8 +82,8 @@ func Do_test_quotestar_for_x11() else call remote_send(name, ":gui -f\") endif - " Wait for the server to be up and answering requests. - call WaitFor('remote_expr("' . name . '", "v:version", "", 1) != ""') + " Wait for the server in the GUI to be up and answering requests. + call WaitFor('remote_expr("' . name . '", "has(\"gui_running\")", "", 1) =~ "1"') call remote_send(name, ":let @* = 'maybe'\") call WaitFor('remote_expr("' . name . '", "@*", "", 1) == "maybe"') diff --git a/src/nvim/version.c b/src/nvim/version.c index 1267759970..17f89a25d2 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1139,7 +1139,7 @@ static const int included_patches[] = { // 503, 502, // 501, - // 500, + 500, 499, 498, // 497, -- cgit