From c84b39150f3f5e12e042777f61ca9adf13be09d8 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Mon, 23 Sep 2019 22:12:02 +0200 Subject: vim-patch:8.1.1362: code and data in tests can be hard to read Problem: Code and data in tests can be hard to read. Solution: Use the new heredoc style. (Yegappan Lakshmanan, closes vim/vim#4400) https://github.com/vim/vim/commit/c79745a82faeb5a6058e915ca49a4c69fa60ea01 --- src/nvim/testdir/test_startup.vim | 150 ++++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 69 deletions(-) (limited to 'src/nvim/testdir/test_startup.vim') diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 1e70f28a00..a38625cca8 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -20,25 +20,27 @@ func Test_after_comes_later() if !has('packages') return endif - let before = [ - \ 'set nocp viminfo+=nviminfo', - \ 'set guioptions+=M', - \ 'let $HOME = "/does/not/exist"', - \ 'set loadplugins', - \ 'set rtp=Xhere,Xafter,Xanother', - \ 'set packpath=Xhere,Xafter', - \ 'set nomore', - \ 'let g:sequence = ""', - \ ] - let after = [ - \ 'redir! > Xtestout', - \ 'scriptnames', - \ 'redir END', - \ 'redir! > Xsequence', - \ 'echo g:sequence', - \ 'redir END', - \ 'quit', - \ ] + let before =<< trim [CODE] + set nocp viminfo+=nviminfo + set guioptions+=M + let $HOME = "/does/not/exist" + set loadplugins + set rtp=Xhere,Xafter,Xanother + set packpath=Xhere,Xafter + set nomore + let g:sequence = "" + [CODE] + + let after =<< trim [CODE] + redir! > Xtestout + scriptnames + redir END + redir! > Xsequence + echo g:sequence + redir END + quit + [CODE] + call mkdir('Xhere/plugin', 'p') call writefile(['let g:sequence .= "here "'], 'Xhere/plugin/here.vim') call mkdir('Xanother/plugin', 'p') @@ -77,15 +79,16 @@ func Test_pack_in_rtp_when_plugins_run() if !has('packages') return endif - let before = [ - \ 'set nocp viminfo+=nviminfo', - \ 'set guioptions+=M', - \ 'let $HOME = "/does/not/exist"', - \ 'set loadplugins', - \ 'set rtp=Xhere', - \ 'set packpath=Xhere', - \ 'set nomore', - \ ] + let before =<< trim [CODE] + set nocp viminfo+=nviminfo + set guioptions+=M + let $HOME = "/does/not/exist" + set loadplugins + set rtp=Xhere + set packpath=Xhere + set nomore + [CODE] + let after = [ \ 'quit', \ ] @@ -133,11 +136,12 @@ endfunc func Test_compatible_args() throw "skipped: Nvim is always 'nocompatible'" - let after = [ - \ 'call writefile([string(&compatible)], "Xtestout")', - \ 'set viminfo+=nviminfo', - \ 'quit', - \ ] + let after =<< trim [CODE] + call writefile([string(&compatible)], "Xtestout") + set viminfo+=nviminfo + quit + [CODE] + if RunVim([], after, '-C') let lines = readfile('Xtestout') call assert_equal('1', lines[0]) @@ -154,14 +158,15 @@ endfunc " Test the -o[N] and -O[N] arguments to open N windows split " horizontally or vertically. func Test_o_arg() - let after = [ - \ 'call writefile([winnr("$"), - \ winheight(1), winheight(2), &lines, - \ winwidth(1), winwidth(2), &columns, - \ bufname(winbufnr(1)), bufname(winbufnr(2))], - \ "Xtestout")', - \ 'qall', - \ ] + let after =<< trim [CODE] + call writefile([winnr("$"), + \ winheight(1), winheight(2), &lines, + \ winwidth(1), winwidth(2), &columns, + \ bufname(winbufnr(1)), bufname(winbufnr(2))], + \ "Xtestout") + qall + [CODE] + if RunVim([], after, '-o2') " Open 2 windows split horizontally. Expect: " - 2 windows @@ -230,10 +235,11 @@ endfunc " Test the -p[N] argument to open N tabpages. func Test_p_arg() - let after = [ - \ 'call writefile(split(execute("tabs"), "\n"), "Xtestout")', - \ 'qall', - \ ] + let after =<< trim [CODE] + call writefile(split(execute("tabs"), "\n"), "Xtestout") + qall + [CODE] + if RunVim([], after, '-p2') let lines = readfile('Xtestout') call assert_equal(4, len(lines)) @@ -290,10 +296,11 @@ endfunc " -M resets 'modifiable' and 'write' " -R sets 'readonly' func Test_m_M_R() - let after = [ - \ 'call writefile([&write, &modifiable, &readonly, &updatecount], "Xtestout")', - \ 'qall', - \ ] + let after =<< trim [CODE] + call writefile([&write, &modifiable, &readonly, &updatecount], "Xtestout") + qall + [CODE] + if RunVim([], after, '') let lines = readfile('Xtestout') call assert_equal(['1', '1', '0', '200'], lines) @@ -316,10 +323,11 @@ 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', - \ ] + let after =<< trim [CODE] + call writefile([&rightleft, &arabic, 0, &hkmap], "Xtestout") + qall + [CODE] + " 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') @@ -423,10 +431,11 @@ func Test_invalid_args() endfunc func Test_file_args() - let after = [ - \ 'call writefile(argv(), "Xtestout")', - \ 'qall', - \ ] + let after =<< trim [CODE] + call writefile(argv(), "Xtestout") + qall + [CODE] + if RunVim([], after, '') let lines = readfile('Xtestout') call assert_equal(0, len(lines)) @@ -487,10 +496,11 @@ func Test_startuptime() endfunc func Test_read_stdin() - let after = [ - \ 'write Xtestout', - \ 'quit!', - \ ] + let after =<< trim [CODE] + write Xtestout + quit! + [CODE] + if RunVimPiped([], after, '-', 'echo something | ') let lines = readfile('Xtestout') " MS-Windows adds a space after the word @@ -540,20 +550,22 @@ endfunc func Test_zzz_startinsert() " Test :startinsert call writefile(['123456'], 'Xtestout') - let after = [ - \ ':startinsert', - \ 'call feedkeys("foobar\:wq\","t")' - \ ] + let after =<< trim [CODE] + :startinsert + call feedkeys("foobar\:wq\","t") + [CODE] + if RunVim([], after, 'Xtestout') let lines = readfile('Xtestout') call assert_equal(['foobar123456'], lines) endif " Test :startinsert! call writefile(['123456'], 'Xtestout') - let after = [ - \ ':startinsert!', - \ 'call feedkeys("foobar\:wq\","t")' - \ ] + let after =<< trim [CODE] + :startinsert! + call feedkeys("foobar\:wq\","t") + [CODE] + if RunVim([], after, 'Xtestout') let lines = readfile('Xtestout') call assert_equal(['123456foobar'], lines) -- cgit From 8e385eb46a8b961a760e05b4cfa053cf713def62 Mon Sep 17 00:00:00 2001 From: We're Yet <58348703+butwerenotthereyet@users.noreply.github.com> Date: Sat, 18 Jan 2020 13:19:56 -0800 Subject: tabpage: :tabs indicates previous tabpage's curwin --- src/nvim/testdir/test_startup.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir/test_startup.vim') diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index a38625cca8..15b55d35c1 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -246,7 +246,7 @@ func Test_p_arg() 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]) + call assert_equal('# [No Name]', lines[3]) endif if RunVim([], after, '-p foo bar') @@ -255,7 +255,7 @@ func Test_p_arg() 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]) + call assert_equal('# bar', lines[3]) endif call delete('Xtestout') -- cgit From cd16e036d1ca1853853125fe4bc0ce6a8a2b4eb1 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 3 May 2020 13:41:26 -0400 Subject: vim-patch:8.2.0691: startup test fails Problem: Startup test fails. Solution: Adjust expected output from -V2 argument. https://github.com/vim/vim/commit/7779ee30d912e9dd5bd2371f8b27057bd249d53c --- src/nvim/testdir/test_startup.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_startup.vim') diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 15b55d35c1..4741753f31 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -271,7 +271,7 @@ 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\nline \\d\\+: sourcing \"[\\./]*runtime[\\/]filetype\.vim\".*\n", out) call assert_match(" verbose=2\n", out) let out = system(GetVimCommand() . ' --clean -es -X -V15 -c "set verbose?" -cq') -- cgit From ed4df85f6bae488d763b5d0eebbf2db9da25551d Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 3 May 2020 13:43:16 -0400 Subject: vim-patch:8.2.0692: startup test fails on MS-Windows Problem: Startup test fails on MS-Windows. Solution: Allow for any path. https://github.com/vim/vim/commit/4515bcdec8f3ba54f9d671cc37b9c9b3e19ea999 --- src/nvim/testdir/test_startup.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_startup.vim') diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 4741753f31..f03c493275 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -271,7 +271,7 @@ 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\nline \\d\\+: sourcing \"[\\./]*runtime[\\/]filetype\.vim\".*\n", out) + " call assert_match("sourcing \"$VIMRUNTIME[\\/]defaults\.vim\"\r\nline \\d\\+: sourcing \"[^\"]*runtime[\\/]filetype\.vim\".*\n", out) call assert_match(" verbose=2\n", out) let out = system(GetVimCommand() . ' --clean -es -X -V15 -c "set verbose?" -cq') -- cgit From e89462d9855eef7718d482df7f92da4279a1c5c3 Mon Sep 17 00:00:00 2001 From: kuuote <36663503+kuuote@users.noreply.github.com> Date: Mon, 25 May 2020 03:45:25 +0900 Subject: vim-patch:8.1.2233: cannot get the Vim command line arguments (#12117) Problem: Cannot get the Vim command line arguments. Solution: Add v:argv. (Dmitri Vereshchagin, closes vim/vim#1322) https://github.com/vim/vim/commit/69bf634858a2a75f2984e42b1e4017bc529a040a --- src/nvim/testdir/test_startup.vim | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/nvim/testdir/test_startup.vim') diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index f03c493275..9abaca5957 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -584,3 +584,12 @@ func Test_start_with_tabs() " clean up call StopVimInTerminal(buf) endfunc + +func Test_v_argv() + let out = system(GetVimCommand() . ' -es -V1 -X arg1 --cmd "echo v:argv" --cmd q') + let list = split(out, "', '") + call assert_match('vim', list[0]) + let idx = index(list, 'arg1') + call assert_true(idx > 2) + call assert_equal(['arg1', '--cmd', 'echo v:argv', '--cmd', 'q'']'], list[idx:]) +endfunc -- cgit