From de16b6dc7a61f2f0726537dfaa0c9a8061c7e563 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 7 Jun 2019 08:02:04 -0400 Subject: vim-patch:8.1.0406: several command line arguments are not tested Problem: Several command line arguments are not tested. Solution: Add tests for -A, -F, -H, -p and -V. (Dominique Pelle, closes vim/vim#3446) https://github.com/vim/vim/commit/9e81db9742a35cc972ce5cae204e837093987692 --- src/nvim/testdir/test_startup.vim | 65 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 3bc9eaf756..c86c62711f 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -201,7 +201,7 @@ func Test_o_arg() " - both windows should have the same height " - window height (+ 2 for the statusline and Ex command) should be equal " to the number of lines - " - buffer of both windowns should have no name + " - buffer of both windows should have no name let [wn, wh1, wh2, ln, ww1, ww2, cn, bn1, bn2] = readfile('Xtestout') call assert_equal('2', wn) call assert_inrange(0, 1, ww1 - ww2) @@ -227,6 +227,69 @@ func Test_o_arg() call delete('Xtestout') endfunc +" Test the -p[N] argument to open N tabpages. +func Test_p_arg() + let after = [ + \ 'call writefile(split(execute("tabs"), "\n"), "Xtestout")', + \ 'qall', + \ ] + if RunVim([], after, '-p2') + let lines = readfile('Xtestout') + call assert_equal(4, len(lines)) + call assert_equal('Tab page 1', lines[0]) + call assert_equal('> [No Name]', lines[1]) + call assert_equal('Tab page 2', lines[2]) + call assert_equal(' [No Name]', lines[3]) + endif + + if RunVim([], after, '-p foo bar') + let lines = readfile('Xtestout') + call assert_equal(4, len(lines)) + call assert_equal('Tab page 1', lines[0]) + call assert_equal('> foo', lines[1]) + call assert_equal('Tab page 2', lines[2]) + call assert_equal(' bar', lines[3]) + endif + + call delete('Xtestout') +endfunc + +" Test the -V[N] argument to set the 'version' option to [N] +func Test_V_arg() + let out = system(GetVimCommand() . ' --clean -es -X -V0 -c "set verbose?" -cq') + call assert_equal(" verbose=0\n", out) + + let out = system(GetVimCommand() . ' --clean -es -X -V2 -c "set verbose?" -cq') + call assert_match("^sourcing \"$VIMRUNTIME/defaults\.vim\"\r\nSearching for \"filetype\.vim\".*\n verbose=2\n$", out) + + let out = system(GetVimCommand() . ' --clean -es -X -V15 -c "set verbose?" -cq') + call assert_match("\+*\nsourcing \"$VIMRUNTIME/defaults\.vim\"\r\nline 1: \" The default vimrc file\..*\n verbose=15\n\+*", out) +endfunc + +" Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes). +func Test_A_F_H_arg() + let after = [ + \ 'call writefile([&rightleft, &arabic, 0, &hkmap], "Xtestout")', + \ 'qall', + \ ] + if has('arabic') && RunVim([], after, '-A') + let lines = readfile('Xtestout') + call assert_equal(['1', '1', '0', '0'], lines) + endif + + if has('farsi') && RunVim([], after, '-F') + let lines = readfile('Xtestout') + call assert_equal(['1', '0', '1', '0'], lines) + endif + + if has('rightleft') && RunVim([], after, '-H') + let lines = readfile('Xtestout') + call assert_equal(['1', '0', '0', '1'], lines) + endif + + call delete('Xtestout') +endfunc + func Test_file_args() let after = [ \ 'call writefile(argv(), "Xtestout")', -- cgit From a597ea7bccf4f7fdf7d8b35f934677201fe69134 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 7 Jun 2019 16:08:49 -0400 Subject: vim-patch:8.1.0409: startup test fails on MS-Windows Problem: Startup test fails on MS-Windows. Solution: Do the Arabic test in silent Ex mode. Loosen the check for -V2. https://github.com/vim/vim/commit/4b1c9a91b5d7f98b6e3391e776a289d485aa274d --- src/nvim/testdir/test_startup.vim | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index c86c62711f..8656985130 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -254,16 +254,21 @@ func Test_p_arg() call delete('Xtestout') endfunc -" Test the -V[N] argument to set the 'version' option to [N] +" Test the -V[N] argument to set the 'verbose' option to [N] func Test_V_arg() + if has('gui_running') + " Can't catch the output of gvim. + return + endif let out = system(GetVimCommand() . ' --clean -es -X -V0 -c "set verbose?" -cq') call assert_equal(" verbose=0\n", out) let out = system(GetVimCommand() . ' --clean -es -X -V2 -c "set verbose?" -cq') - call assert_match("^sourcing \"$VIMRUNTIME/defaults\.vim\"\r\nSearching for \"filetype\.vim\".*\n verbose=2\n$", out) + call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nSearching for \"filetype\.vim\".*\n", out) + call assert_match(" verbose=2\n", out) let out = system(GetVimCommand() . ' --clean -es -X -V15 -c "set verbose?" -cq') - call assert_match("\+*\nsourcing \"$VIMRUNTIME/defaults\.vim\"\r\nline 1: \" The default vimrc file\..*\n verbose=15\n\+*", out) + call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nline 1: \" The default vimrc file\..* verbose=15\n", out) endfunc " Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes). @@ -272,7 +277,9 @@ func Test_A_F_H_arg() \ 'call writefile([&rightleft, &arabic, 0, &hkmap], "Xtestout")', \ 'qall', \ ] - if has('arabic') && RunVim([], after, '-A') + " Use silent Ex mode to avoid the hit-Enter prompt for the warning that + " 'encoding' is not utf-8. + if has('arabic') && &encoding == 'utf-8' && RunVim([], after, '-e -s -A') let lines = readfile('Xtestout') call assert_equal(['1', '1', '0', '0'], lines) endif -- cgit From a64e0e6a58ae29fd7a673a81bee668d7eeed3a73 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 7 Jun 2019 08:11:06 -0400 Subject: vim-patch:8.1.0417: several command line arguments are not tested Problem: Several command line arguments are not tested. Solution: Add tests for -m, -M, -R and -Vfile. (Dominique Pelle, closes vim/vim#3458) https://github.com/vim/vim/commit/036b09ca78c5516d2b914ebc9494bf7580b8fed8 --- src/nvim/testdir/test_startup.vim | 50 +++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 8656985130..f119e9d5bc 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -196,8 +196,8 @@ func Test_o_arg() " Open 2 windows split vertically. Expect: " - 2 windows " - both windows should have the same or almost the same width - " - sum of both windows width (+ 1 separator) should be equal to the - " number of columns + " - sum of both windows width (+ 1 for the separator) should be equal to + " the number of columns " - both windows should have the same height " - window height (+ 2 for the statusline and Ex command) should be equal " to the number of lines @@ -271,6 +271,48 @@ func Test_V_arg() call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nline 1: \" The default vimrc file\..* verbose=15\n", out) endfunc +" Test the -V[N]{filename} argument to set the 'verbose' option to N +" and set 'verbosefile' to filename. +func Test_V_file_arg() + if RunVim([], [], ' --clean -X -V2Xverbosefile -c "set verbose? verbosefile?" -cq') + let out = join(readfile('Xverbosefile'), "\n") + call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\n", out) + call assert_match("\n verbose=2\n", out) + call assert_match("\n verbosefile=Xverbosefile", out) + endif + + call delete('Xverbosefile') +endfunc + +" Test the -m, -M and -R arguments: +" -m resets 'write' +" -M resets 'modifiable' and 'write' +" -R sets 'readonly' +func Test_m_M_R() + let after = [ + \ 'call writefile([&write, &modifiable, &readonly, &updatecount], "Xtestout")', + \ 'qall', + \ ] + if RunVim([], after, '') + let lines = readfile('Xtestout') + call assert_equal(['1', '1', '0', '200'], lines) + endif + if RunVim([], after, '-m') + let lines = readfile('Xtestout') + call assert_equal(['0', '1', '0', '200'], lines) + endif + if RunVim([], after, '-M') + let lines = readfile('Xtestout') + call assert_equal(['0', '0', '0', '200'], lines) + endif + if RunVim([], after, '-R') + let lines = readfile('Xtestout') + call assert_equal(['1', '1', '1', '10000'], lines) + endif + + call delete('Xtestout') +endfunc + " Test the -A, -F and -H arguments (Arabic, Farsi and Hebrew modes). func Test_A_F_H_arg() let after = [ @@ -417,7 +459,7 @@ func Test_zzz_startinsert() call writefile(['123456'], 'Xtestout') let after = [ \ ':startinsert', - \ 'call feedkeys("foobar\:wq\","t")' + \ 'call feedkeys("foobar\:wq\","t")' \ ] if RunVim([], after, 'Xtestout') let lines = readfile('Xtestout') @@ -427,7 +469,7 @@ func Test_zzz_startinsert() call writefile(['123456'], 'Xtestout') let after = [ \ ':startinsert!', - \ 'call feedkeys("foobar\:wq\","t")' + \ 'call feedkeys("foobar\:wq\","t")' \ ] if RunVim([], after, 'Xtestout') let lines = readfile('Xtestout') -- cgit From b868f87310c4fc108ad13be5b0ba260599d3b6d9 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 7 Jun 2019 16:12:01 -0400 Subject: test/old: ignore defaults.vim assertion --- src/nvim/testdir/test_startup.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index f119e9d5bc..b1a05d9c1b 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -264,11 +264,11 @@ func Test_V_arg() call assert_equal(" verbose=0\n", out) let out = system(GetVimCommand() . ' --clean -es -X -V2 -c "set verbose?" -cq') - call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nSearching for \"filetype\.vim\".*\n", out) + " call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nSearching for \"filetype\.vim\".*\n", out) call assert_match(" verbose=2\n", out) let out = system(GetVimCommand() . ' --clean -es -X -V15 -c "set verbose?" -cq') - call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nline 1: \" The default vimrc file\..* verbose=15\n", out) + " call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nline 1: \" The default vimrc file\..* verbose=15\n", out) endfunc " Test the -V[N]{filename} argument to set the 'verbose' option to N @@ -276,7 +276,7 @@ endfunc func Test_V_file_arg() if RunVim([], [], ' --clean -X -V2Xverbosefile -c "set verbose? verbosefile?" -cq') let out = join(readfile('Xverbosefile'), "\n") - call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\n", out) + " call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\n", out) call assert_match("\n verbose=2\n", out) call assert_match("\n verbosefile=Xverbosefile", out) endif -- cgit From 0206f279baf3250e7b1ae35eb29b581da7cc8b9b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 7 Jun 2019 16:09:46 -0400 Subject: vim-patch:8.1.0426: accessing invalid memory in SmcOpenConnection() Problem: Accessing invalid memory in SmcOpenConnection(). Solution: Reduce size of errorstring by one. (Dominique Pelle, closes vim/vim#3469) https://github.com/vim/vim/commit/4841a7ccaed57f723016656e9683b587ac91f621 --- src/nvim/testdir/test_startup.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index b1a05d9c1b..873f2e8731 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -274,7 +274,7 @@ endfunc " Test the -V[N]{filename} argument to set the 'verbose' option to N " and set 'verbosefile' to filename. func Test_V_file_arg() - if RunVim([], [], ' --clean -X -V2Xverbosefile -c "set verbose? verbosefile?" -cq') + if RunVim([], [], ' --clean -V2Xverbosefile -c "set verbose? verbosefile?" -cq') let out = join(readfile('Xverbosefile'), "\n") " call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\n", out) call assert_match("\n verbose=2\n", out) -- cgit