0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 9.0.0767: too many delete() calls in tests

Problem:    Too many delete() calls in tests.
Solution:   Use deferred delete where possible.
This commit is contained in:
Bram Moolenaar
2022-10-15 20:52:26 +01:00
parent 0e9bdad545
commit c4860bdd28
14 changed files with 169 additions and 313 deletions

View File

@@ -154,10 +154,8 @@ func Test_mouse_click_in_tab()
set mouse=a set mouse=a
exe "norm \<LeftMouse>" exe "norm \<LeftMouse>"
END END
call writefile(lines, 'Xclickscript') call writefile(lines, 'Xclickscript', 'D')
call RunVim([], [], "-e -s -S Xclickscript -c qa") call RunVim([], [], "-e -s -S Xclickscript -c qa")
call delete('Xclickscript')
endfunc endfunc

View File

@@ -606,13 +606,12 @@ func Test_tabpage_cmdheight()
\ 'echo "hello\nthere"', \ 'echo "hello\nthere"',
\ 'tabnext', \ 'tabnext',
\ 'redraw', \ 'redraw',
\ ], 'XTest_tabpage_cmdheight') \ ], 'XTest_tabpage_cmdheight', 'D')
" Check that cursor line is concealed " Check that cursor line is concealed
let buf = RunVimInTerminal('-S XTest_tabpage_cmdheight', {'statusoff': 3}) let buf = RunVimInTerminal('-S XTest_tabpage_cmdheight', {'statusoff': 3})
call VerifyScreenDump(buf, 'Test_tabpage_cmdheight', {}) call VerifyScreenDump(buf, 'Test_tabpage_cmdheight', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XTest_tabpage_cmdheight')
endfunc endfunc
" Test for closing the tab page from a command window " Test for closing the tab page from a command window

View File

@@ -1,7 +1,7 @@
" test 'tagcase' option " test 'tagcase' option
func Test_tagcase() func Test_tagcase()
call writefile(["Bar\tXtext\t3", "Foo\tXtext\t2", "foo\tXtext\t4"], 'Xtags') call writefile(["Bar\tXtext\t3", "Foo\tXtext\t2", "foo\tXtext\t4"], 'Xtags', 'D')
set tags=Xtags set tags=Xtags
e Xtext e Xtext
@@ -43,7 +43,6 @@ func Test_tagcase()
endfor endfor
endfor endfor
call delete('Xtags')
set tags& set tags&
set ic& set ic&
setg tc& setg tc&

View File

@@ -105,7 +105,7 @@ func Test_tagfunc_settagstack()
return [{'name' : 'mytag', 'filename' : 'Xtest', 'cmd' : '1'}] return [{'name' : 'mytag', 'filename' : 'Xtest', 'cmd' : '1'}]
endfunc endfunc
set tagfunc=Mytagfunc1 set tagfunc=Mytagfunc1
call writefile([''], 'Xtest') call writefile([''], 'Xtest', 'D')
call assert_fails('tag xyz', 'E986:') call assert_fails('tag xyz', 'E986:')
func Mytagfunc2(pat, flags, info) func Mytagfunc2(pat, flags, info)
@@ -115,7 +115,6 @@ func Test_tagfunc_settagstack()
set tagfunc=Mytagfunc2 set tagfunc=Mytagfunc2
call assert_fails('tag xyz', 'E986:') call assert_fails('tag xyz', 'E986:')
call delete('Xtest')
set tagfunc& set tagfunc&
delfunc Mytagfunc1 delfunc Mytagfunc1
delfunc Mytagfunc2 delfunc Mytagfunc2

View File

@@ -20,8 +20,8 @@ func Test_ptjump()
\ "one\tXptfile\t1", \ "one\tXptfile\t1",
\ "three\tXptfile\t3", \ "three\tXptfile\t3",
\ "two\tXptfile\t2"], \ "two\tXptfile\t2"],
\ 'Xpttags') \ 'Xpttags', 'D')
call writefile(['one', 'two', 'three'], 'Xptfile') call writefile(['one', 'two', 'three'], 'Xptfile', 'D')
%bw! %bw!
ptjump two ptjump two
@@ -48,8 +48,6 @@ func Test_ptjump()
call assert_equal(5, winheight(0)) call assert_equal(5, winheight(0))
close close
call delete('Xpttags')
call delete('Xptfile')
set tags& set tags&
endfunc endfunc
@@ -60,14 +58,13 @@ func Test_cancel_ptjump()
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
\ "word\tfile1\tcmd1", \ "word\tfile1\tcmd1",
\ "word\tfile2\tcmd2"], \ "word\tfile2\tcmd2"],
\ 'Xtags') \ 'Xtags', 'D')
only! only!
call feedkeys(":ptjump word\<CR>\<CR>", "xt") call feedkeys(":ptjump word\<CR>\<CR>", "xt")
help help
call assert_equal(2, winnr('$')) call assert_equal(2, winnr('$'))
call delete('Xtags')
set tags& set tags&
quit quit
endfunc endfunc
@@ -77,7 +74,7 @@ func Test_static_tagjump()
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
\ "one\tXtjfile1\t/^one/;\"\tf\tfile:\tsignature:(void)", \ "one\tXtjfile1\t/^one/;\"\tf\tfile:\tsignature:(void)",
\ "word\tXtjfile2\tcmd2"], \ "word\tXtjfile2\tcmd2"],
\ 'Xtjtags') \ 'Xtjtags', 'D')
new Xtjfile1 new Xtjfile1
call setline(1, ['empty', 'one()', 'empty']) call setline(1, ['empty', 'one()', 'empty'])
write write
@@ -86,7 +83,6 @@ func Test_static_tagjump()
bwipe! bwipe!
set tags& set tags&
call delete('Xtjtags')
call delete('Xtjfile1') call delete('Xtjfile1')
endfunc endfunc
@@ -97,7 +93,7 @@ func Test_duplicate_tagjump()
\ "thesame\tXdtfile1\t2;\"\td\tfile:", \ "thesame\tXdtfile1\t2;\"\td\tfile:",
\ "thesame\tXdtfile1\t3;\"\td\tfile:", \ "thesame\tXdtfile1\t3;\"\td\tfile:",
\ ], \ ],
\ 'Xdttags') \ 'Xdttags', 'D')
new Xdtfile1 new Xdtfile1
call setline(1, ['thesame one', 'thesame two', 'thesame three']) call setline(1, ['thesame one', 'thesame two', 'thesame three'])
write write
@@ -110,7 +106,6 @@ func Test_duplicate_tagjump()
bwipe! bwipe!
set tags& set tags&
call delete('Xdttags')
call delete('Xdtfile1') call delete('Xdtfile1')
endfunc endfunc
@@ -121,8 +116,8 @@ func Test_tagjump_switchbuf()
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
\ "second\tXsbfile1\t2", \ "second\tXsbfile1\t2",
\ "third\tXsbfile1\t3",], \ "third\tXsbfile1\t3",],
\ 'Xswtags') \ 'Xswtags', 'D')
call writefile(['first', 'second', 'third'], 'Xsbfile1') call writefile(['first', 'second', 'third'], 'Xsbfile1', 'D')
enew | only enew | only
set switchbuf= set switchbuf=
@@ -153,8 +148,6 @@ func Test_tagjump_switchbuf()
tabclose! tabclose!
enew | only enew | only
call delete('Xsbfile1')
call delete('Xswtags')
set tags& set tags&
set switchbuf&vim set switchbuf&vim
endfunc endfunc
@@ -168,13 +161,13 @@ function Test_keyword_jump()
\ " test text", \ " test text",
\ " start OK if found this line", \ " start OK if found this line",
\ " start found wrong line", \ " start found wrong line",
\ "test text"], 'Xtestfile') \ "test text"], 'Xtestfile', 'D')
call writefile(["/* test text test tex start here", call writefile(["/* test text test tex start here",
\ " some text", \ " some text",
\ " test text", \ " test text",
\ " start OK if found this line", \ " start OK if found this line",
\ " start found wrong line", \ " start found wrong line",
\ "test text"], 'Xinclude') \ "test text"], 'Xinclude', 'D')
new Xtestfile new Xtestfile
call cursor(1,1) call cursor(1,1)
call search("start") call search("start")
@@ -189,8 +182,6 @@ function Test_keyword_jump()
call assert_fails('tag /\%(/', 'E426:') call assert_fails('tag /\%(/', 'E426:')
enew! | only enew! | only
call delete('Xtestfile')
call delete('Xinclude')
endfunction endfunction
" Test for jumping to a tag with 'hidden' set, with symbolic link in path of " Test for jumping to a tag with 'hidden' set, with symbolic link in path of
@@ -205,9 +196,9 @@ func Test_tag_symbolic()
call writefile([ call writefile([
\ "SECTION_OFF " . getcwd() . "/Xtest.dir/Xtest.c /^#define SECTION_OFF 3$/", \ "SECTION_OFF " . getcwd() . "/Xtest.dir/Xtest.c /^#define SECTION_OFF 3$/",
\ '', \ '',
\ ], 'Xsymtags') \ ], 'Xsymtags', 'D')
call writefile(['#define SECTION_OFF 3', call writefile(['#define SECTION_OFF 3',
\ '#define NUM_SECTIONS 3'], 'Xtest.c') \ '#define NUM_SECTIONS 3'], 'Xtest.c', 'D')
" Try jumping to a tag, but with a path that contains a symbolic link. When " Try jumping to a tag, but with a path that contains a symbolic link. When
" wrong, this will give the ATTENTION message. The next space will then be " wrong, this will give the ATTENTION message. The next space will then be
@@ -223,8 +214,6 @@ func Test_tag_symbolic()
set hidden& set hidden&
set tags& set tags&
enew! enew!
call delete('Xsymtags')
call delete('Xtest.c')
call delete("Xtest.dir", "rf") call delete("Xtest.dir", "rf")
%bwipe! %bwipe!
endfunc endfunc
@@ -243,13 +232,13 @@ func Test_tag_file_encoding()
set encoding=utf8 set encoding=utf8
let content = ['text for tags1', 'abcdefghijklmnopqrs'] let content = ['text for tags1', 'abcdefghijklmnopqrs']
call writefile(content, 'Xtags1.txt') call writefile(content, 'Xtags1.txt', 'D')
let content = ['text for tags2', ''] let content = ['text for tags2', '']
call writefile(content, 'Xtags2.txt') call writefile(content, 'Xtags2.txt', 'D')
let content = ['text for tags3', ''] let content = ['text for tags3', '']
call writefile(content, 'Xtags3.txt') call writefile(content, 'Xtags3.txt', 'D')
let content = ['!_TAG_FILE_ENCODING utf-8 //', 'abcdefghijklmnopqrs Xtags1.txt /abcdefghijklmnopqrs'] let content = ['!_TAG_FILE_ENCODING utf-8 //', 'abcdefghijklmnopqrs Xtags1.txt /abcdefghijklmnopqrs']
call writefile(content, 'Xtags1') call writefile(content, 'Xtags1', 'D')
" case1: " case1:
new new
@@ -280,20 +269,15 @@ func Test_tag_file_encoding()
call add(contents, 'abc' .. i call add(contents, 'abc' .. i
\ .. " Xtags3.txt /\x82`\x82a\x82b") \ .. " Xtags3.txt /\x82`\x82a\x82b")
endfor endfor
call writefile(contents, 'Xenctags') call writefile(contents, 'Xenctags', 'D')
set tags=Xenctags set tags=Xenctags
tag abc50 tag abc50
call assert_equal('Xtags3.txt', expand('%:t')) call assert_equal('Xtags3.txt', expand('%:t'))
call assert_equal('', getline('.')) call assert_equal('', getline('.'))
call delete('Xenctags')
close close
set tags& set tags&
let &encoding = save_enc let &encoding = save_enc
call delete('Xtags1.txt')
call delete('Xtags2.txt')
call delete('Xtags3.txt')
call delete('Xtags1')
endfunc endfunc
" Test for emacs-style tags file (TAGS) " Test for emacs-style tags file (TAGS)
@@ -307,14 +291,14 @@ func Test_tagjump_etags()
\ "\tfoo();", \ "\tfoo();",
\ "\treturn 0;", \ "\treturn 0;",
\ "}", \ "}",
\ ], 'Xmain.c') \ ], 'Xmain.c', 'D')
call writefile([ call writefile([
\ "\x0c", \ "\x0c",
\ "Xmain.c,64", \ "Xmain.c,64",
\ "void foo() {}\x7ffoo\x011,0", \ "void foo() {}\x7ffoo\x011,0",
\ "int main(int argc, char **argv)\x7fmain\x012,14", \ "int main(int argc, char **argv)\x7fmain\x012,14",
\ ], 'Xtetags') \ ], 'Xtetags', 'D')
set tags=Xtetags set tags=Xtetags
ta foo ta foo
call assert_equal('void foo() {}', getline('.')) call assert_equal('void foo() {}', getline('.'))
@@ -333,7 +317,7 @@ func Test_tagjump_etags()
\ "\x0c", \ "\x0c",
\ "Xmain.c,64", \ "Xmain.c,64",
\ "int main(int argc, char **argv)\x7fmain\x012,14", \ "int main(int argc, char **argv)\x7fmain\x012,14",
\ ], 'Xtags2') \ ], 'Xtags2', 'D')
tag main tag main
call assert_equal(2, line('.')) call assert_equal(2, line('.'))
call assert_fails('tag bar', 'E426:') call assert_fails('tag bar', 'E426:')
@@ -383,18 +367,15 @@ func Test_tagjump_etags()
\ ], 'Xtags2') \ ], 'Xtags2')
call assert_fails('tag foo', 'E431:') call assert_fails('tag foo', 'E431:')
call delete('Xtetags')
call delete('Xtags2')
call delete('Xmain.c')
set tags& set tags&
bwipe! bwipe!
endfunc endfunc
" Test for getting and modifying the tag stack " Test for getting and modifying the tag stack
func Test_getsettagstack() func Test_getsettagstack()
call writefile(['line1', 'line2', 'line3'], 'Xstsfile1') call writefile(['line1', 'line2', 'line3'], 'Xstsfile1', 'D')
call writefile(['line1', 'line2', 'line3'], 'Xstsfile2') call writefile(['line1', 'line2', 'line3'], 'Xstsfile2', 'D')
call writefile(['line1', 'line2', 'line3'], 'Xstsfile3') call writefile(['line1', 'line2', 'line3'], 'Xstsfile3', 'D')
enew | only enew | only
call settagstack(1, {'items' : []}) call settagstack(1, {'items' : []})
@@ -414,7 +395,7 @@ func Test_getsettagstack()
\ "one\tXstsfile1\t1", \ "one\tXstsfile1\t1",
\ "three\tXstsfile3\t3", \ "three\tXstsfile3\t3",
\ "two\tXstsfile2\t2"], \ "two\tXstsfile2\t2"],
\ 'Xtsttags') \ 'Xtsttags', 'D')
let stk = [] let stk = []
call add(stk, {'bufnr' : bufnr('%'), 'tagname' : 'one', call add(stk, {'bufnr' : bufnr('%'), 'tagname' : 'one',
@@ -515,28 +496,24 @@ func Test_getsettagstack()
call assert_fails('call gettagstack()', 'E342:') call assert_fails('call gettagstack()', 'E342:')
call settagstack(1, {'items' : []}) call settagstack(1, {'items' : []})
call delete('Xstsfile1')
call delete('Xstsfile2')
call delete('Xstsfile3')
call delete('Xtsttags')
set tags& set tags&
endfunc endfunc
func Test_tag_with_count() func Test_tag_with_count()
call writefile([ call writefile([
\ 'test Xtest.h /^void test();$/;" p typeref:typename:void signature:()', \ 'test Xtest.h /^void test();$/;" p typeref:typename:void signature:()',
\ ], 'Xtags') \ ], 'Xtags', 'D')
call writefile([ call writefile([
\ 'main Xtest.c /^int main()$/;" f typeref:typename:int signature:()', \ 'main Xtest.c /^int main()$/;" f typeref:typename:int signature:()',
\ 'test Xtest.c /^void test()$/;" f typeref:typename:void signature:()', \ 'test Xtest.c /^void test()$/;" f typeref:typename:void signature:()',
\ ], 'Ytags') \ ], 'Ytags', 'D')
cal writefile([ cal writefile([
\ 'int main()', \ 'int main()',
\ 'void test()', \ 'void test()',
\ ], 'Xtest.c') \ ], 'Xtest.c', 'D')
cal writefile([ cal writefile([
\ 'void test();', \ 'void test();',
\ ], 'Xtest.h') \ ], 'Xtest.h', 'D')
set tags=Xtags,Ytags set tags=Xtags,Ytags
new Xtest.c new Xtest.c
@@ -552,12 +529,8 @@ func Test_tag_with_count()
call assert_equal(bufname('%'), 'Xtest.h') call assert_equal(bufname('%'), 'Xtest.h')
set tags& set tags&
call delete('Xtags')
call delete('Ytags')
bwipe Xtest.h bwipe Xtest.h
bwipe Xtest.c bwipe Xtest.c
call delete('Xtest.h')
call delete('Xtest.c')
endfunc endfunc
func Test_tagnr_recall() func Test_tagnr_recall()
@@ -565,14 +538,14 @@ func Test_tagnr_recall()
\ 'test Xtest.h /^void test();$/;" p', \ 'test Xtest.h /^void test();$/;" p',
\ 'main Xtest.c /^int main()$/;" f', \ 'main Xtest.c /^int main()$/;" f',
\ 'test Xtest.c /^void test()$/;" f', \ 'test Xtest.c /^void test()$/;" f',
\ ], 'Xtags') \ ], 'Xtags', 'D')
cal writefile([ cal writefile([
\ 'int main()', \ 'int main()',
\ 'void test()', \ 'void test()',
\ ], 'Xtest.c') \ ], 'Xtest.c', 'D')
cal writefile([ cal writefile([
\ 'void test();', \ 'void test();',
\ ], 'Xtest.h') \ ], 'Xtest.h', 'D')
set tags=Xtags set tags=Xtags
new Xtest.c new Xtest.c
@@ -588,17 +561,14 @@ func Test_tagnr_recall()
call assert_equal(bufname('%'), 'Xtest.h') call assert_equal(bufname('%'), 'Xtest.h')
set tags& set tags&
call delete('Xtags')
bwipe Xtest.h bwipe Xtest.h
bwipe Xtest.c bwipe Xtest.c
call delete('Xtest.h')
call delete('Xtest.c')
endfunc endfunc
func Test_tag_line_toolong() func Test_tag_line_toolong()
call writefile([ call writefile([
\ '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 django/contrib/admin/templates/admin/edit_inline/stacked.html 16;" j line:16 language:HTML' \ '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 django/contrib/admin/templates/admin/edit_inline/stacked.html 16;" j line:16 language:HTML'
\ ], 'Xtags') \ ], 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let old_vbs = &verbose let old_vbs = &verbose
set verbose=5 set verbose=5
@@ -635,7 +605,7 @@ func Test_tag_line_toolong()
\ 'two', \ 'two',
\ 'trhee', \ 'trhee',
\ 'four', \ 'four',
\ ], 'Xsomewhere') \ ], 'Xsomewhere', 'D')
tag foobar tag foobar
call assert_equal('Xsomewhere', expand('%')) call assert_equal('Xsomewhere', expand('%'))
call assert_equal(3, getcurpos()[1]) call assert_equal(3, getcurpos()[1])
@@ -650,8 +620,6 @@ func Test_tag_line_toolong()
" Should not crash " Should not crash
call assert_true(v:true) call assert_true(v:true)
call delete('Xtags')
call delete('Xsomewhere')
set tags& set tags&
let &verbose = old_vbs let &verbose = old_vbs
endfunc endfunc
@@ -665,16 +633,16 @@ func Test_tselect()
\ 'main Xtest.h /^void test();$/;" f', \ 'main Xtest.h /^void test();$/;" f',
\ 'main Xtest.c /^int main()$/;" f', \ 'main Xtest.c /^int main()$/;" f',
\ 'main Xtest.x /^void test()$/;" f', \ 'main Xtest.x /^void test()$/;" f',
\ ], 'Xtags') \ ], 'Xtags', 'D')
cal writefile([ cal writefile([
\ 'int main()', \ 'int main()',
\ 'void test()', \ 'void test()',
\ ], 'Xtest.c') \ ], 'Xtest.c', 'D')
let lines =<< trim [SCRIPT] let lines =<< trim [SCRIPT]
set tags=Xtags set tags=Xtags
[SCRIPT] [SCRIPT]
call writefile(lines, 'XTest_tselect') call writefile(lines, 'XTest_tselect', 'D')
let buf = RunVimInTerminal('-S XTest_tselect', {'rows': 10, 'cols': 50}) let buf = RunVimInTerminal('-S XTest_tselect', {'rows': 10, 'cols': 50})
call TermWait(buf, 50) call TermWait(buf, 50)
@@ -682,22 +650,19 @@ func Test_tselect()
call VerifyScreenDump(buf, 'Test_tselect_1', {}) call VerifyScreenDump(buf, 'Test_tselect_1', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xtags')
call delete('Xtest.c')
call delete('XTest_tselect')
endfunc endfunc
func Test_tagline() func Test_tagline()
call writefile([ call writefile([
\ 'provision Xtest.py /^ def provision(self, **kwargs):$/;" m line:1 language:Python class:Foo', \ 'provision Xtest.py /^ def provision(self, **kwargs):$/;" m line:1 language:Python class:Foo',
\ 'provision Xtest.py /^ def provision(self, **kwargs):$/;" m line:3 language:Python class:Bar', \ 'provision Xtest.py /^ def provision(self, **kwargs):$/;" m line:3 language:Python class:Bar',
\], 'Xtags') \], 'Xtags', 'D')
call writefile([ call writefile([
\ ' def provision(self, **kwargs):', \ ' def provision(self, **kwargs):',
\ ' pass', \ ' pass',
\ ' def provision(self, **kwargs):', \ ' def provision(self, **kwargs):',
\ ' pass', \ ' pass',
\], 'Xtest.py') \], 'Xtest.py', 'D')
set tags=Xtags set tags=Xtags
@@ -706,14 +671,12 @@ func Test_tagline()
2tag provision 2tag provision
call assert_equal(line('.'), 3) call assert_equal(line('.'), 3)
call delete('Xtags')
call delete('Xtest.py')
set tags& set tags&
endfunc endfunc
" Test for expanding environment variable in a tag file name " Test for expanding environment variable in a tag file name
func Test_tag_envvar() func Test_tag_envvar()
call writefile(["Func1\t$FOO\t/^Func1/"], 'Xtags') call writefile(["Func1\t$FOO\t/^Func1/"], 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let $FOO='TagTestEnv' let $FOO='TagTestEnv'
@@ -728,7 +691,6 @@ func Test_tag_envvar()
call assert_true(caught_exception) call assert_true(caught_exception)
set tags& set tags&
call delete('Xtags')
unlet $FOO unlet $FOO
endfunc endfunc
@@ -737,9 +699,9 @@ func Test_tag_preview()
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
\ "second\tXtpfile1\t2", \ "second\tXtpfile1\t2",
\ "third\tXtpfile1\t3",], \ "third\tXtpfile1\t3",],
\ 'Xtags') \ 'Xtags', 'D')
set tags=Xtags set tags=Xtags
call writefile(['first', 'second', 'third'], 'Xtpfile1') call writefile(['first', 'second', 'third'], 'Xtpfile1', 'D')
enew | only enew | only
ptag third ptag third
@@ -766,8 +728,6 @@ func Test_tag_preview()
pclose pclose
call assert_equal(1, winnr('$')) call assert_equal(1, winnr('$'))
call delete('Xtpfile1')
call delete('Xtags')
set tags& set tags&
endfunc endfunc
@@ -778,7 +738,7 @@ func Test_tag_guess()
\ "func2\tXfoo\t/^int func2(int y)/", \ "func2\tXfoo\t/^int func2(int y)/",
\ "func3\tXfoo\t/^func3/", \ "func3\tXfoo\t/^func3/",
\ "func4\tXfoo\t/^func4/"], \ "func4\tXfoo\t/^func4/"],
\ 'Xtags') \ 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let code =<< trim [CODE] let code =<< trim [CODE]
@@ -788,7 +748,7 @@ func Test_tag_guess()
int * func3 () { } int * func3 () { }
[CODE] [CODE]
call writefile(code, 'Xfoo') call writefile(code, 'Xfoo', 'D')
let v:statusmsg = '' let v:statusmsg = ''
ta func1 ta func1
@@ -804,8 +764,6 @@ func Test_tag_guess()
call assert_equal(5, line('.')) call assert_equal(5, line('.'))
call assert_fails('ta func4', 'E434:') call assert_fails('ta func4', 'E434:')
call delete('Xtags')
call delete('Xfoo')
set tags& set tags&
endfunc endfunc
@@ -815,26 +773,23 @@ func Test_tag_sort()
\ "first\tXfoo\t1", \ "first\tXfoo\t1",
\ "ten\tXfoo\t3", \ "ten\tXfoo\t3",
\ "six\tXfoo\t2"] \ "six\tXfoo\t2"]
call writefile(l, 'Xtags') call writefile(l, 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let code =<< trim [CODE] let code =<< trim [CODE]
int first() {} int first() {}
int six() {} int six() {}
int ten() {} int ten() {}
[CODE] [CODE]
call writefile(code, 'Xfoo') call writefile(code, 'Xfoo', 'D')
call assert_fails('tag first', 'E432:') call assert_fails('tag first', 'E432:')
" When multiple tag files are not sorted, then message should be displayed " When multiple tag files are not sorted, then message should be displayed
" multiple times " multiple times
call writefile(l, 'Xtags2') call writefile(l, 'Xtags2', 'D')
set tags=Xtags,Xtags2 set tags=Xtags,Xtags2
call assert_fails('tag first', ['E432:', 'E432:']) call assert_fails('tag first', ['E432:', 'E432:'])
call delete('Xtags')
call delete('Xtags2')
call delete('Xfoo')
set tags& set tags&
%bwipe %bwipe
endfunc endfunc
@@ -847,22 +802,20 @@ func Test_tag_fold()
\ "first\tXfoo\t1", \ "first\tXfoo\t1",
\ "second\tXfoo\t2", \ "second\tXfoo\t2",
\ "third\tXfoo\t3"], \ "third\tXfoo\t3"],
\ 'Xtags') \ 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let code =<< trim [CODE] let code =<< trim [CODE]
int first() {} int first() {}
int second() {} int second() {}
int third() {} int third() {}
[CODE] [CODE]
call writefile(code, 'Xfoo') call writefile(code, 'Xfoo', 'D')
enew enew
tag second tag second
call assert_equal('Xfoo', bufname('')) call assert_equal('Xfoo', bufname(''))
call assert_equal(2, line('.')) call assert_equal(2, line('.'))
call delete('Xtags')
call delete('Xfoo')
set tags& set tags&
%bwipe %bwipe
endfunc endfunc
@@ -874,14 +827,14 @@ func Test_ltag()
\ "first\tXfoo\t1", \ "first\tXfoo\t1",
\ "second\tXfoo\t/^int second() {}$/", \ "second\tXfoo\t/^int second() {}$/",
\ "third\tXfoo\t3"], \ "third\tXfoo\t3"],
\ 'Xtags') \ 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let code =<< trim [CODE] let code =<< trim [CODE]
int first() {} int first() {}
int second() {} int second() {}
int third() {} int third() {}
[CODE] [CODE]
call writefile(code, 'Xfoo') call writefile(code, 'Xfoo', 'D')
enew enew
call setloclist(0, [], 'f') call setloclist(0, [], 'f')
@@ -899,8 +852,6 @@ func Test_ltag()
\ 'valid': 1, 'vcol': 0, 'nr': 0, 'type': '', 'module': '', \ 'valid': 1, 'vcol': 0, 'nr': 0, 'type': '', 'module': '',
\ 'text': 'second'}], getloclist(0)) \ 'text': 'second'}], getloclist(0))
call delete('Xtags')
call delete('Xfoo')
set tags& set tags&
%bwipe %bwipe
endfunc endfunc
@@ -913,14 +864,14 @@ func Test_tag_last_search_pat()
\ "first\tXfoo\t/^int first() {}/", \ "first\tXfoo\t/^int first() {}/",
\ "second\tXfoo\t/^int second() {}/", \ "second\tXfoo\t/^int second() {}/",
\ "third\tXfoo\t/^int third() {}/"], \ "third\tXfoo\t/^int third() {}/"],
\ 'Xtags') \ 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let code =<< trim [CODE] let code =<< trim [CODE]
int first() {} int first() {}
int second() {} int second() {}
int third() {} int third() {}
[CODE] [CODE]
call writefile(code, 'Xfoo') call writefile(code, 'Xfoo', 'D')
enew enew
let save_cpo = &cpo let save_cpo = &cpo
@@ -930,8 +881,6 @@ func Test_tag_last_search_pat()
call assert_equal('^int second() {}', @/) call assert_equal('^int second() {}', @/)
let &cpo = save_cpo let &cpo = save_cpo
call delete('Xtags')
call delete('Xfoo')
set tags& set tags&
%bwipe %bwipe
endfunc endfunc
@@ -942,14 +891,14 @@ func Test_tag_stack()
for i in range(10, 31) for i in range(10, 31)
let l += ["var" .. i .. "\tXfoo\t/^int var" .. i .. ";$/"] let l += ["var" .. i .. "\tXfoo\t/^int var" .. i .. ";$/"]
endfor endfor
call writefile(l, 'Xtags') call writefile(l, 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let l = [] let l = []
for i in range(10, 31) for i in range(10, 31)
let l += ["int var" .. i .. ";"] let l += ["int var" .. i .. ";"]
endfor endfor
call writefile(l, 'Xfoo') call writefile(l, 'Xfoo', 'D')
" Jump to a tag when the tag stack is full. Oldest entry should be removed. " Jump to a tag when the tag stack is full. Oldest entry should be removed.
enew enew
@@ -994,8 +943,6 @@ func Test_tag_stack()
call settagstack(1, {'items' : []}) call settagstack(1, {'items' : []})
call assert_fails('pop', 'E73:') call assert_fails('pop', 'E73:')
call delete('Xtags')
call delete('Xfoo')
set tags& set tags&
%bwipe %bwipe
endfunc endfunc
@@ -1007,14 +954,14 @@ func Test_tag_multimatch()
\ "first\tXfoo\t1", \ "first\tXfoo\t1",
\ "first\tXfoo\t2", \ "first\tXfoo\t2",
\ "first\tXfoo\t3"], \ "first\tXfoo\t3"],
\ 'Xtags') \ 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let code =<< trim [CODE] let code =<< trim [CODE]
int first() {} int first() {}
int first() {} int first() {}
int first() {} int first() {}
[CODE] [CODE]
call writefile(code, 'Xfoo') call writefile(code, 'Xfoo', 'D')
call settagstack(1, {'items' : []}) call settagstack(1, {'items' : []})
tag first tag first
@@ -1041,8 +988,6 @@ func Test_tag_multimatch()
call assert_equal(1, line('.')) call assert_equal(1, line('.'))
set ignorecase& set ignorecase&
call delete('Xtags')
call delete('Xfoo')
set tags& set tags&
%bwipe %bwipe
endfunc endfunc
@@ -1054,14 +999,14 @@ func Test_preview_tag_multimatch()
\ "first\tXfoo\t1", \ "first\tXfoo\t1",
\ "first\tXfoo\t2", \ "first\tXfoo\t2",
\ "first\tXfoo\t3"], \ "first\tXfoo\t3"],
\ 'Xtags') \ 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let code =<< trim [CODE] let code =<< trim [CODE]
int first() {} int first() {}
int first() {} int first() {}
int first() {} int first() {}
[CODE] [CODE]
call writefile(code, 'Xfoo') call writefile(code, 'Xfoo', 'D')
enew | only enew | only
ptag first ptag first
@@ -1091,8 +1036,6 @@ func Test_preview_tag_multimatch()
pclose pclose
call delete('Xtags')
call delete('Xfoo')
set tags& set tags&
%bwipe %bwipe
endfunc endfunc
@@ -1104,14 +1047,14 @@ func Test_tnext_multimatch()
\ "first\tXfoo1\t1", \ "first\tXfoo1\t1",
\ "first\tXfoo2\t1", \ "first\tXfoo2\t1",
\ "first\tXfoo3\t1"], \ "first\tXfoo3\t1"],
\ 'Xtags') \ 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let code =<< trim [CODE] let code =<< trim [CODE]
int first() {} int first() {}
[CODE] [CODE]
call writefile(code, 'Xfoo1') call writefile(code, 'Xfoo1', 'D')
call writefile(code, 'Xfoo2') call writefile(code, 'Xfoo2', 'D')
call writefile(code, 'Xfoo3') call writefile(code, 'Xfoo3', 'D')
tag first tag first
tag first tag first
@@ -1120,10 +1063,6 @@ func Test_tnext_multimatch()
tnext tnext
call assert_fails('tnext', 'E428:') call assert_fails('tnext', 'E428:')
call delete('Xtags')
call delete('Xfoo1')
call delete('Xfoo2')
call delete('Xfoo3')
set tags& set tags&
%bwipe %bwipe
endfunc endfunc
@@ -1135,14 +1074,13 @@ func Test_multimatch_non_existing_files()
\ "first\tXfoo1\t1", \ "first\tXfoo1\t1",
\ "first\tXfoo2\t1", \ "first\tXfoo2\t1",
\ "first\tXfoo3\t1"], \ "first\tXfoo3\t1"],
\ 'Xtags') \ 'Xtags', 'D')
set tags=Xtags set tags=Xtags
call settagstack(1, {'items' : []}) call settagstack(1, {'items' : []})
call assert_fails('tag first', 'E429:') call assert_fails('tag first', 'E429:')
call assert_equal(3, gettagstack().items[0].matchnr) call assert_equal(3, gettagstack().items[0].matchnr)
call delete('Xtags')
set tags& set tags&
%bwipe %bwipe
endfunc endfunc
@@ -1152,14 +1090,14 @@ func Test_tselect_listing()
\ "!_TAG_FILE_ENCODING\tutf-8\t//", \ "!_TAG_FILE_ENCODING\tutf-8\t//",
\ "first\tXfoo\t1" .. ';"' .. "\tv\ttyperef:typename:int\tfile:", \ "first\tXfoo\t1" .. ';"' .. "\tv\ttyperef:typename:int\tfile:",
\ "first\tXfoo\t2" .. ';"' .. "\tkind:v\ttyperef:typename:char\tfile:"], \ "first\tXfoo\t2" .. ';"' .. "\tkind:v\ttyperef:typename:char\tfile:"],
\ 'Xtags') \ 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let code =<< trim [CODE] let code =<< trim [CODE]
static int first; static int first;
static char first; static char first;
[CODE] [CODE]
call writefile(code, 'Xfoo') call writefile(code, 'Xfoo', 'D')
call feedkeys("\<CR>", "t") call feedkeys("\<CR>", "t")
let l = split(execute("tselect first"), "\n") let l = split(execute("tselect first"), "\n")
@@ -1175,8 +1113,6 @@ Type number and <Enter> (q or empty cancels):
[DATA] [DATA]
call assert_equal(expected, l) call assert_equal(expected, l)
call delete('Xtags')
call delete('Xfoo')
set tags& set tags&
%bwipe %bwipe
endfunc endfunc
@@ -1454,9 +1390,9 @@ func Test_tag_length()
set tags=Xtags set tags=Xtags
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
\ "tame\tXtlfile1\t1;", \ "tame\tXtlfile1\t1;",
\ "tape\tXtlfile2\t1;"], 'Xtags') \ "tape\tXtlfile2\t1;"], 'Xtags', 'D')
call writefile(['tame'], 'Xtlfile1') call writefile(['tame'], 'Xtlfile1', 'D')
call writefile(['tape'], 'Xtlfile2') call writefile(['tape'], 'Xtlfile2', 'D')
" Jumping to the tag 'tape', should instead jump to 'tame' " Jumping to the tag 'tape', should instead jump to 'tame'
new new
@@ -1468,9 +1404,6 @@ func Test_tag_length()
tag /^tape$ tag /^tape$
call assert_equal('Xtlfile2', @%) call assert_equal('Xtlfile2', @%)
call delete('Xtags')
call delete('Xtlfile1')
call delete('Xtlfile2')
set tags& taglength& set tags& taglength&
endfunc endfunc
@@ -1480,8 +1413,8 @@ func Test_tagfile_errors()
" missing search pattern or line number for a tag " missing search pattern or line number for a tag
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
\ "foo\tXfile\t"], 'Xtags', 'b') \ "foo\tXfile\t"], 'Xtags', 'bD')
call writefile(['foo'], 'Xfile') call writefile(['foo'], 'Xfile', 'D')
enew enew
tag foo tag foo
@@ -1504,8 +1437,6 @@ func Test_tagfile_errors()
\ "foo\tXfile 1;"], 'Xtags') \ "foo\tXfile 1;"], 'Xtags')
call assert_fails('tag foo', 'E431:') call assert_fails('tag foo', 'E431:')
call delete('Xtags')
call delete('Xfile')
set tags& set tags&
endfunc endfunc
@@ -1514,9 +1445,9 @@ func Test_stag_close_window_on_error()
new | only new | only
set tags=Xtags set tags=Xtags
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
\ "foo\tXfile\t1"], 'Xtags') \ "foo\tXfile\t1"], 'Xtags', 'D')
call writefile(['foo'], 'Xfile') call writefile(['foo'], 'Xfile', 'D')
call writefile([], '.Xfile.swp') call writefile([], '.Xfile.swp', 'D')
" Remove the catch-all that runtest.vim adds " Remove the catch-all that runtest.vim adds
au! SwapExists au! SwapExists
augroup StagTest augroup StagTest
@@ -1531,8 +1462,6 @@ func Test_stag_close_window_on_error()
augroup StagTest augroup StagTest
au! au!
augroup END augroup END
call delete('Xfile')
call delete('.Xfile.swp')
set tags& set tags&
endfunc endfunc
@@ -1546,14 +1475,14 @@ func Test_tagbsearch()
\ "third\tXfoo\t3", \ "third\tXfoo\t3",
\ "second\tXfoo\t2", \ "second\tXfoo\t2",
\ "first\tXfoo\t1"], \ "first\tXfoo\t1"],
\ 'Xtags') \ 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let code =<< trim [CODE] let code =<< trim [CODE]
int first() {} int first() {}
int second() {} int second() {}
int third() {} int third() {}
[CODE] [CODE]
call writefile(code, 'Xfoo') call writefile(code, 'Xfoo', 'D')
enew enew
set tagbsearch set tagbsearch
@@ -1613,8 +1542,6 @@ func Test_tagbsearch()
\ 'Xtags') \ 'Xtags')
call assert_fails('tag bbb', 'E426:') call assert_fails('tag bbb', 'E426:')
call delete('Xtags')
call delete('Xfoo')
set tags& tagbsearch& set tags& tagbsearch&
endfunc endfunc

View File

@@ -12,7 +12,7 @@ func Test_taglist()
\ "Kindly\tXbar\t3;\"\tv\tfile:", \ "Kindly\tXbar\t3;\"\tv\tfile:",
\ "Lambda\tXbar\t3;\"\tλ\tfile:", \ "Lambda\tXbar\t3;\"\tλ\tfile:",
\ "Command\tXbar\tcall cursor(3, 4)|;\"\td", \ "Command\tXbar\tcall cursor(3, 4)|;\"\td",
\ ], 'Xtags') \ ], 'Xtags', 'D')
set tags=Xtags set tags=Xtags
split Xtext split Xtext
@@ -40,12 +40,11 @@ func Test_taglist()
" Use characters with value > 127 in the tag extra field. " Use characters with value > 127 in the tag extra field.
call writefile([ call writefile([
\ "vFoo\tXfoo\t4" .. ';"' .. "\ttypename:int\ta£££\tv", \ "vFoo\tXfoo\t4" .. ';"' .. "\ttypename:int\ta£££\tv",
\ ], 'Xtags') \ ], 'Xtags', 'D')
call assert_equal('v', taglist('vFoo')[0].kind) call assert_equal('v', taglist('vFoo')[0].kind)
call assert_fails("let l=taglist([])", 'E730:') call assert_fails("let l=taglist([])", 'E730:')
call delete('Xtags')
set tags& set tags&
bwipe bwipe
endfunc endfunc
@@ -58,14 +57,13 @@ func Test_taglist_native_etags()
\ "src/os_unix.c,13491", \ "src/os_unix.c,13491",
\ "set_signals(\x7f1335,32699", \ "set_signals(\x7f1335,32699",
\ "reset_signals(\x7f1407,34136", \ "reset_signals(\x7f1407,34136",
\ ], 'Xtags') \ ], 'Xtags', 'D')
set tags=Xtags set tags=Xtags
call assert_equal([['set_signals', '1335,32699'], ['reset_signals', '1407,34136']], call assert_equal([['set_signals', '1335,32699'], ['reset_signals', '1407,34136']],
\ map(taglist('set_signals'), {i, v -> [v.name, v.cmd]})) \ map(taglist('set_signals'), {i, v -> [v.name, v.cmd]}))
call delete('Xtags')
set tags& set tags&
endfunc endfunc
@@ -77,14 +75,13 @@ func Test_taglist_ctags_etags()
\ "src/os_unix.c,13491", \ "src/os_unix.c,13491",
\ "set_signals(void)\x7fset_signals\x011335,32699", \ "set_signals(void)\x7fset_signals\x011335,32699",
\ "reset_signals(void)\x7freset_signals\x011407,34136", \ "reset_signals(void)\x7freset_signals\x011407,34136",
\ ], 'Xtags') \ ], 'Xtags', 'D')
set tags=Xtags set tags=Xtags
call assert_equal([['set_signals', '1335,32699'], ['reset_signals', '1407,34136']], call assert_equal([['set_signals', '1335,32699'], ['reset_signals', '1407,34136']],
\ map(taglist('set_signals'), {i, v -> [v.name, v.cmd]})) \ map(taglist('set_signals'), {i, v -> [v.name, v.cmd]}))
call delete('Xtags')
set tags& set tags&
endfunc endfunc
@@ -96,8 +93,8 @@ endfunc
func Test_tagfiles() func Test_tagfiles()
call assert_equal([], tagfiles()) call assert_equal([], tagfiles())
call writefile(["FFoo\tXfoo\t1"], 'Xtags1') call writefile(["FFoo\tXfoo\t1"], 'Xtags1', 'D')
call writefile(["FBar\tXbar\t1"], 'Xtags2') call writefile(["FBar\tXbar\t1"], 'Xtags2', 'D')
set tags=Xtags1,Xtags2 set tags=Xtags1,Xtags2
call assert_equal(['Xtags1', 'Xtags2'], tagfiles()) call assert_equal(['Xtags1', 'Xtags2'], tagfiles())
@@ -111,22 +108,19 @@ func Test_tagfiles()
set tags& set tags&
call assert_equal([], tagfiles()) call assert_equal([], tagfiles())
call delete('Xtags1')
call delete('Xtags2')
bd bd
endfunc endfunc
" For historical reasons we support a tags file where the last line is missing " For historical reasons we support a tags file where the last line is missing
" the newline. " the newline.
func Test_tagsfile_without_trailing_newline() func Test_tagsfile_without_trailing_newline()
call writefile(["Foo\tfoo\t1"], 'Xtags', 'b') call writefile(["Foo\tfoo\t1"], 'Xtags', 'bD')
set tags=Xtags set tags=Xtags
let tl = taglist('.*') let tl = taglist('.*')
call assert_equal(1, len(tl)) call assert_equal(1, len(tl))
call assert_equal('Foo', tl[0].name) call assert_equal('Foo', tl[0].name)
call delete('Xtags')
set tags& set tags&
endfunc endfunc
@@ -136,7 +130,7 @@ func Test_tagfile_ignore_comments()
\ "!_TAG_PROGRAM_NAME /Test tags generator/", \ "!_TAG_PROGRAM_NAME /Test tags generator/",
\ "FBar\tXfoo\t2" .. ';"' .. "\textrafield\tf", \ "FBar\tXfoo\t2" .. ';"' .. "\textrafield\tf",
\ "!_TAG_FILE_FORMAT 2 /extended format/", \ "!_TAG_FILE_FORMAT 2 /extended format/",
\ ], 'Xtags') \ ], 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let l = taglist('.*') let l = taglist('.*')
@@ -144,7 +138,6 @@ func Test_tagfile_ignore_comments()
call assert_equal('FBar', l[0].name) call assert_equal('FBar', l[0].name)
set tags& set tags&
call delete('Xtags')
endfunc endfunc
" Test for using an excmd in a tags file to position the cursor (instead of a " Test for using an excmd in a tags file to position the cursor (instead of a
@@ -152,7 +145,7 @@ endfunc
func Test_tagfile_excmd() func Test_tagfile_excmd()
call writefile([ call writefile([
\ "vFoo\tXfoo\tcall cursor(3, 4)" .. '|;"' .. "\tv", \ "vFoo\tXfoo\tcall cursor(3, 4)" .. '|;"' .. "\tv",
\ ], 'Xtags') \ ], 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let l = taglist('.*') let l = taglist('.*')
@@ -164,14 +157,13 @@ func Test_tagfile_excmd()
\ 'filename' : 'Xfoo'}], l) \ 'filename' : 'Xfoo'}], l)
set tags& set tags&
call delete('Xtags')
endfunc endfunc
" Test for duplicate fields in a tag in a tags file " Test for duplicate fields in a tag in a tags file
func Test_duplicate_field() func Test_duplicate_field()
call writefile([ call writefile([
\ "vFoo\tXfoo\t4" .. ';"' .. "\ttypename:int\ttypename:int\tv", \ "vFoo\tXfoo\t4" .. ';"' .. "\ttypename:int\ttypename:int\tv",
\ ], 'Xtags') \ ], 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let l = taglist('.*') let l = taglist('.*')
@@ -184,14 +176,13 @@ func Test_duplicate_field()
\ 'filename' : 'Xfoo'}], l) \ 'filename' : 'Xfoo'}], l)
set tags& set tags&
call delete('Xtags')
endfunc endfunc
" Test for tag address with ; " Test for tag address with ;
func Test_tag_addr_with_semicolon() func Test_tag_addr_with_semicolon()
call writefile([ call writefile([
\ "Func1\tXfoo\t6;/^Func1/" .. ';"' .. "\tf" \ "Func1\tXfoo\t6;/^Func1/" .. ';"' .. "\tf"
\ ], 'Xtags') \ ], 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let l = taglist('.*') let l = taglist('.*')
@@ -203,12 +194,11 @@ func Test_tag_addr_with_semicolon()
\ 'filename' : 'Xfoo'}], l) \ 'filename' : 'Xfoo'}], l)
set tags& set tags&
call delete('Xtags')
endfunc endfunc
" Test for format error in a tags file " Test for format error in a tags file
func Test_format_error() func Test_format_error()
call writefile(['vFoo-Xfoo-4'], 'Xtags') call writefile(['vFoo-Xfoo-4'], 'Xtags', 'D')
set tags=Xtags set tags=Xtags
let caught_exception = v:false let caught_exception = v:false
@@ -228,12 +218,11 @@ func Test_format_error()
call assert_fails("echo taglist('foo')", 'E431:') call assert_fails("echo taglist('foo')", 'E431:')
set tags& set tags&
call delete('Xtags')
endfunc endfunc
" Test for :tag command completion with 'wildoptions' set to 'tagfile' " Test for :tag command completion with 'wildoptions' set to 'tagfile'
func Test_tag_complete_wildoptions() func Test_tag_complete_wildoptions()
call writefile(["foo\ta.c\t10;\"\tf", "bar\tb.c\t20;\"\td"], 'Xtags') call writefile(["foo\ta.c\t10;\"\tf", "bar\tb.c\t20;\"\td"], 'Xtags', 'D')
set tags=Xtags set tags=Xtags
set wildoptions=tagfile set wildoptions=tagfile
@@ -242,7 +231,6 @@ func Test_tag_complete_wildoptions()
call assert_equal('"tag bar d b.c : foo f a.c', @:) call assert_equal('"tag bar d b.c : foo f a.c', @:)
call delete('Xtags')
set wildoptions& set wildoptions&
set tags& set tags&
endfunc endfunc
@@ -256,7 +244,7 @@ func Test_tag_complete_with_overlong_line()
inboundGovernor a 2;" kind:⊢ type:forall (muxMode :: MuxMode) socket peerAddr versionNumber m a b. (MonadAsync m, MonadCatch m, MonadEvaluate m, MonadThrow m, MonadThrow (STM m), MonadTime m, MonadTimer m, MonadMask m, Ord peerAddr, HasResponder muxMode ~ True) => Tracer m (RemoteTransitionTrace peerAddr) -> Tracer m (InboundGovernorTrace peerAddr) -> ServerControlChannel muxMode peerAddr ByteString m a b -> DiffTime -> MuxConnectionManager muxMode socket peerAddr versionNumber ByteString m a b -> StrictTVar m InboundGovernorObservableState -> m Void inboundGovernor a 2;" kind:⊢ type:forall (muxMode :: MuxMode) socket peerAddr versionNumber m a b. (MonadAsync m, MonadCatch m, MonadEvaluate m, MonadThrow m, MonadThrow (STM m), MonadTime m, MonadTimer m, MonadMask m, Ord peerAddr, HasResponder muxMode ~ True) => Tracer m (RemoteTransitionTrace peerAddr) -> Tracer m (InboundGovernorTrace peerAddr) -> ServerControlChannel muxMode peerAddr ByteString m a b -> DiffTime -> MuxConnectionManager muxMode socket peerAddr versionNumber ByteString m a b -> StrictTVar m InboundGovernorObservableState -> m Void
inboundGovernorCounters a 3;" kind:⊢ type:InboundGovernorState muxMode peerAddr m a b -> InboundGovernorCounters inboundGovernorCounters a 3;" kind:⊢ type:InboundGovernorState muxMode peerAddr m a b -> InboundGovernorCounters
END END
call writefile(tagslines, 'Xtags') call writefile(tagslines, 'Xtags', 'D')
set tags=Xtags set tags=Xtags
" try with binary search " try with binary search
@@ -269,7 +257,6 @@ func Test_tag_complete_with_overlong_line()
call assert_equal('"tag inboundGSV inboundGovernor inboundGovernorCounters', @:) call assert_equal('"tag inboundGSV inboundGovernor inboundGovernorCounters', @:)
set tagbsearch& set tagbsearch&
call delete('Xtags')
set tags& set tags&
endfunc endfunc

View File

@@ -684,25 +684,22 @@ endfunc
" Test :tclfile " Test :tclfile
func Test_tclfile() func Test_tclfile()
call delete('Xtcl_file') call delete('Xtcl_file')
call writefile(['set pi [format "%.2f" [expr acos(-1.0)]]'], 'Xtcl_file') call writefile(['set pi [format "%.2f" [expr acos(-1.0)]]'], 'Xtcl_file', 'D')
call setfperm('Xtcl_file', 'r-xr-xr-x') call setfperm('Xtcl_file', 'r-xr-xr-x')
tclfile Xtcl_file tclfile Xtcl_file
call assert_equal('3.14', TclEval('set pi')) call assert_equal('3.14', TclEval('set pi'))
tcl unset pi tcl unset pi
call delete('Xtcl_file')
endfunc endfunc
" Test :tclfile with syntax error in tcl script " Test :tclfile with syntax error in tcl script
func Test_tclfile_error() func Test_tclfile_error()
call delete('Xtcl_file') call delete('Xtcl_file')
call writefile(['xyz'], 'Xtcl_file') call writefile(['xyz'], 'Xtcl_file', 'D')
call setfperm('Xtcl_file', 'r-xr-xr-x') call setfperm('Xtcl_file', 'r-xr-xr-x')
call assert_fails('tclfile Xtcl_file', 'invalid command name "xyz"') call assert_fails('tclfile Xtcl_file', 'invalid command name "xyz"')
call delete('Xtcl_file')
endfunc endfunc
" Test exiting current Tcl interpreter and re-creating one. " Test exiting current Tcl interpreter and re-creating one.

View File

@@ -26,14 +26,13 @@ func Test_termencoding_euc_jp()
\ 'scriptencoding utf-8', \ 'scriptencoding utf-8',
\ 'exe "normal aE83: バッファを作成できないので、他のを使用します...\<Esc>"', \ 'exe "normal aE83: バッファを作成できないので、他のを使用します...\<Esc>"',
\ 'split Xeuc_jp.txt', \ 'split Xeuc_jp.txt',
\ ], 'XTest_tenc_euc_jp') \ ], 'XTest_tenc_euc_jp', 'D')
let buf = RunVimInTerminal('-S XTest_tenc_euc_jp', {'rows': 10}) let buf = RunVimInTerminal('-S XTest_tenc_euc_jp', {'rows': 10})
call VerifyScreenDump(buf, 'Test_tenc_euc_jp_01', {}) call VerifyScreenDump(buf, 'Test_tenc_euc_jp_01', {})
" clean up " clean up
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xeuc_jp.txt') call delete('Xeuc_jp.txt')
call delete('XTest_tenc_euc_jp')
endfunc endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -405,7 +405,7 @@ func Test_terminal_scrape_123()
endfunc endfunc
func Test_terminal_scrape_multibyte() func Test_terminal_scrape_multibyte()
call writefile(["léttまrs"], 'Xtext') call writefile(["léttまrs"], 'Xtext', 'D')
if has('win32') if has('win32')
" Run cmd with UTF-8 codepage to make the type command print the expected " Run cmd with UTF-8 codepage to make the type command print the expected
" multibyte characters. " multibyte characters.
@@ -436,7 +436,6 @@ func Test_terminal_scrape_multibyte()
call TermWait(buf) call TermWait(buf)
exe buf . 'bwipe' exe buf . 'bwipe'
call delete('Xtext')
endfunc endfunc
func Test_terminal_one_column() func Test_terminal_one_column()
@@ -455,7 +454,7 @@ func Test_terminal_one_column()
endfunc endfunc
func Test_terminal_scroll() func Test_terminal_scroll()
call writefile(range(1, 200), 'Xtext') call writefile(range(1, 200), 'Xtext', 'D')
if has('win32') if has('win32')
let cmd = 'cmd /c "type Xtext"' let cmd = 'cmd /c "type Xtext"'
else else
@@ -484,13 +483,12 @@ func Test_terminal_scroll()
call assert_equal('200', term_getline(buf, 200 - scrolled)) call assert_equal('200', term_getline(buf, 200 - scrolled))
exe buf . 'bwipe' exe buf . 'bwipe'
call delete('Xtext')
endfunc endfunc
func Test_terminal_scrollback() func Test_terminal_scrollback()
let buf = Run_shell_in_terminal({'term_rows': 15}) let buf = Run_shell_in_terminal({'term_rows': 15})
set termwinscroll=100 set termwinscroll=100
call writefile(range(150), 'Xtext') call writefile(range(150), 'Xtext', 'D')
if has('win32') if has('win32')
call term_sendkeys(buf, "type Xtext\<CR>") call term_sendkeys(buf, "type Xtext\<CR>")
else else
@@ -505,14 +503,13 @@ func Test_terminal_scrollback()
call StopShellInTerminal(buf) call StopShellInTerminal(buf)
exe buf . 'bwipe' exe buf . 'bwipe'
set termwinscroll& set termwinscroll&
call delete('Xtext')
endfunc endfunc
func Test_terminal_postponed_scrollback() func Test_terminal_postponed_scrollback()
" tail -f only works on Unix " tail -f only works on Unix
CheckUnix CheckUnix
call writefile(range(50), 'Xtext') call writefile(range(50), 'Xtext', 'D')
call writefile([ call writefile([
\ 'set shell=/bin/sh noruler', \ 'set shell=/bin/sh noruler',
\ 'terminal', \ 'terminal',
@@ -520,7 +517,7 @@ func Test_terminal_postponed_scrollback()
\ 'call feedkeys("tail -n 100 -f Xtext\<CR>", "xt")', \ 'call feedkeys("tail -n 100 -f Xtext\<CR>", "xt")',
\ 'sleep 100m', \ 'sleep 100m',
\ 'call feedkeys("\<C-W>N", "xt")', \ 'call feedkeys("\<C-W>N", "xt")',
\ ], 'XTest_postponed') \ ], 'XTest_postponed', 'D')
let buf = RunVimInTerminal('-S XTest_postponed', {}) let buf = RunVimInTerminal('-S XTest_postponed', {})
" Check that the Xtext lines are displayed and in Terminal-Normal mode " Check that the Xtext lines are displayed and in Terminal-Normal mode
call VerifyScreenDump(buf, 'Test_terminal_scrollback_1', {}) call VerifyScreenDump(buf, 'Test_terminal_scrollback_1', {})
@@ -547,8 +544,6 @@ func Test_terminal_postponed_scrollback()
echo type(tsk_ret) echo type(tsk_ret)
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XTest_postponed')
call delete('Xtext')
endfunc endfunc
" Run diff on two dumps with different size. " Run diff on two dumps with different size.
@@ -783,10 +778,9 @@ endfunc
func Test_terminal_cwd_failure() func Test_terminal_cwd_failure()
" Case 1: Provided directory is not actually a directory. Attempt to make " Case 1: Provided directory is not actually a directory. Attempt to make
" the file executable as well. " the file executable as well.
call writefile([], 'Xtcfile') call writefile([], 'Xtcfile', 'D')
call setfperm('Xtcfile', 'rwx------') call setfperm('Xtcfile', 'rwx------')
call assert_fails("call term_start(&shell, {'cwd': 'Xtcfile'})", 'E475:') call assert_fails("call term_start(&shell, {'cwd': 'Xtcfile'})", 'E475:')
call delete('Xtcfile')
" Case 2: Directory does not exist. " Case 2: Directory does not exist.
call assert_fails("call term_start(&shell, {'cwd': 'Xdir'})", 'E475:') call assert_fails("call term_start(&shell, {'cwd': 'Xdir'})", 'E475:')
@@ -989,14 +983,13 @@ func Test_terminal_special_chars()
" this file name only works on Unix " this file name only works on Unix
CheckUnix CheckUnix
call mkdir('Xdir with spaces') call mkdir('Xdir with spaces', 'R')
call writefile(['x'], 'Xdir with spaces/quoted"file') call writefile(['x'], 'Xdir with spaces/quoted"file')
term ls Xdir\ with\ spaces/quoted\"file term ls Xdir\ with\ spaces/quoted\"file
call WaitForAssert({-> assert_match('quoted"file', term_getline('', 1))}) call WaitForAssert({-> assert_match('quoted"file', term_getline('', 1))})
" make sure the job has finished " make sure the job has finished
call WaitForAssert({-> assert_match('finish', term_getstatus(bufnr()))}) call WaitForAssert({-> assert_match('finish', term_getstatus(bufnr()))})
call delete('Xdir with spaces', 'rf')
bwipe bwipe
endfunc endfunc
@@ -1040,14 +1033,13 @@ func Test_terminal_redir_file()
bwipe bwipe
if has('unix') if has('unix')
call writefile(['one line'], 'Xtrfile') call writefile(['one line'], 'Xtrfile', 'D')
let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xtrfile'}) let buf = term_start('cat', {'in_io': 'file', 'in_name': 'Xtrfile'})
call TermWait(buf) call TermWait(buf)
call WaitForAssert({-> assert_equal('one line', term_getline(buf, 1))}) call WaitForAssert({-> assert_equal('one line', term_getline(buf, 1))})
let g:job = term_getjob(buf) let g:job = term_getjob(buf)
call WaitForAssert({-> assert_equal('dead', job_status(g:job))}) call WaitForAssert({-> assert_equal('dead', job_status(g:job))})
bwipe bwipe
call delete('Xtrfile')
endif endif
endfunc endfunc
@@ -1279,7 +1271,7 @@ func Test_aa_terminal_focus_events()
au FocusLost * call setline(1, 'I am lost') | set nomod au FocusLost * call setline(1, 'I am lost') | set nomod
au FocusGained * call setline(1, 'I am back') | set nomod au FocusGained * call setline(1, 'I am back') | set nomod
END END
call writefile(lines, 'XtermFocus') call writefile(lines, 'XtermFocus', 'D')
let buf = RunVimInTerminal('-S XtermFocus', #{rows: 6}) let buf = RunVimInTerminal('-S XtermFocus', #{rows: 6})
" Send a focus event to ourselves, it should be forwarded to the terminal " Send a focus event to ourselves, it should be forwarded to the terminal
@@ -1297,7 +1289,6 @@ func Test_aa_terminal_focus_events()
call term_sendkeys(buf, "\<Esc>") call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XtermFocus')
let &term = save_term let &term = save_term
let &ttymouse = save_ttymouse let &ttymouse = save_ttymouse
endfunc endfunc
@@ -1399,7 +1390,7 @@ func Test_terminal_exit()
close close
call win_gotoid(termid) call win_gotoid(termid)
END END
call writefile(lines, 'XtermExit') call writefile(lines, 'XtermExit', 'D')
let buf = RunVimInTerminal('-S XtermExit', #{rows: 10}) let buf = RunVimInTerminal('-S XtermExit', #{rows: 10})
let job = term_getjob(buf) let job = term_getjob(buf)
call WaitForAssert({-> assert_equal("run", job_status(job))}) call WaitForAssert({-> assert_equal("run", job_status(job))})
@@ -1407,8 +1398,6 @@ func Test_terminal_exit()
" quit the shell, it will make Vim exit " quit the shell, it will make Vim exit
call term_sendkeys(buf, "exit\<CR>") call term_sendkeys(buf, "exit\<CR>")
call WaitForAssert({-> assert_equal("dead", job_status(job))}) call WaitForAssert({-> assert_equal("dead", job_status(job))})
call delete('XtermExit')
endfunc endfunc
func Test_terminal_open_autocmd() func Test_terminal_open_autocmd()
@@ -1455,7 +1444,7 @@ func Test_open_term_from_cmd()
set incsearch set incsearch
cnoremap <F3> <Cmd>call term_start(['/bin/sh', '-c', ':'])<CR> cnoremap <F3> <Cmd>call term_start(['/bin/sh', '-c', ':'])<CR>
END END
call writefile(lines, 'Xopenterm') call writefile(lines, 'Xopenterm', 'D')
let buf = RunVimInTerminal('-S Xopenterm', {}) let buf = RunVimInTerminal('-S Xopenterm', {})
" this opens a window, incsearch should not use the old cursor position " this opens a window, incsearch should not use the old cursor position
@@ -1465,18 +1454,17 @@ func Test_open_term_from_cmd()
call term_sendkeys(buf, ":q\<CR>") call term_sendkeys(buf, ":q\<CR>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xopenterm')
endfunc endfunc
func Test_combining_double_width() func Test_combining_double_width()
CheckUnix CheckUnix
CheckRunVimInTerminal CheckRunVimInTerminal
call writefile(["\xe3\x83\x9b\xe3\x82\x9a"], 'Xonedouble') call writefile(["\xe3\x83\x9b\xe3\x82\x9a"], 'Xonedouble', 'D')
let lines =<< trim END let lines =<< trim END
call term_start(['/bin/sh', '-c', 'cat Xonedouble']) call term_start(['/bin/sh', '-c', 'cat Xonedouble'])
END END
call writefile(lines, 'Xcombining') call writefile(lines, 'Xcombining', 'D')
let buf = RunVimInTerminal('-S Xcombining', #{rows: 9}) let buf = RunVimInTerminal('-S Xcombining', #{rows: 9})
" this opens a window, incsearch should not use the old cursor position " this opens a window, incsearch should not use the old cursor position
@@ -1484,8 +1472,6 @@ func Test_combining_double_width()
call term_sendkeys(buf, ":q\<CR>") call term_sendkeys(buf, ":q\<CR>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xonedouble')
call delete('Xcombining')
endfunc endfunc
func Test_terminal_popup_with_cmd() func Test_terminal_popup_with_cmd()
@@ -1531,7 +1517,7 @@ func Test_terminal_popup_two_windows()
call term_sendkeys(termbuf, "echo 'test'") call term_sendkeys(termbuf, "echo 'test'")
END END
call writefile(lines, 'XpopupScript') call writefile(lines, 'XpopupScript', 'D')
let buf = RunVimInTerminal('-S XpopupScript', {}) let buf = RunVimInTerminal('-S XpopupScript', {})
" typed text appears both in normal window and in popup " typed text appears both in normal window and in popup
@@ -1542,7 +1528,6 @@ func Test_terminal_popup_two_windows()
call TermWait(buf) call TermWait(buf)
call term_sendkeys(buf, ":q\<CR>") call term_sendkeys(buf, ":q\<CR>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XpopupScript')
endfunc endfunc
func Test_terminal_popup_insert_cmd() func Test_terminal_popup_insert_cmd()
@@ -1576,7 +1561,7 @@ func Test_terminal_dumpwrite_composing()
call assert_equal(1, winnr('$')) call assert_equal(1, winnr('$'))
let text = " a\u0300 e\u0302 o\u0308" let text = " a\u0300 e\u0302 o\u0308"
call writefile([text], 'Xcomposing') call writefile([text], 'Xcomposing', 'D')
let buf = RunVimInTerminal('--cmd "set encoding=utf-8" Xcomposing', {}) let buf = RunVimInTerminal('--cmd "set encoding=utf-8" Xcomposing', {})
call WaitForAssert({-> assert_match(text, term_getline(buf, 1))}) call WaitForAssert({-> assert_match(text, term_getline(buf, 1))})
eval 'Xdump'->term_dumpwrite(buf) eval 'Xdump'->term_dumpwrite(buf)
@@ -1584,7 +1569,6 @@ func Test_terminal_dumpwrite_composing()
call assert_match('|à| |ê| |ö', dumpline) call assert_match('|à| |ê| |ö', dumpline)
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xcomposing')
call delete('Xdump') call delete('Xdump')
let &encoding = save_enc let &encoding = save_enc
endfunc endfunc
@@ -1647,12 +1631,11 @@ func Test_terminal_dumpload_dump()
let lines =<< trim END let lines =<< trim END
call term_dumpload('dumps/Test_popupwin_22.dump', #{term_rows: 12}) call term_dumpload('dumps/Test_popupwin_22.dump', #{term_rows: 12})
END END
call writefile(lines, 'XtermDumpload') call writefile(lines, 'XtermDumpload', 'D')
let buf = RunVimInTerminal('-S XtermDumpload', #{rows: 15}) let buf = RunVimInTerminal('-S XtermDumpload', #{rows: 15})
call VerifyScreenDump(buf, 'Test_terminal_dumpload', {}) call VerifyScreenDump(buf, 'Test_terminal_dumpload', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XtermDumpload')
endfunc endfunc
func Test_terminal_dumpdiff() func Test_terminal_dumpdiff()
@@ -1667,9 +1650,8 @@ func Test_terminal_dumpdiff()
call assert_fails('call term_dumpdiff("X1.dump", [])', 'E730:') call assert_fails('call term_dumpdiff("X1.dump", [])', 'E730:')
call assert_fails('call term_dumpdiff("X1.dump", "X2.dump")', 'E485:') call assert_fails('call term_dumpdiff("X1.dump", "X2.dump")', 'E485:')
call writefile([], 'X1.dump') call writefile([], 'X1.dump', 'D')
call assert_fails('call term_dumpdiff("X1.dump", "X2.dump")', 'E485:') call assert_fails('call term_dumpdiff("X1.dump", "X2.dump")', 'E485:')
call delete('X1.dump')
endfunc endfunc
func Test_terminal_dumpdiff_swap() func Test_terminal_dumpdiff_swap()
@@ -1766,7 +1748,7 @@ func Test_start_terminal_from_timer()
CheckFeature timers CheckFeature timers
" Open a terminal window from a timer, typed text goes to the terminal " Open a terminal window from a timer, typed text goes to the terminal
call writefile(["call timer_start(100, { -> term_start('sh') })"], 'XtimerTerm') call writefile(["call timer_start(100, { -> term_start('sh') })"], 'XtimerTerm', 'D')
let buf = RunVimInTerminal('-S XtimerTerm', {}) let buf = RunVimInTerminal('-S XtimerTerm', {})
call CheckTerminalWindowWorks(buf) call CheckTerminalWindowWorks(buf)
@@ -1775,7 +1757,6 @@ func Test_start_terminal_from_timer()
call CheckTerminalWindowWorks(buf) call CheckTerminalWindowWorks(buf)
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XtimerTerm')
endfunc endfunc
func Test_terminal_window_focus() func Test_terminal_window_focus()
@@ -1923,13 +1904,12 @@ func Test_terminal_api_drop_oldwin()
\ 'let &titlestring = ''["drop","Xtextfile"]''', \ 'let &titlestring = ''["drop","Xtextfile"]''',
\ 'redraw', \ 'redraw',
\ "set t_ts=", \ "set t_ts=",
\ ], 'Xscript') \ ], 'Xscript', 'D')
let buf = RunVimInTerminal('-S Xscript', {'rows': 10}) let buf = RunVimInTerminal('-S Xscript', {'rows': 10})
call WaitForAssert({-> assert_equal('Xtextfile', expand('%:t'))}) call WaitForAssert({-> assert_equal('Xtextfile', expand('%:t'))})
call assert_equal(textfile_winid, win_getid()) call assert_equal(textfile_winid, win_getid())
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xscript')
bwipe Xtextfile bwipe Xtextfile
endfunc endfunc
@@ -2261,13 +2241,12 @@ func Test_terminal_all_ansi_colors()
\ 'call matchadd("TgreenBold", "Y")', \ 'call matchadd("TgreenBold", "Y")',
\ 'call matchadd("TmagentaBold", "Z")', \ 'call matchadd("TmagentaBold", "Z")',
\ 'redraw', \ 'redraw',
\ ], 'Xcolorscript') \ ], 'Xcolorscript', 'D')
let buf = RunVimInTerminal('-S Xcolorscript', {'rows': 10}) let buf = RunVimInTerminal('-S Xcolorscript', {'rows': 10})
call VerifyScreenDump(buf, 'Test_terminal_all_ansi_colors', {}) call VerifyScreenDump(buf, 'Test_terminal_all_ansi_colors', {})
call term_sendkeys(buf, ":q\<CR>") call term_sendkeys(buf, ":q\<CR>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xcolorscript')
endfunc endfunc
function On_BufFilePost() function On_BufFilePost()

View File

@@ -19,7 +19,7 @@ func Test_terminal_termwinsize_option_fixed()
for n in range(10) for n in range(10)
call add(text, repeat(n, 50)) call add(text, repeat(n, 50))
endfor endfor
call writefile(text, 'Xwinsize') call writefile(text, 'Xwinsize', 'D')
let buf = RunVimInTerminal('Xwinsize', {}) let buf = RunVimInTerminal('Xwinsize', {})
let win = bufwinid(buf) let win = bufwinid(buf)
call assert_equal([6, 40], term_getsize(buf)) call assert_equal([6, 40], term_getsize(buf))
@@ -34,7 +34,6 @@ func Test_terminal_termwinsize_option_fixed()
call assert_equal(60, winwidth(win)) call assert_equal(60, winwidth(win))
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xwinsize')
call assert_fails('set termwinsize=40', 'E474:') call assert_fails('set termwinsize=40', 'E474:')
call assert_fails('set termwinsize=10+40', 'E474:') call assert_fails('set termwinsize=10+40', 'E474:')
@@ -192,7 +191,7 @@ func Test_terminal_out_err()
\ '#!/bin/sh', \ '#!/bin/sh',
\ 'echo "this is standard error" >&2', \ 'echo "this is standard error" >&2',
\ 'echo "this is standard out" >&1', \ 'echo "this is standard out" >&1',
\ ], 'Xechoerrout.sh') \ ], 'Xechoerrout.sh', 'D')
call setfperm('Xechoerrout.sh', 'rwxrwx---') call setfperm('Xechoerrout.sh', 'rwxrwx---')
let outfile = 'Xtermstdout' let outfile = 'Xtermstdout'
@@ -204,7 +203,6 @@ func Test_terminal_out_err()
call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))}) call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
exe buf . 'bwipe' exe buf . 'bwipe'
call delete('Xechoerrout.sh')
call delete(outfile) call delete(outfile)
endfunc endfunc
@@ -290,36 +288,34 @@ func Test_zz1_terminal_in_gui()
unlet g:job unlet g:job
endfunc endfunc
" TODO: re-enable when this no longer hangs on Travis func Test_zz2_terminal_guioptions_bang()
"func Test_zz2_terminal_guioptions_bang() CheckGui
" CheckGui set guioptions+=!
" set guioptions+=!
" let filename = 'Xtestscript'
" let filename = 'Xtestscript' if has('win32')
" if has('win32') let filename .= '.bat'
" let filename .= '.bat' let prefix = ''
" let prefix = '' let contents = ['@echo off', 'exit %1']
" let contents = ['@echo off', 'exit %1'] else
" else let filename .= '.sh'
" let filename .= '.sh' let prefix = './'
" let prefix = './' let contents = ['#!/bin/sh', 'exit $1']
" let contents = ['#!/bin/sh', 'exit $1'] endif
" endif call writefile(contents, filename, 'D')
" call writefile(contents, filename) call setfperm(filename, 'rwxrwx---')
" call setfperm(filename, 'rwxrwx---')
" " Check if v:shell_error is equal to the exit status.
" " Check if v:shell_error is equal to the exit status. let exitval = 0
" let exitval = 0 execute printf(':!%s%s %d', prefix, filename, exitval)
" execute printf(':!%s%s %d', prefix, filename, exitval) call assert_equal(exitval, v:shell_error)
" call assert_equal(exitval, v:shell_error)
" let exitval = 9
" let exitval = 9 execute printf(':!%s%s %d', prefix, filename, exitval)
" execute printf(':!%s%s %d', prefix, filename, exitval) call assert_equal(exitval, v:shell_error)
" call assert_equal(exitval, v:shell_error)
" set guioptions&
" set guioptions& endfunc
" call delete(filename)
"endfunc
func Test_terminal_hidden() func Test_terminal_hidden()
CheckUnix CheckUnix
@@ -372,7 +368,7 @@ func Test_terminal_normal_mode()
call setline(1, range(11111, 11122)) call setline(1, range(11111, 11122))
3 3
END END
call writefile(lines, 'XtermNormal') call writefile(lines, 'XtermNormal', 'D')
let buf = RunVimInTerminal('-S XtermNormal', {'rows': 8}) let buf = RunVimInTerminal('-S XtermNormal', {'rows': 8})
call TermWait(buf) call TermWait(buf)
@@ -389,7 +385,6 @@ func Test_terminal_normal_mode()
call assert_fails('call term_sendkeys(buf, [])', 'E730:') call assert_fails('call term_sendkeys(buf, [])', 'E730:')
call term_sendkeys(buf, "a:q!\<CR>:q\<CR>:q\<CR>") call term_sendkeys(buf, "a:q!\<CR>:q\<CR>:q\<CR>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XtermNormal')
endfunc endfunc
func Test_terminal_hidden_and_close() func Test_terminal_hidden_and_close()
@@ -415,7 +410,7 @@ func Test_terminal_does_not_truncate_last_newlines()
\ ] \ ]
for c in contents for c in contents
call writefile(c, 'Xdntfile') call writefile(c, 'Xdntfile', 'D')
if has('win32') if has('win32')
term cmd /c type Xdntfile term cmd /c type Xdntfile
else else
@@ -428,8 +423,6 @@ func Test_terminal_does_not_truncate_last_newlines()
call assert_equal(c, getline(1, line('$'))) call assert_equal(c, getline(1, line('$')))
quit quit
endfor endfor
call delete('Xdntfile')
endfunc endfunc
func GetDummyCmd() func GetDummyCmd()

View File

@@ -18,7 +18,7 @@ func Test_terminal_altscreen()
let cmd = "cat Xtext\<CR>" let cmd = "cat Xtext\<CR>"
let buf = term_start(&shell, {}) let buf = term_start(&shell, {})
call writefile(["\<Esc>[?1047h"], 'Xtext') call writefile(["\<Esc>[?1047h"], 'Xtext', 'D')
call term_sendkeys(buf, cmd) call term_sendkeys(buf, cmd)
call WaitForAssert({-> assert_equal(1, term_getaltscreen(buf))}) call WaitForAssert({-> assert_equal(1, term_getaltscreen(buf))})
@@ -28,7 +28,6 @@ func Test_terminal_altscreen()
call term_sendkeys(buf, "exit\r") call term_sendkeys(buf, "exit\r")
exe buf . "bwipe!" exe buf . "bwipe!"
call delete('Xtext')
endfunc endfunc
func Test_terminal_shell_option() func Test_terminal_shell_option()
@@ -79,7 +78,7 @@ func Terminal_color(group_name, highlight_cmds, highlight_opt, open_cmds)
\ ] + a:open_cmds + [ \ ] + a:open_cmds + [
\ 'endfunc', \ 'endfunc',
\ ] + a:highlight_cmds \ ] + a:highlight_cmds
call writefile(lines, 'XtermStart') call writefile(lines, 'XtermStart', 'D')
let buf = RunVimInTerminal('-S XtermStart', #{rows: 15}) let buf = RunVimInTerminal('-S XtermStart', #{rows: 15})
call TermWait(buf, 100) call TermWait(buf, 100)
call term_sendkeys(buf, ":call OpenTerm()\<CR>") call term_sendkeys(buf, ":call OpenTerm()\<CR>")
@@ -90,7 +89,6 @@ func Terminal_color(group_name, highlight_cmds, highlight_opt, open_cmds)
call term_sendkeys(buf, "\<C-D>") call term_sendkeys(buf, "\<C-D>")
call TermWait(buf, 50) call TermWait(buf, 50)
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XtermStart')
endfunc endfunc
func Test_terminal_color_Terminal() func Test_terminal_color_Terminal()
@@ -143,7 +141,7 @@ func Test_terminal_color_wincolor_split()
\ 'highlight MyWinCol ctermfg=red ctermbg=darkyellow', \ 'highlight MyWinCol ctermfg=red ctermbg=darkyellow',
\ 'highlight MyWinCol2 ctermfg=black ctermbg=blue', \ 'highlight MyWinCol2 ctermfg=black ctermbg=blue',
\ ] \ ]
call writefile(lines, 'XtermStart') call writefile(lines, 'XtermStart', 'D')
let buf = RunVimInTerminal('-S XtermStart', #{rows: 15}) let buf = RunVimInTerminal('-S XtermStart', #{rows: 15})
call TermWait(buf, 100) call TermWait(buf, 100)
call term_sendkeys(buf, ":call OpenTerm()\<CR>") call term_sendkeys(buf, ":call OpenTerm()\<CR>")
@@ -162,7 +160,6 @@ func Test_terminal_color_wincolor_split()
call term_sendkeys(buf, "\<C-D>") call term_sendkeys(buf, "\<C-D>")
call TermWait(buf, 50) call TermWait(buf, 50)
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XtermStart')
endfunc endfunc
func Test_terminal_color_transp_Terminal() func Test_terminal_color_transp_Terminal()
@@ -245,7 +242,7 @@ func Test_terminal_in_popup()
to edit to edit
in a popup window in a popup window
END END
call writefile(text, 'Xtext') call writefile(text, 'Xtext', 'D')
let cmd = GetVimCommandCleanTerm() let cmd = GetVimCommandCleanTerm()
let lines = [ let lines = [
\ 'call setline(1, range(20))', \ 'call setline(1, range(20))',
@@ -268,7 +265,7 @@ func Test_terminal_in_popup()
\ ' call popup_create(s:buf, #{minwidth: 40, minheight: 6, border: []})', \ ' call popup_create(s:buf, #{minwidth: 40, minheight: 6, border: []})',
\ 'endfunc', \ 'endfunc',
\ ] \ ]
call writefile(lines, 'XtermPopup') call writefile(lines, 'XtermPopup', 'D')
let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15}) let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
call TermWait(buf, 100) call TermWait(buf, 100)
call term_sendkeys(buf, ":call OpenTerm(0)\<CR>") call term_sendkeys(buf, ":call OpenTerm(0)\<CR>")
@@ -312,8 +309,6 @@ func Test_terminal_in_popup()
call TermWait(buf, 250) " wait for terminal to vanish call TermWait(buf, 250) " wait for terminal to vanish
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xtext')
call delete('XtermPopup')
endfunc endfunc
" Check a terminal in popup window uses the default minimum size. " Check a terminal in popup window uses the default minimum size.
@@ -325,7 +320,7 @@ func Test_terminal_in_popup_min_size()
to show to show
in a popup window in a popup window
END END
call writefile(text, 'Xtext') call writefile(text, 'Xtext', 'D')
let lines = [ let lines = [
\ 'call setline(1, range(20))', \ 'call setline(1, range(20))',
\ 'func OpenTerm()', \ 'func OpenTerm()',
@@ -333,7 +328,7 @@ func Test_terminal_in_popup_min_size()
\ ' let g:winid = popup_create(s:buf, #{ border: []})', \ ' let g:winid = popup_create(s:buf, #{ border: []})',
\ 'endfunc', \ 'endfunc',
\ ] \ ]
call writefile(lines, 'XtermPopup') call writefile(lines, 'XtermPopup', 'D')
let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15}) let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
call TermWait(buf, 100) call TermWait(buf, 100)
call term_sendkeys(buf, ":set noruler\<CR>") call term_sendkeys(buf, ":set noruler\<CR>")
@@ -346,8 +341,6 @@ func Test_terminal_in_popup_min_size()
call term_sendkeys(buf, ":q\<CR>") call term_sendkeys(buf, ":q\<CR>")
call TermWait(buf, 50) " wait for terminal to vanish call TermWait(buf, 50) " wait for terminal to vanish
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xtext')
call delete('XtermPopup')
endfunc endfunc
" Check a terminal in popup window with different colors " Check a terminal in popup window with different colors
@@ -365,7 +358,7 @@ func Terminal_in_popup_color(group_name, highlight_cmds, highlight_opt, popup_cm
\ ] + a:popup_cmds + [ \ ] + a:popup_cmds + [
\ 'endfunc', \ 'endfunc',
\ ] + a:highlight_cmds \ ] + a:highlight_cmds
call writefile(lines, 'XtermPopup') call writefile(lines, 'XtermPopup', 'D')
let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15}) let buf = RunVimInTerminal('-S XtermPopup', #{rows: 15})
call TermWait(buf, 100) call TermWait(buf, 100)
call term_sendkeys(buf, ":set noruler\<CR>") call term_sendkeys(buf, ":set noruler\<CR>")
@@ -379,7 +372,6 @@ func Terminal_in_popup_color(group_name, highlight_cmds, highlight_opt, popup_cm
call term_sendkeys(buf, ":q\<CR>") call term_sendkeys(buf, ":q\<CR>")
call TermWait(buf, 50) " wait for terminal to vanish call TermWait(buf, 50) " wait for terminal to vanish
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XtermPopup')
endfunc endfunc
func Test_terminal_in_popup_color_Terminal() func Test_terminal_in_popup_color_Terminal()
@@ -582,7 +574,7 @@ func Test_term_and_startinsert()
term term
startinsert startinsert
EOL EOL
call writefile(lines, 'XTest_startinsert') call writefile(lines, 'XTest_startinsert', 'D')
let buf = RunVimInTerminal('-S XTest_startinsert', {}) let buf = RunVimInTerminal('-S XTest_startinsert', {})
call term_sendkeys(buf, "exit\r") call term_sendkeys(buf, "exit\r")
@@ -592,7 +584,6 @@ func Test_term_and_startinsert()
call WaitForAssert({-> assert_equal("some text<", term_getline(buf, 1))}) call WaitForAssert({-> assert_equal("some text<", term_getline(buf, 1))})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XTest_startinsert')
endfunc endfunc
" Test for passing invalid arguments to terminal functions " Test for passing invalid arguments to terminal functions
@@ -683,7 +674,7 @@ func Test_term_mouse()
red green yellow red blue red green yellow red blue
vim emacs sublime nano vim emacs sublime nano
END END
call writefile(lines, 'Xtest_mouse') call writefile(lines, 'Xtest_mouse', 'D')
" Create a terminal window running Vim for the test with mouse enabled " Create a terminal window running Vim for the test with mouse enabled
let prev_win = win_getid() let prev_win = win_getid()
@@ -783,7 +774,6 @@ func Test_term_mouse()
let &ttymouse = save_ttymouse let &ttymouse = save_ttymouse
let &clipboard = save_clipboard let &clipboard = save_clipboard
set mousetime& set mousetime&
call delete('Xtest_mouse')
call delete('Xbuf') call delete('Xbuf')
endfunc endfunc
@@ -836,7 +826,7 @@ func Test_term_modeless_selection()
red green yellow red blue red green yellow red blue
vim emacs sublime nano vim emacs sublime nano
END END
call writefile(lines, 'Xtest_modeless') call writefile(lines, 'Xtest_modeless', 'D')
" Create a terminal window running Vim for the test with mouse disabled " Create a terminal window running Vim for the test with mouse disabled
let prev_win = win_getid() let prev_win = win_getid()
@@ -869,7 +859,6 @@ func Test_term_modeless_selection()
let &term = save_term let &term = save_term
let &ttymouse = save_ttymouse let &ttymouse = save_ttymouse
set mousetime& clipboard& set mousetime& clipboard&
call delete('Xtest_modeless')
new | only! new | only!
endfunc endfunc

View File

@@ -371,12 +371,12 @@ func Test_timer_restore_count()
\ ' normal 3j', \ ' normal 3j',
\ 'endfunc', \ 'endfunc',
\ 'call timer_start(100, "Doit")', \ 'call timer_start(100, "Doit")',
\ ], 'Xtrcscript') \ ], 'Xtrcscript', 'D')
call writefile([ call writefile([
\ '1-1234', \ '1-1234',
\ '2-1234', \ '2-1234',
\ '3-1234', \ '3-1234',
\ ], 'Xtrctext') \ ], 'Xtrctext', 'D')
let buf = RunVimInTerminal('-S Xtrcscript Xtrctext', {}) let buf = RunVimInTerminal('-S Xtrcscript Xtrctext', {})
" Wait for the timer to move the cursor to the third line. " Wait for the timer to move the cursor to the third line.
@@ -387,8 +387,6 @@ func Test_timer_restore_count()
call WaitForAssert({-> assert_equal(2, term_getcursor(buf)[1])}) call WaitForAssert({-> assert_equal(2, term_getcursor(buf)[1])})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xtrcscript')
call delete('Xtrctext')
endfunc endfunc
" Test that the garbage collector isn't triggered if a timer callback invokes " Test that the garbage collector isn't triggered if a timer callback invokes
@@ -438,7 +436,7 @@ func Test_timer_error_in_timer_callback()
set updatetime=50 set updatetime=50
call timer_start(1, 'Func') call timer_start(1, 'Func')
[CODE] [CODE]
call writefile(lines, 'Xtest.vim') call writefile(lines, 'Xtest.vim', 'D')
let buf = term_start(GetVimCommandCleanTerm() .. ' -S Xtest.vim', {'term_rows': 8}) let buf = term_start(GetVimCommandCleanTerm() .. ' -S Xtest.vim', {'term_rows': 8})
let job = term_getjob(buf) let job = term_getjob(buf)
@@ -456,7 +454,6 @@ func Test_timer_error_in_timer_callback()
call assert_equal('', job_info(job).termsig) call assert_equal('', job_info(job).termsig)
endif endif
call delete('Xtest.vim')
exe buf .. 'bwipe!' exe buf .. 'bwipe!'
endfunc endfunc
@@ -485,7 +482,7 @@ func Test_timer_changing_function_list()
endfor endfor
au CmdlineLeave : call timer_start(0, {-> 0}) au CmdlineLeave : call timer_start(0, {-> 0})
END END
call writefile(lines, 'XTest_timerchange') call writefile(lines, 'XTest_timerchange', 'D')
let buf = RunVimInTerminal('-S XTest_timerchange', #{rows: 10}) let buf = RunVimInTerminal('-S XTest_timerchange', #{rows: 10})
call term_sendkeys(buf, ":fu\<CR>") call term_sendkeys(buf, ":fu\<CR>")
call WaitForAssert({-> assert_match('-- More --', term_getline(buf, 10))}) call WaitForAssert({-> assert_match('-- More --', term_getline(buf, 10))})
@@ -494,7 +491,6 @@ func Test_timer_changing_function_list()
call term_sendkeys(buf, "\<Esc>") call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XTest_timerchange')
endfunc endfunc
func Test_timer_outputting_message() func Test_timer_outputting_message()
@@ -508,7 +504,7 @@ func Test_timer_outputting_message()
echon repeat('x', &columns - 11) echon repeat('x', &columns - 11)
}) })
END END
call writefile(lines, 'XTest_timermessage') call writefile(lines, 'XTest_timermessage', 'D')
let buf = RunVimInTerminal('-S XTest_timermessage', #{rows: 6}) let buf = RunVimInTerminal('-S XTest_timermessage', #{rows: 6})
call term_sendkeys(buf, "l") call term_sendkeys(buf, "l")
call term_wait(buf) call term_wait(buf)
@@ -516,7 +512,6 @@ func Test_timer_outputting_message()
call WaitForAssert({-> assert_match('xxxxxxxxxxx', term_getline(buf, 6))}) call WaitForAssert({-> assert_match('xxxxxxxxxxx', term_getline(buf, 6))})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XTest_timermessage')
endfunc endfunc
func Test_timer_using_win_execute_undo_sync() func Test_timer_using_win_execute_undo_sync()

View File

@@ -1975,7 +1975,7 @@ func Test_builtin_func_error()
endfunc endfunc
func Test_reload_in_try_catch() func Test_reload_in_try_catch()
call writefile(['x'], 'Xreload') call writefile(['x'], 'Xreload', 'D')
set autoread set autoread
edit Xreload edit Xreload
tabnew tabnew
@@ -1995,7 +1995,6 @@ func Test_reload_in_try_catch()
autocmd! ReLoad autocmd! ReLoad
set noautoread set noautoread
bwipe! Xreload bwipe! Xreload
call delete('Xreload')
endfunc endfunc
" Test for errors with :catch, :throw, :finally {{{1 " Test for errors with :catch, :throw, :finally {{{1
@@ -2306,10 +2305,8 @@ func Test_user_command_function_call_with_endtry()
call s:main() call s:main()
call assert_equal('yes', s:caught) call assert_equal('yes', s:caught)
END END
call writefile(lines, 'XtestThrow') call writefile(lines, 'XtestThrow', 'D')
source XtestThrow source XtestThrow
call delete('XtestThrow')
endfunc endfunc
func ThisWillFail() func ThisWillFail()
@@ -2325,13 +2322,11 @@ func Test_error_in_catch_and_finally()
for l in [] for l in []
finally finally
END END
call writefile(lines, 'XtestCatchAndFinally') call writefile(lines, 'XtestCatchAndFinally', 'D')
try try
source XtestCatchAndFinally source XtestCatchAndFinally
catch /E600:/ catch /E600:/
endtry endtry
call delete('XtestCatchAndFinally')
endfunc endfunc
" This was causing an illegal memory access " This was causing an illegal memory access
@@ -2345,13 +2340,11 @@ func Test_leave_block_in_endtry_not_called()
if if
endtry endtry
END END
call writefile(lines, 'XtestEndtry') call writefile(lines, 'XtestEndtry', 'D')
try try
source XtestEndtry source XtestEndtry
catch /E171:/ catch /E171:/
endtry endtry
call delete('XtestEndtry')
endfunc endfunc
" Modeline {{{1 " Modeline {{{1

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
767,
/**/ /**/
766, 766,
/**/ /**/