From 2e790e9ad10bca3a64b20be75672a3c6a6f3d97c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 19 Jul 2022 20:55:13 +0800 Subject: vim-patch:8.2.0509: various code is not properly tested. Problem: various code is not properly tested. Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#5871) https://github.com/vim/vim/commit/cde0ff39da2459b16007fef701ebaa449fb6fe9d Cherry-pick test_clientserver.vim change from patch 8.1.1826. Cherry-pick a comment from patch 8.2.0301. Omit test_viminfo.vim. --- src/nvim/testdir/test_clientserver.vim | 79 +++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 11 deletions(-) (limited to 'src/nvim/testdir/test_clientserver.vim') diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim index db62fe5fa6..788b1dd204 100644 --- a/src/nvim/testdir/test_clientserver.vim +++ b/src/nvim/testdir/test_clientserver.vim @@ -1,16 +1,12 @@ " Tests for the +clientserver feature. -if !has('job') || !has('clientserver') - throw 'Skipped: job and/or clientserver feature missing' -endif +source check.vim +CheckFeature job +CheckFeature clientserver source shared.vim -func Test_client_server() - let cmd = GetVimCommand() - if cmd == '' - return - endif +func Check_X11_Connection() if has('x11') if empty($DISPLAY) throw 'Skipped: $DISPLAY is not set' @@ -19,11 +15,19 @@ func Test_client_server() call remote_send('xxx', '') catch if v:exception =~ 'E240:' - throw 'Skipped: no connection to the X server' + throw 'Skipped: no connection to the X server' endif " ignore other errors endtry endif +endfunc + +func Test_client_server() + let cmd = GetVimCommand() + if cmd == '' + return + endif + call Check_X11_Connection() let name = 'XVIMTEST' let cmd .= ' --servername ' . name @@ -81,6 +85,10 @@ func Test_client_server() endif let g:testvar = 'myself' call assert_equal('myself', remote_expr(v:servername, 'testvar')) + call remote_send(v:servername, ":let g:testvar2 = 75\") + call feedkeys('', 'x') + call assert_equal(75, g:testvar2) + call assert_fails('let v = remote_expr(v:servername, "/2")', 'E449:') call remote_send(name, ":call server2client(expand(''), 'got it')\", 'g:myserverid') call assert_equal('got it', g:myserverid->remote_read(2)) @@ -101,6 +109,55 @@ func Test_client_server() call assert_equal('another', g:peek_result) call assert_equal('another', remote_read(g:myserverid, 2)) + if !has('gui_running') + " In GUI vim, the following tests display a dialog box + + let cmd = GetVimProg() .. ' --servername ' .. name + + " Run a separate instance to send a command to the server + call remote_expr(name, 'execute("only")') + call system(cmd .. ' --remote-send ":new Xfile"') + call assert_equal('2', remote_expr(name, 'winnr("$")')) + call assert_equal('Xfile', remote_expr(name, 'winbufnr(1)->bufname()')) + call remote_expr(name, 'execute("only")') + + " Invoke a remote-expr. On MS-Windows, the returned value has a carriage + " return. + let l = system(cmd .. ' --remote-expr "2 + 2"') + call assert_equal(['4'], split(l, "\n")) + + " Edit multiple files using --remote + call system(cmd .. ' --remote Xfile1 Xfile2 Xfile3') + call assert_equal("Xfile1\nXfile2\nXfile3\n", remote_expr(name, 'argv()')) + eval name->remote_send(":%bw!\") + + " Edit files in separate tab pages + call system(cmd .. ' --remote-tab Xfile1 Xfile2 Xfile3') + call assert_equal('3', remote_expr(name, 'tabpagenr("$")')) + call assert_equal('Xfile2', remote_expr(name, 'bufname(tabpagebuflist(2)[0])')) + eval name->remote_send(":%bw!\") + + " Edit a file using --remote-wait + eval name->remote_send(":source $VIMRUNTIME/plugin/rrhelper.vim\") + call system(cmd .. ' --remote-wait +enew Xfile1') + call assert_equal("Xfile1", remote_expr(name, 'bufname("#")')) + eval name->remote_send(":%bw!\") + + " Edit files using --remote-tab-wait + call system(cmd .. ' --remote-tabwait +tabonly\|enew Xfile1 Xfile2') + call assert_equal('1', remote_expr(name, 'tabpagenr("$")')) + eval name->remote_send(":%bw!\") + + " Error cases + if v:lang == "C" || v:lang =~ '^[Ee]n' + let l = split(system(cmd .. ' --remote +pwd'), "\n") + call assert_equal("Argument missing after: \"+pwd\"", l[1]) + endif + let l = system(cmd .. ' --remote-expr "abcd"') + call assert_match('^E449: ', l) + endif + + eval name->remote_send(":%bw!\") eval name->remote_send(":qa!\") try call WaitForAssert({-> assert_equal("dead", job_status(job))}) @@ -111,8 +168,8 @@ func Test_client_server() endif endtry - call assert_fails("let x=remote_peek([])", 'E730:') - call assert_fails("let x=remote_read('vim10')", 'E277:') + call assert_fails("let x = remote_peek([])", 'E730:') + call assert_fails("let x = remote_read('vim10')", 'E277:') endfunc " Uncomment this line to get a debugging log -- cgit From 358f9b776b48e854fdb714c76b24c5929bbd8544 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 19 Jul 2022 21:36:53 +0800 Subject: vim-patch:8.2.2632: not all command line arguments are tested MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Not all command line arguments are tested. Solution: Add tests for -D and -serverlist. (Dominique Pellé, closes vim/vim#7992) https://github.com/vim/vim/commit/c5cf369e9543ff065e2e1da91da3218c223840e2 Cherry-pick two deletions from patch 8.2.1799. --- src/nvim/testdir/test_clientserver.vim | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/testdir/test_clientserver.vim') diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim index 788b1dd204..edf36b413b 100644 --- a/src/nvim/testdir/test_clientserver.vim +++ b/src/nvim/testdir/test_clientserver.vim @@ -38,6 +38,14 @@ func Test_client_server() " When using valgrind it takes much longer. call WaitForAssert({-> assert_match(name, serverlist())}) + if !has('win32') + if RunVim([], [], '--serverlist >Xtest_serverlist') + let lines = readfile('Xtest_serverlist') + call assert_true(index(lines, 'XVIMTEST') >= 0) + endif + call delete('Xtest_serverlist') + endif + eval name->remote_foreground() call remote_send(name, ":let testvar = 'yes'\") -- cgit