Merge pull request #24833 from zeertzjq/vim-9.0.0391

vim-patch:9.0.{0380,0391,0415,0425,0428,0837}
This commit is contained in:
zeertzjq
2023-08-22 19:10:14 +08:00
committed by GitHub
16 changed files with 174 additions and 185 deletions

View File

@@ -73,7 +73,8 @@ append({lnum}, {text}) *append()*
{lnum} can be zero to insert a line before the first one. {lnum} can be zero to insert a line before the first one.
{lnum} is used like with |getline()|. {lnum} is used like with |getline()|.
Returns 1 for failure ({lnum} out of range or out of memory), Returns 1 for failure ({lnum} out of range or out of memory),
0 for success. Example: >vim 0 for success. When {text} is an empty list zero is returned,
no matter the value of {lnum}. Example: >vim
let failed = append(line('$'), "# THE END") let failed = append(line('$'), "# THE END")
let failed = append(0, ["Chapter 1", "the beginning"]) let failed = append(0, ["Chapter 1", "the beginning"])
< <
@@ -96,7 +97,8 @@ appendbufline({buf}, {lnum}, {text}) *appendbufline()*
If {buf} is not a valid buffer or {lnum} is not valid, an If {buf} is not a valid buffer or {lnum} is not valid, an
error message is given. Example: >vim error message is given. Example: >vim
let failed = appendbufline(13, 0, "# THE START") let failed = appendbufline(13, 0, "# THE START")
< < However, when {text} is an empty list then no error is given
for an invalid {lnum}, since {lnum} isn't actually used.
argc([{winid}]) *argc()* argc([{winid}]) *argc()*
The result is the number of files in the argument list. See The result is the number of files in the argument list. See
@@ -6213,9 +6215,10 @@ setbufline({buf}, {lnum}, {text}) *setbufline()*
To insert lines use |appendbufline()|. To insert lines use |appendbufline()|.
{text} can be a string to set one line, or a list of strings {text} can be a string to set one line, or a List of strings
to set multiple lines. If the list extends below the last to set multiple lines. If the List extends below the last
line then those lines are added. line then those lines are added. If the List is empty then
nothing is changed and zero is returned.
For the use of {buf}, see |bufname()| above. For the use of {buf}, see |bufname()| above.
@@ -6374,7 +6377,8 @@ setline({lnum}, {text}) *setline()*
When {lnum} is just below the last line the {text} will be When {lnum} is just below the last line the {text} will be
added below the last line. added below the last line.
{text} can be any type or a List of any type, each item is {text} can be any type or a List of any type, each item is
converted to a String. converted to a String. When {text} is an empty List then
nothing is changed and FALSE is returned.
If this succeeds, FALSE is returned. If this fails (most likely If this succeeds, FALSE is returned. If this fails (most likely
because {lnum} is invalid) TRUE is returned. because {lnum} is invalid) TRUE is returned.

View File

@@ -79,7 +79,8 @@ function vim.fn.api_info() end
--- {lnum} can be zero to insert a line before the first one. --- {lnum} can be zero to insert a line before the first one.
--- {lnum} is used like with |getline()|. --- {lnum} is used like with |getline()|.
--- Returns 1 for failure ({lnum} out of range or out of memory), --- Returns 1 for failure ({lnum} out of range or out of memory),
--- 0 for success. Example: >vim --- 0 for success. When {text} is an empty list zero is returned,
--- no matter the value of {lnum}. Example: >vim
--- let failed = append(line('$'), "# THE END") --- let failed = append(line('$'), "# THE END")
--- let failed = append(0, ["Chapter 1", "the beginning"]) --- let failed = append(0, ["Chapter 1", "the beginning"])
--- < --- <
@@ -106,7 +107,8 @@ function vim.fn.append(lnum, text) end
--- If {buf} is not a valid buffer or {lnum} is not valid, an --- If {buf} is not a valid buffer or {lnum} is not valid, an
--- error message is given. Example: >vim --- error message is given. Example: >vim
--- let failed = appendbufline(13, 0, "# THE START") --- let failed = appendbufline(13, 0, "# THE START")
--- < --- <However, when {text} is an empty list then no error is given
--- for an invalid {lnum}, since {lnum} isn't actually used.
--- ---
--- @param buf any --- @param buf any
--- @param lnum integer --- @param lnum integer
@@ -7398,9 +7400,10 @@ function vim.fn.serverstop(address) end
--- ---
--- To insert lines use |appendbufline()|. --- To insert lines use |appendbufline()|.
--- ---
--- {text} can be a string to set one line, or a list of strings --- {text} can be a string to set one line, or a List of strings
--- to set multiple lines. If the list extends below the last --- to set multiple lines. If the List extends below the last
--- line then those lines are added. --- line then those lines are added. If the List is empty then
--- nothing is changed and zero is returned.
--- ---
--- For the use of {buf}, see |bufname()| above. --- For the use of {buf}, see |bufname()| above.
--- ---
@@ -7602,7 +7605,8 @@ function vim.fn.setfperm(fname, mode) end
--- When {lnum} is just below the last line the {text} will be --- When {lnum} is just below the last line the {text} will be
--- added below the last line. --- added below the last line.
--- {text} can be any type or a List of any type, each item is --- {text} can be any type or a List of any type, each item is
--- converted to a String. --- converted to a String. When {text} is an empty List then
--- nothing is changed and FALSE is returned.
--- ---
--- If this succeeds, FALSE is returned. If this fails (most likely --- If this succeeds, FALSE is returned. If this fails (most likely
--- because {lnum} is invalid) TRUE is returned. --- because {lnum} is invalid) TRUE is returned.

View File

@@ -141,7 +141,8 @@ M.funcs = {
{lnum} can be zero to insert a line before the first one. {lnum} can be zero to insert a line before the first one.
{lnum} is used like with |getline()|. {lnum} is used like with |getline()|.
Returns 1 for failure ({lnum} out of range or out of memory), Returns 1 for failure ({lnum} out of range or out of memory),
0 for success. Example: >vim 0 for success. When {text} is an empty list zero is returned,
no matter the value of {lnum}. Example: >vim
let failed = append(line('$'), "# THE END") let failed = append(line('$'), "# THE END")
let failed = append(0, ["Chapter 1", "the beginning"]) let failed = append(0, ["Chapter 1", "the beginning"])
< <
@@ -173,7 +174,8 @@ M.funcs = {
If {buf} is not a valid buffer or {lnum} is not valid, an If {buf} is not a valid buffer or {lnum} is not valid, an
error message is given. Example: >vim error message is given. Example: >vim
let failed = appendbufline(13, 0, "# THE START") let failed = appendbufline(13, 0, "# THE START")
< <However, when {text} is an empty list then no error is given
for an invalid {lnum}, since {lnum} isn't actually used.
]=], ]=],
name = 'appendbufline', name = 'appendbufline',
@@ -8871,9 +8873,10 @@ M.funcs = {
To insert lines use |appendbufline()|. To insert lines use |appendbufline()|.
{text} can be a string to set one line, or a list of strings {text} can be a string to set one line, or a List of strings
to set multiple lines. If the list extends below the last to set multiple lines. If the List extends below the last
line then those lines are added. line then those lines are added. If the List is empty then
nothing is changed and zero is returned.
For the use of {buf}, see |bufname()| above. For the use of {buf}, see |bufname()| above.
@@ -9117,7 +9120,8 @@ M.funcs = {
When {lnum} is just below the last line the {text} will be When {lnum} is just below the last line the {text} will be
added below the last line. added below the last line.
{text} can be any type or a List of any type, each item is {text} can be any type or a List of any type, each item is
converted to a String. converted to a String. When {text} is an empty List then
nothing is changed and FALSE is returned.
If this succeeds, FALSE is returned. If this fails (most likely If this succeeds, FALSE is returned. If this fails (most likely
because {lnum} is invalid) TRUE is returned. because {lnum} is invalid) TRUE is returned.

View File

@@ -160,10 +160,7 @@ static void set_buffer_lines(buf_T *buf, linenr_T lnum_arg, bool append, typval_
if (lines->v_type == VAR_LIST) { if (lines->v_type == VAR_LIST) {
l = lines->vval.v_list; l = lines->vval.v_list;
if (l == NULL || tv_list_len(l) == 0) { if (l == NULL || tv_list_len(l) == 0) {
// set proper return code // not appending anything always succeeds
if (lnum > curbuf->b_ml.ml_line_count) {
rettv->vval.v_number = 1; // FAIL
}
goto cleanup; goto cleanup;
} }
li = tv_list_first(l); li = tv_list_first(l);

View File

@@ -97,7 +97,7 @@ endfunc
func Test_argadd_empty_curbuf() func Test_argadd_empty_curbuf()
new new
let curbuf = bufnr('%') let curbuf = bufnr('%')
call writefile(['test', 'Xargadd'], 'Xargadd') call writefile(['test', 'Xargadd'], 'Xargadd', 'D')
" must not re-use the current buffer. " must not re-use the current buffer.
argadd Xargadd argadd Xargadd
call assert_equal(curbuf, bufnr('%')) call assert_equal(curbuf, bufnr('%'))
@@ -516,9 +516,9 @@ endfunc
" Test for autocommand that redefines the argument list, when doing ":all". " Test for autocommand that redefines the argument list, when doing ":all".
func Test_arglist_autocmd() func Test_arglist_autocmd()
autocmd BufReadPost Xxx2 next Xxx2 Xxx1 autocmd BufReadPost Xxx2 next Xxx2 Xxx1
call writefile(['test file Xxx1'], 'Xxx1') call writefile(['test file Xxx1'], 'Xxx1', 'D')
call writefile(['test file Xxx2'], 'Xxx2') call writefile(['test file Xxx2'], 'Xxx2', 'D')
call writefile(['test file Xxx3'], 'Xxx3') call writefile(['test file Xxx3'], 'Xxx3', 'D')
new new
" redefine arglist; go to Xxx1 " redefine arglist; go to Xxx1
@@ -534,18 +534,14 @@ func Test_arglist_autocmd()
autocmd! BufReadPost Xxx2 autocmd! BufReadPost Xxx2
enew! | only enew! | only
call delete('Xxx1')
call delete('Xxx2')
call delete('Xxx3')
argdelete Xxx* argdelete Xxx*
bwipe! Xxx1 Xxx2 Xxx3 bwipe! Xxx1 Xxx2 Xxx3
endfunc endfunc
func Test_arg_all_expand() func Test_arg_all_expand()
call writefile(['test file Xxx1'], 'Xx x') call writefile(['test file Xxx1'], 'Xx x', 'D')
next notexist Xx\ x runtest.vim next notexist Xx\ x runtest.vim
call assert_equal('notexist Xx\ x runtest.vim', expand('##')) call assert_equal('notexist Xx\ x runtest.vim', expand('##'))
call delete('Xx x')
endfunc endfunc
func Test_large_arg() func Test_large_arg()

View File

@@ -92,12 +92,12 @@ func Test_assert_equalfile()
call remove(v:errors, 0) call remove(v:errors, 0)
let goodtext = ["one", "two", "three"] let goodtext = ["one", "two", "three"]
call writefile(goodtext, 'Xone') call writefile(goodtext, 'Xone', 'D')
call assert_equal(1, 'Xone'->assert_equalfile('xyzxyz')) call assert_equal(1, 'Xone'->assert_equalfile('xyzxyz'))
call assert_match("E485: Can't read file xyzxyz", v:errors[0]) call assert_match("E485: Can't read file xyzxyz", v:errors[0])
call remove(v:errors, 0) call remove(v:errors, 0)
call writefile(goodtext, 'Xtwo') call writefile(goodtext, 'Xtwo', 'D')
call assert_equal(0, assert_equalfile('Xone', 'Xtwo')) call assert_equal(0, assert_equalfile('Xone', 'Xtwo'))
call writefile([goodtext[0]], 'Xone') call writefile([goodtext[0]], 'Xone')
@@ -127,9 +127,6 @@ func Test_assert_equalfile()
call assert_equal(1, assert_equalfile('Xone', 'Xtwo', 'a message')) call assert_equal(1, assert_equalfile('Xone', 'Xtwo', 'a message'))
call assert_match("a message: difference at byte 234, line 1 after", v:errors[0]) call assert_match("a message: difference at byte 234, line 1 after", v:errors[0])
call remove(v:errors, 0) call remove(v:errors, 0)
call delete('Xone')
call delete('Xtwo')
endfunc endfunc
func Test_assert_notequal() func Test_assert_notequal()

View File

@@ -24,12 +24,12 @@ endfunc
" Test for the CursorHold autocmd " Test for the CursorHold autocmd
func Test_CursorHold_autocmd() func Test_CursorHold_autocmd()
CheckRunVimInTerminal CheckRunVimInTerminal
call writefile(['one', 'two', 'three'], 'XoneTwoThree') call writefile(['one', 'two', 'three'], 'XoneTwoThree', 'D')
let before =<< trim END let before =<< trim END
set updatetime=10 set updatetime=10
au CursorHold * call writefile([line('.')], 'XCHoutput', 'a') au CursorHold * call writefile([line('.')], 'XCHoutput', 'a')
END END
call writefile(before, 'XCHinit') call writefile(before, 'XCHinit', 'D')
let buf = RunVimInTerminal('-S XCHinit XoneTwoThree', {}) let buf = RunVimInTerminal('-S XCHinit XoneTwoThree', {})
call term_sendkeys(buf, "G") call term_sendkeys(buf, "G")
call term_wait(buf, 50) call term_wait(buf, 50)
@@ -44,9 +44,7 @@ func Test_CursorHold_autocmd()
call WaitForAssert({-> assert_equal(['1', '2', '3'], readfile('XCHoutput')[-3:-1])}) call WaitForAssert({-> assert_equal(['1', '2', '3'], readfile('XCHoutput')[-3:-1])})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XCHinit')
call delete('XCHoutput') call delete('XCHoutput')
call delete('XoneTwoThree')
endfunc endfunc
if has('timers') if has('timers')
@@ -112,7 +110,7 @@ if has('timers')
augroup set_tabstop augroup set_tabstop
au OptionSet tabstop call timer_start(1, {-> execute("echo 'Handler called'", "")}) au OptionSet tabstop call timer_start(1, {-> execute("echo 'Handler called'", "")})
augroup END augroup END
call writefile(['vim: set ts=7 sw=5 :', 'something'], 'XoptionsetModeline') call writefile(['vim: set ts=7 sw=5 :', 'something'], 'XoptionsetModeline', 'D')
set modeline set modeline
let v:errmsg = '' let v:errmsg = ''
call assert_fails('split XoptionsetModeline', 'E12:') call assert_fails('split XoptionsetModeline', 'E12:')
@@ -124,7 +122,6 @@ if has('timers')
augroup END augroup END
bwipe! bwipe!
set ts& set ts&
call delete('XoptionsetModeline')
call test_override('starting', 0) call test_override('starting', 0)
endfunc endfunc
@@ -234,8 +231,8 @@ endfunc
func Test_autocmd_dummy_wipeout() func Test_autocmd_dummy_wipeout()
" prepare files " prepare files
call writefile([''], 'Xdummywipetest1.txt') call writefile([''], 'Xdummywipetest1.txt', 'D')
call writefile([''], 'Xdummywipetest2.txt') call writefile([''], 'Xdummywipetest2.txt', 'D')
augroup test_bufunload_group augroup test_bufunload_group
autocmd! autocmd!
autocmd BufUnload * call add(s:li, "bufunload") autocmd BufUnload * call add(s:li, "bufunload")
@@ -249,8 +246,6 @@ func Test_autocmd_dummy_wipeout()
call assert_equal(["bufunload", "bufwipeout"], s:li) call assert_equal(["bufunload", "bufwipeout"], s:li)
bwipeout bwipeout
call delete('Xdummywipetest1.txt')
call delete('Xdummywipetest2.txt')
au! test_bufunload_group au! test_bufunload_group
augroup! test_bufunload_group augroup! test_bufunload_group
endfunc endfunc
@@ -969,18 +964,19 @@ func Test_autocmd_bufwipe_in_SessLoadPost()
augroup END augroup END
func WriteErrors() func WriteErrors()
call writefile([execute("messages")], "Xerrors") call writefile([execute("messages")], "XerrorsBwipe")
endfunc endfunc
au VimLeave * call WriteErrors() au VimLeave * call WriteErrors()
[CODE] [CODE]
call writefile(content, 'Xvimrc') call writefile(content, 'Xvimrc', 'D')
call system(GetVimCommand('Xvimrc') .. ' --headless --noplugins -S Session.vim -c cq') call system(GetVimCommand('Xvimrc') .. ' --headless --noplugins -S Session.vim -c cq')
let errors = join(readfile('Xerrors')) sleep 100m
call assert_match('E814', errors) let errors = join(readfile('XerrorsBwipe'))
call assert_match('E814:', errors)
set swapfile set swapfile
for file in ['Session.vim', 'Xvimrc', 'Xerrors'] for file in ['Session.vim', 'XerrorsBwipe']
call delete(file) call delete(file)
endfor endfor
endfunc endfunc
@@ -993,16 +989,16 @@ func Test_autocmd_blast_badd()
edit foo1 edit foo1
au BufNew,BufAdd,BufWinEnter,BufEnter,BufLeave,BufWinLeave,BufUnload,VimEnter foo* ball au BufNew,BufAdd,BufWinEnter,BufEnter,BufLeave,BufWinLeave,BufUnload,VimEnter foo* ball
edit foo2 edit foo2
call writefile(['OK'], 'Xerrors') call writefile(['OK'], 'XerrorsBlast')
qall qall
[CODE] [CODE]
call writefile(content, 'XblastBall') call writefile(content, 'XblastBall', 'D')
call system(GetVimCommand() .. ' --clean -S XblastBall') call system(GetVimCommand() .. ' --clean -S XblastBall')
call assert_match('OK', readfile('Xerrors')->join()) sleep 100m
call assert_match('OK', readfile('XerrorsBlast')->join())
call delete('XblastBall') call delete('XerrorsBlast')
call delete('Xerrors')
endfunc endfunc
" SEGV occurs in older versions. " SEGV occurs in older versions.
@@ -1029,20 +1025,21 @@ func Test_autocmd_bufwipe_in_SessLoadPost2()
au SessionLoadPost * call DeleteInactiveBufs() au SessionLoadPost * call DeleteInactiveBufs()
func WriteErrors() func WriteErrors()
call writefile([execute("messages")], "Xerrors") call writefile([execute("messages")], "XerrorsPost")
endfunc endfunc
au VimLeave * call WriteErrors() au VimLeave * call WriteErrors()
[CODE] [CODE]
call writefile(content, 'Xvimrc') call writefile(content, 'Xvimrc', 'D')
call system(GetVimCommand('Xvimrc') .. ' --headless --noplugins -S Session.vim -c cq') call system(GetVimCommand('Xvimrc') .. ' --headless --noplugins -S Session.vim -c cq')
let errors = join(readfile('Xerrors')) sleep 100m
let errors = join(readfile('XerrorsPost'))
" This probably only ever matches on unix. " This probably only ever matches on unix.
call assert_notmatch('Caught deadly signal SEGV', errors) call assert_notmatch('Caught deadly signal SEGV', errors)
call assert_match('SessionLoadPost DONE', errors) call assert_match('SessionLoadPost DONE', errors)
set swapfile set swapfile
for file in ['Session.vim', 'Xvimrc', 'Xerrors'] for file in ['Session.vim', 'XerrorsPost']
call delete(file) call delete(file)
endfor endfor
endfunc endfunc
@@ -1745,9 +1742,9 @@ endfunc
func Test_Acmd_BufAll() func Test_Acmd_BufAll()
enew! enew!
%bwipe! %bwipe!
call writefile(['Test file Xxx1'], 'Xxx1') call writefile(['Test file Xxx1'], 'Xxx1', 'D')
call writefile(['Test file Xxx2'], 'Xxx2') call writefile(['Test file Xxx2'], 'Xxx2', 'D')
call writefile(['Test file Xxx3'], 'Xxx3') call writefile(['Test file Xxx3'], 'Xxx3', 'D')
" Add three files to the buffer list " Add three files to the buffer list
split Xxx1 split Xxx1
@@ -1769,9 +1766,6 @@ func Test_Acmd_BufAll()
au! BufReadPost au! BufReadPost
%bwipe! %bwipe!
call delete('Xxx1')
call delete('Xxx2')
call delete('Xxx3')
enew! | only enew! | only
endfunc endfunc
@@ -1781,11 +1775,11 @@ func Test_Acmd_BufEnter()
%bwipe! %bwipe!
call writefile(['start of test file Xxx1', call writefile(['start of test file Xxx1',
\ "\<Tab>this is a test", \ "\<Tab>this is a test",
\ 'end of test file Xxx1'], 'Xxx1') \ 'end of test file Xxx1'], 'Xxx1', 'D')
call writefile(['start of test file Xxx2', call writefile(['start of test file Xxx2',
\ 'vim: set noai :', \ 'vim: set noai :',
\ "\<Tab>this is a test", \ "\<Tab>this is a test",
\ 'end of test file Xxx2'], 'Xxx2') \ 'end of test file Xxx2'], 'Xxx2', 'D')
au BufEnter Xxx2 brew au BufEnter Xxx2 brew
set ai modeline modelines=3 set ai modeline modelines=3
@@ -1807,8 +1801,6 @@ func Test_Acmd_BufEnter()
call assert_equal(4, line('.')) call assert_equal(4, line('.'))
%bwipe! %bwipe!
call delete('Xxx1')
call delete('Xxx2')
set ai&vim modeline&vim modelines&vim set ai&vim modeline&vim modelines&vim
endfunc endfunc
@@ -1835,8 +1827,8 @@ func Test_BufLeave_Wipe()
let content = ['start of test file Xxx', let content = ['start of test file Xxx',
\ 'this is a test', \ 'this is a test',
\ 'end of test file Xxx'] \ 'end of test file Xxx']
call writefile(content, 'Xxx1') call writefile(content, 'Xxx1', 'D')
call writefile(content, 'Xxx2') call writefile(content, 'Xxx2', 'D')
au BufLeave Xxx2 bwipe au BufLeave Xxx2 bwipe
edit Xxx1 edit Xxx1
@@ -1862,8 +1854,6 @@ func Test_BufLeave_Wipe()
let g:bufinfo = getbufinfo() let g:bufinfo = getbufinfo()
call assert_equal(1, len(g:bufinfo)) call assert_equal(1, len(g:bufinfo))
call delete('Xxx1')
call delete('Xxx2')
call delete('test.out') call delete('test.out')
%bwipe %bwipe
au! BufLeave au! BufLeave
@@ -1990,32 +1980,30 @@ func Test_BufWritePre()
au BufWritePre Xxx1 bunload au BufWritePre Xxx1 bunload
au BufWritePre Xxx2 bwipe au BufWritePre Xxx2 bwipe
call writefile(['start of Xxx1', 'test', 'end of Xxx1'], 'Xxx1') call writefile(['start of Xxx1', 'test', 'end of Xxx1'], 'Xxx1', 'D')
call writefile(['start of Xxx2', 'test', 'end of Xxx2'], 'Xxx2') call writefile(['start of Xxx2', 'test', 'end of Xxx2'], 'Xxx2', 'D')
edit Xtest edit Xtest
e! Xxx2 e! Xxx2
bdel Xtest bdel Xtest
e Xxx1 e Xxx1
" write it, will unload it and give an error msg " write it, will unload it and give an error msg
call assert_fails('w', 'E203') call assert_fails('w', 'E203:')
call assert_equal('Xxx2', bufname('%')) call assert_equal('Xxx2', bufname('%'))
edit Xtest edit Xtest
e! Xxx2 e! Xxx2
bwipe Xtest bwipe Xtest
" write it, will delete the buffer and give an error msg " write it, will delete the buffer and give an error msg
call assert_fails('w', 'E203') call assert_fails('w', 'E203:')
call assert_equal('Xxx1', bufname('%')) call assert_equal('Xxx1', bufname('%'))
au! BufWritePre au! BufWritePre
call delete('Xxx1')
call delete('Xxx2')
endfunc endfunc
" Test for BufUnload autocommand that unloads all the other buffers " Test for BufUnload autocommand that unloads all the other buffers
func Test_bufunload_all() func Test_bufunload_all()
let g:test_is_flaky = 1 let g:test_is_flaky = 1
call writefile(['Test file Xxx1'], 'Xxx1')" call writefile(['Test file Xxx1'], 'Xxx1', 'D')"
call writefile(['Test file Xxx2'], 'Xxx2')" call writefile(['Test file Xxx2'], 'Xxx2', 'D')"
let content =<< trim [CODE] let content =<< trim [CODE]
func UnloadAllBufs() func UnloadAllBufs()
@@ -2035,15 +2023,12 @@ func Test_bufunload_all()
q q
[CODE] [CODE]
call writefile(content, 'Xtest') call writefile(content, 'Xbunloadtest', 'D')
call delete('Xout') call delete('Xout')
call system(GetVimCommandClean() .. ' -N --headless -S Xtest') call system(GetVimCommandClean() .. ' -N --headless -S Xbunloadtest')
call assert_true(filereadable('Xout')) call assert_true(filereadable('Xout'))
call delete('Xxx1')
call delete('Xxx2')
call delete('Xtest')
call delete('Xout') call delete('Xout')
endfunc endfunc
@@ -2071,7 +2056,7 @@ endfunc
" Test for "*Cmd" autocommands " Test for "*Cmd" autocommands
func Test_Cmd_Autocmds() func Test_Cmd_Autocmds()
call writefile(['start of Xxx', "\tabc2", 'end of Xxx'], 'Xxx') call writefile(['start of Xxx', "\tabc2", 'end of Xxx'], 'Xxx', 'D')
enew! enew!
au BufReadCmd XtestA 0r Xxx|$del au BufReadCmd XtestA 0r Xxx|$del
@@ -2146,7 +2131,6 @@ func Test_Cmd_Autocmds()
au! FileWriteCmd au! FileWriteCmd
au! FileAppendCmd au! FileAppendCmd
%bwipe! %bwipe!
call delete('Xxx')
enew! enew!
endfunc endfunc
@@ -2171,7 +2155,7 @@ func Test_BufReadCmd()
autocmd BufReadCmd *.test call s:ReadFile() autocmd BufReadCmd *.test call s:ReadFile()
autocmd BufWriteCmd *.test call s:WriteFile() autocmd BufWriteCmd *.test call s:WriteFile()
call writefile(['one', 'two', 'three'], 'Xcmd.test') call writefile(['one', 'two', 'three'], 'Xcmd.test', 'D')
edit Xcmd.test edit Xcmd.test
call assert_match('Xcmd.test" line 1 of 3', execute('file')) call assert_match('Xcmd.test" line 1 of 3', execute('file'))
normal! Gofour normal! Gofour
@@ -2179,7 +2163,6 @@ func Test_BufReadCmd()
call assert_equal(['one', 'two', 'three', 'four'], readfile('Xcmd.test')) call assert_equal(['one', 'two', 'three', 'four'], readfile('Xcmd.test'))
bwipe! bwipe!
call delete('Xcmd.test')
au! BufReadCmd au! BufReadCmd
au! BufWriteCmd au! BufWriteCmd
endfunc endfunc
@@ -2543,7 +2526,7 @@ func Test_Changed_FirstTime()
let g:test_is_flaky = 1 let g:test_is_flaky = 1
" Prepare file for TextChanged event. " Prepare file for TextChanged event.
call writefile([''], 'Xchanged.txt') call writefile([''], 'Xchanged.txt', 'D')
let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': 3}) let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': 3})
call assert_equal('running', term_getstatus(buf)) call assert_equal('running', term_getstatus(buf))
" Wait for the ruler (in the status line) to be shown. " Wait for the ruler (in the status line) to be shown.
@@ -2555,7 +2538,6 @@ func Test_Changed_FirstTime()
call assert_equal([''], readfile('Xchanged.txt')) call assert_equal([''], readfile('Xchanged.txt'))
" clean up " clean up
call delete('Xchanged.txt')
bwipe! bwipe!
endfunc endfunc
@@ -2642,13 +2624,12 @@ func Test_autocmd_nested_switch_window()
autocmd BufReadPost * autocmd SafeState * ++once foldclosed('.') autocmd BufReadPost * autocmd SafeState * ++once foldclosed('.')
autocmd WinEnter * matchadd('ErrorMsg', 'pat') autocmd WinEnter * matchadd('ErrorMsg', 'pat')
END END
call writefile(lines, 'Xautoscript') call writefile(lines, 'Xautoscript', 'D')
let buf = RunVimInTerminal('-S Xautoscript', {'rows': 10}) let buf = RunVimInTerminal('-S Xautoscript', {'rows': 10})
call VerifyScreenDump(buf, 'Test_autocmd_nested_switch', {}) call VerifyScreenDump(buf, 'Test_autocmd_nested_switch', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('Xautofile') call delete('Xautofile')
call delete('Xautoscript')
endfunc endfunc
func Test_autocmd_once() func Test_autocmd_once()
@@ -2801,7 +2782,7 @@ func Test_ReadWrite_Autocmds()
au FileAppendPost *.out !cat Xtest.c >> test.out au FileAppendPost *.out !cat Xtest.c >> test.out
augroup END augroup END
call writefile(['/*', ' * Here is a new .c file', ' */'], 'Xtest.c') call writefile(['/*', ' * Here is a new .c file', ' */'], 'Xtest.c', 'D')
new foo.c " should load Xtest.c new foo.c " should load Xtest.c
call assert_equal(['/*', ' * Here is a new .c file', ' */'], getline(2, 4)) call assert_equal(['/*', ' * Here is a new .c file', ' */'], getline(2, 4))
w! >> test.out " append it to the output file w! >> test.out " append it to the output file
@@ -2925,7 +2906,6 @@ func Test_ReadWrite_Autocmds()
au! FileChangedShell au! FileChangedShell
call delete('Xtestfile.gz') call delete('Xtestfile.gz')
call delete('Xtest.c')
call delete('test.out') call delete('test.out')
endfunc endfunc
@@ -2972,10 +2952,10 @@ func Test_autocmd_SafeState()
call timer_start(10, {id -> execute('let g:again ..= "t"')}) call timer_start(10, {id -> execute('let g:again ..= "t"')})
endfunc endfunc
END END
call writefile(lines, 'XSafeState') call writefile(lines, 'XSafeState', 'D')
let buf = RunVimInTerminal('-S XSafeState', #{rows: 6}) let buf = RunVimInTerminal('-S XSafeState', #{rows: 6})
" Sometimes we loop to handle a K_IGNORE, SafeState may be trigered once or " Sometimes we loop to handle a K_IGNORE, SafeState may be triggered once or
" more often. " more often.
call term_sendkeys(buf, ":echo g:safe\<CR>") call term_sendkeys(buf, ":echo g:safe\<CR>")
call WaitForAssert({-> assert_match('^\d ', term_getline(buf, 6))}, 1000) call WaitForAssert({-> assert_match('^\d ', term_getline(buf, 6))}, 1000)
@@ -2992,7 +2972,6 @@ func Test_autocmd_SafeState()
call WaitForAssert({-> assert_match('xtx', term_getline(buf, 6))}, 1000) call WaitForAssert({-> assert_match('xtx', term_getline(buf, 6))}, 1000)
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XSafeState')
endfunc endfunc
func Test_autocmd_CmdWinEnter() func Test_autocmd_CmdWinEnter()
@@ -3244,11 +3223,11 @@ func Test_BufReadPre_delfile()
au! au!
autocmd BufReadPre XbufreadPre call delete('XbufreadPre') autocmd BufReadPre XbufreadPre call delete('XbufreadPre')
augroup END augroup END
call writefile([], 'XbufreadPre') call writefile([], 'XbufreadPre', 'D')
call assert_fails('new XbufreadPre', 'E200:') call assert_fails('new XbufreadPre', 'E200:')
call assert_equal('XbufreadPre', @%) call assert_equal('XbufreadPre', @%)
call assert_equal(1, &readonly) call assert_equal(1, &readonly)
call delete('XbufreadPre')
augroup TestAuCmd augroup TestAuCmd
au! au!
augroup END augroup END
@@ -3261,11 +3240,11 @@ func Test_BufReadPre_changebuf()
au! au!
autocmd BufReadPre Xchangebuf edit Xsomeotherfile autocmd BufReadPre Xchangebuf edit Xsomeotherfile
augroup END augroup END
call writefile([], 'Xchangebuf') call writefile([], 'Xchangebuf', 'D')
call assert_fails('new Xchangebuf', 'E201:') call assert_fails('new Xchangebuf', 'E201:')
call assert_equal('Xsomeotherfile', @%) call assert_equal('Xsomeotherfile', @%)
call assert_equal(1, &readonly) call assert_equal(1, &readonly)
call delete('Xchangebuf')
augroup TestAuCmd augroup TestAuCmd
au! au!
augroup END augroup END

View File

@@ -79,11 +79,11 @@ endfunc
func Test_non_existing_backupdir() func Test_non_existing_backupdir()
throw 'Skipped: Nvim auto-creates backup directory' throw 'Skipped: Nvim auto-creates backup directory'
set backupdir=./non_existing_dir backupskip= set backupdir=./non_existing_dir backupskip=
call writefile(['line1'], 'Xbackupdir') call writefile(['line1'], 'Xbackupdir', 'D')
new Xbackupdir new Xbackupdir
call assert_fails('write', 'E510:') call assert_fails('write', 'E510:')
set backupdir&vim backupskip&vim set backupdir&vim backupskip&vim
call delete('Xbackupdir')
endfunc endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -942,14 +942,13 @@ func Test_cursor_position_with_showbreak()
repeat('x', &columns - leftcol - 1)->setline(1) repeat('x', &columns - leftcol - 1)->setline(1)
'second line'->setline(2) 'second line'->setline(2)
END END
call writefile(lines, 'XscriptShowbreak') call writefile(lines, 'XscriptShowbreak', 'D')
let buf = RunVimInTerminal('-S XscriptShowbreak', #{rows: 6}) let buf = RunVimInTerminal('-S XscriptShowbreak', #{rows: 6})
call term_sendkeys(buf, "AX") call term_sendkeys(buf, "AX")
call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak', {}) call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XscriptShowbreak')
endfunc endfunc
func Test_no_spurious_match() func Test_no_spurious_match()

View File

@@ -5,64 +5,60 @@ source check.vim
" Test for the :bunload command with an offset " Test for the :bunload command with an offset
func Test_bunload_with_offset() func Test_bunload_with_offset()
%bwipe! %bwipe!
call writefile(['B1'], 'b1') call writefile(['B1'], 'Xb1', 'D')
call writefile(['B2'], 'b2') call writefile(['B2'], 'Xb2', 'D')
call writefile(['B3'], 'b3') call writefile(['B3'], 'Xb3', 'D')
call writefile(['B4'], 'b4') call writefile(['B4'], 'Xb4', 'D')
" Load four buffers. Unload the second and third buffers and then " Load four buffers. Unload the second and third buffers and then
" execute .+3bunload to unload the last buffer. " execute .+3bunload to unload the last buffer.
edit b1 edit Xb1
new b2 new Xb2
new b3 new Xb3
new b4 new Xb4
bunload b2 bunload Xb2
bunload b3 bunload Xb3
exe bufwinnr('b1') . 'wincmd w' exe bufwinnr('Xb1') . 'wincmd w'
.+3bunload .+3bunload
call assert_equal(0, getbufinfo('b4')[0].loaded) call assert_equal(0, getbufinfo('Xb4')[0].loaded)
call assert_equal('b1', call assert_equal('Xb1',
\ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
" Load four buffers. Unload the third and fourth buffers. Execute .+3bunload " Load four buffers. Unload the third and fourth buffers. Execute .+3bunload
" and check whether the second buffer is unloaded. " and check whether the second buffer is unloaded.
ball ball
bunload b3 bunload Xb3
bunload b4 bunload Xb4
exe bufwinnr('b1') . 'wincmd w' exe bufwinnr('Xb1') . 'wincmd w'
.+3bunload .+3bunload
call assert_equal(0, getbufinfo('b2')[0].loaded) call assert_equal(0, getbufinfo('Xb2')[0].loaded)
call assert_equal('b1', call assert_equal('Xb1',
\ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
" Load four buffers. Unload the second and third buffers and from the last " Load four buffers. Unload the second and third buffers and from the last
" buffer execute .-3bunload to unload the first buffer. " buffer execute .-3bunload to unload the first buffer.
ball ball
bunload b2 bunload Xb2
bunload b3 bunload Xb3
exe bufwinnr('b4') . 'wincmd w' exe bufwinnr('Xb4') . 'wincmd w'
.-3bunload .-3bunload
call assert_equal(0, getbufinfo('b1')[0].loaded) call assert_equal(0, getbufinfo('Xb1')[0].loaded)
call assert_equal('b4', call assert_equal('Xb4',
\ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
" Load four buffers. Unload the first and second buffers. Execute .-3bunload " Load four buffers. Unload the first and second buffers. Execute .-3bunload
" from the last buffer and check whether the third buffer is unloaded. " from the last buffer and check whether the third buffer is unloaded.
ball ball
bunload b1 bunload Xb1
bunload b2 bunload Xb2
exe bufwinnr('b4') . 'wincmd w' exe bufwinnr('Xb4') . 'wincmd w'
.-3bunload .-3bunload
call assert_equal(0, getbufinfo('b3')[0].loaded) call assert_equal(0, getbufinfo('Xb3')[0].loaded)
call assert_equal('b4', call assert_equal('Xb4',
\ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t')) \ fnamemodify(getbufinfo({'bufloaded' : 1})[0].name, ':t'))
%bwipe! %bwipe!
call delete('b1')
call delete('b2')
call delete('b3')
call delete('b4')
call assert_fails('1,4bunload', 'E16:') call assert_fails('1,4bunload', 'E16:')
call assert_fails(',100bunload', 'E16:') call assert_fails(',100bunload', 'E16:')
@@ -76,9 +72,9 @@ func Test_buflist_browse()
%bwipe! %bwipe!
call assert_fails('buffer 1000', 'E86:') call assert_fails('buffer 1000', 'E86:')
call writefile(['foo1', 'foo2', 'foo3', 'foo4'], 'Xbrowse1') call writefile(['foo1', 'foo2', 'foo3', 'foo4'], 'Xbrowse1', 'D')
call writefile(['bar1', 'bar2', 'bar3', 'bar4'], 'Xbrowse2') call writefile(['bar1', 'bar2', 'bar3', 'bar4'], 'Xbrowse2', 'D')
call writefile(['baz1', 'baz2', 'baz3', 'baz4'], 'Xbrowse3') call writefile(['baz1', 'baz2', 'baz3', 'baz4'], 'Xbrowse3', 'D')
edit Xbrowse1 edit Xbrowse1
let b1 = bufnr() let b1 = bufnr()
edit Xbrowse2 edit Xbrowse2
@@ -127,9 +123,6 @@ func Test_buflist_browse()
call assert_fails('sandbox bnext', 'E48:') call assert_fails('sandbox bnext', 'E48:')
call delete('Xbrowse1')
call delete('Xbrowse2')
call delete('Xbrowse3')
%bwipe! %bwipe!
endfunc endfunc
@@ -200,13 +193,13 @@ endfunc
" Test for quitting the 'swapfile exists' dialog with the split buffer " Test for quitting the 'swapfile exists' dialog with the split buffer
" command. " command.
func Test_buffer_sbuf_cleanup() func Test_buffer_sbuf_cleanup()
call writefile([], 'XsplitCleanup') call writefile([], 'XsplitCleanup', 'D')
" first open the file in a buffer " first open the file in a buffer
new XsplitCleanup new XsplitCleanup
let bnr = bufnr() let bnr = bufnr()
close close
" create the swap file " create the swap file
call writefile([], '.XsplitCleanup.swp') call writefile([], '.XsplitCleanup.swp', 'D')
" Remove the catch-all that runtest.vim adds " Remove the catch-all that runtest.vim adds
au! SwapExists au! SwapExists
augroup BufTest augroup BufTest
@@ -231,8 +224,6 @@ func Test_buffer_sbuf_cleanup()
call assert_equal(0, getbufinfo('XsplitCleanup')[0].loaded) call assert_equal(0, getbufinfo('XsplitCleanup')[0].loaded)
set shortmess& set shortmess&
call delete('XsplitCleanup')
call delete('.XsplitCleanup.swp')
augroup BufTest augroup BufTest
au! au!
augroup END augroup END
@@ -329,8 +320,8 @@ endfunc
" Test for using CTRL-^ to edit the alternative file keeping the cursor " Test for using CTRL-^ to edit the alternative file keeping the cursor
" position with 'nostartofline'. Also test using the 'buf' command. " position with 'nostartofline'. Also test using the 'buf' command.
func Test_buffer_edit_altfile() func Test_buffer_edit_altfile()
call writefile(repeat(['one two'], 50), 'Xaltfile1') call writefile(repeat(['one two'], 50), 'Xaltfile1', 'D')
call writefile(repeat(['five six'], 50), 'Xaltfile2') call writefile(repeat(['five six'], 50), 'Xaltfile2', 'D')
set nosol set nosol
edit Xaltfile1 edit Xaltfile1
call cursor(25, 5) call cursor(25, 5)
@@ -345,8 +336,6 @@ func Test_buffer_edit_altfile()
buf Xaltfile2 buf Xaltfile2
call assert_equal([0, 30, 4, 0], getpos('.')) call assert_equal([0, 30, 4, 0], getpos('.'))
set sol& set sol&
call delete('Xaltfile1')
call delete('Xaltfile2')
endfunc endfunc
" Test for running the :sball command with a maximum window count and a " Test for running the :sball command with a maximum window count and a
@@ -390,6 +379,7 @@ endfunc
func Test_buffer_scheme() func Test_buffer_scheme()
CheckMSWindows CheckMSWindows
set noswapfile
set noshellslash set noshellslash
%bwipe! %bwipe!
let bufnames = [ let bufnames = [
@@ -412,6 +402,7 @@ func Test_buffer_scheme()
endfor endfor
set shellslash& set shellslash&
set swapfile&
endfunc endfunc
" this was using a NULL pointer after failing to use the pattern " this was using a NULL pointer after failing to use the pattern
@@ -499,7 +490,7 @@ func Test_buflist_alloc_failure()
call assert_fails('%bw!', 'E342:') call assert_fails('%bw!', 'E342:')
" test for :checktime loading the buffer " test for :checktime loading the buffer
call writefile(['one'], 'XallocFail5') call writefile(['one'], 'XallocFail5', 'D')
if has('unix') if has('unix')
edit XallocFail5 edit XallocFail5
" sleep for some time to make sure the timestamp is different " sleep for some time to make sure the timestamp is different
@@ -515,7 +506,6 @@ func Test_buflist_alloc_failure()
" test for :vimgrep loading a dummy buffer " test for :vimgrep loading a dummy buffer
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)
call assert_fails('vimgrep two XallocFail5', 'E342:') call assert_fails('vimgrep two XallocFail5', 'E342:')
call delete('XallocFail5')
" test for quickfix command loading a buffer " test for quickfix command loading a buffer
call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0) call test_alloc_fail(GetAllocId('newbuf_bvars'), 0, 0)

View File

@@ -25,8 +25,8 @@ func Test_setbufline_getbufline()
call assert_equal(1, setbufline(b, 5, 'x')) call assert_equal(1, setbufline(b, 5, 'x'))
call assert_equal(1, setbufline(b, 5, ['x'])) call assert_equal(1, setbufline(b, 5, ['x']))
call assert_equal(1, setbufline(b, 5, [])) call assert_equal(0, setbufline(b, 5, []))
call assert_equal(1, setbufline(b, 5, v:_null_list)) call assert_equal(0, setbufline(b, 5, v:_null_list))
call assert_equal(1, 'x'->setbufline(bufnr('$') + 1, 1)) call assert_equal(1, 'x'->setbufline(bufnr('$') + 1, 1))
call assert_equal(1, ['x']->setbufline(bufnr('$') + 1, 1)) call assert_equal(1, ['x']->setbufline(bufnr('$') + 1, 1))
@@ -86,11 +86,16 @@ func Test_setline_startup()
if cmd == '' if cmd == ''
return return
endif endif
call writefile(['call setline(1, "Hello")', 'silent w Xtest', 'q!'], 'Xscript') call writefile(['call setline(1, "Hello")', 'silent w Xtest', 'q!'], 'Xscript', 'D')
call system(cmd) call system(cmd)
sleep 50m
call assert_equal(['Hello'], readfile('Xtest')) call assert_equal(['Hello'], readfile('Xtest'))
call delete('Xscript') call assert_equal(0, setline(1, []))
call assert_equal(0, setline(1, v:_null_list))
call assert_equal(0, setline(5, []))
call assert_equal(0, setline(6, v:_null_list))
call delete('Xtest') call delete('Xtest')
endfunc endfunc
@@ -130,8 +135,8 @@ func Test_appendbufline()
call assert_equal(1, appendbufline(b, 4, 'x')) call assert_equal(1, appendbufline(b, 4, 'x'))
call assert_equal(1, appendbufline(b, 4, ['x'])) call assert_equal(1, appendbufline(b, 4, ['x']))
call assert_equal(1, appendbufline(b, 4, [])) call assert_equal(0, appendbufline(b, 4, []))
call assert_equal(1, appendbufline(b, 4, v:_null_list)) call assert_equal(0, appendbufline(b, 4, v:_null_list))
call assert_equal(1, appendbufline(1234, 1, 'x')) call assert_equal(1, appendbufline(1234, 1, 'x'))
call assert_equal(1, appendbufline(1234, 1, ['x'])) call assert_equal(1, appendbufline(1234, 1, ['x']))
@@ -140,8 +145,8 @@ func Test_appendbufline()
call assert_equal(0, appendbufline(b, 1, [])) call assert_equal(0, appendbufline(b, 1, []))
call assert_equal(0, appendbufline(b, 1, v:_null_list)) call assert_equal(0, appendbufline(b, 1, v:_null_list))
call assert_equal(1, appendbufline(b, 3, [])) call assert_equal(0, appendbufline(b, 3, []))
call assert_equal(1, appendbufline(b, 3, v:_null_list)) call assert_equal(0, appendbufline(b, 3, v:_null_list))
call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$')) call assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$'))
@@ -215,12 +220,11 @@ func Test_appendbufline_redraw()
call deletebufline(buf, 1, '$') call deletebufline(buf, 1, '$')
call appendbufline(buf, '$', 'Hello Vim world...') call appendbufline(buf, '$', 'Hello Vim world...')
END END
call writefile(lines, 'XscriptMatchCommon') call writefile(lines, 'XscriptMatchCommon', 'D')
let buf = RunVimInTerminal('-S XscriptMatchCommon', #{rows: 10}) let buf = RunVimInTerminal('-S XscriptMatchCommon', #{rows: 10})
call VerifyScreenDump(buf, 'Test_appendbufline_1', {}) call VerifyScreenDump(buf, 'Test_appendbufline_1', {})
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XscriptMatchCommon')
endfunc endfunc
func Test_setbufline_select_mode() func Test_setbufline_select_mode()

View File

@@ -835,9 +835,13 @@ endfunc
func Test_append() func Test_append()
enew! enew!
split split
call append(0, ["foo"]) call assert_equal(0, append(1, []))
call append(1, []) call assert_equal(0, append(1, v:_null_list))
call append(1, v:_null_list) call assert_equal(0, append(0, ["foo"]))
call assert_equal(0, append(1, []))
call assert_equal(0, append(1, v:_null_list))
call assert_equal(0, append(8, []))
call assert_equal(0, append(9, v:_null_list))
call assert_equal(['foo', ''], getline(1, '$')) call assert_equal(['foo', ''], getline(1, '$'))
split split
only only

View File

@@ -44,6 +44,7 @@ func Test_profile_func()
\ . ' --cmd "qall!"') \ . ' --cmd "qall!"')
call assert_equal(0, v:shell_error) call assert_equal(0, v:shell_error)
sleep 50m
let lines = readfile('Xprofile_func.log') let lines = readfile('Xprofile_func.log')
" - Foo1() is called 3 times but should be reported as called twice " - Foo1() is called 3 times but should be reported as called twice

View File

@@ -5,6 +5,11 @@ source check.vim
source shared.vim source shared.vim
func Test_shell_options() func Test_shell_options()
if has('win32')
" FIXME: This test is flaky on MS-Windows.
let g:test_is_flaky = 1
endif
" The expected value of 'shellcmdflag', 'shellpipe', 'shellquote', " The expected value of 'shellcmdflag', 'shellpipe', 'shellquote',
" 'shellredir', 'shellxescape', 'shellxquote' for the supported shells. " 'shellredir', 'shellxescape', 'shellxquote' for the supported shells.
let shells = [] let shells = []

View File

@@ -295,9 +295,9 @@ func Test_q_arg()
call writefile(lines, 'Xbadfile.c') call writefile(lines, 'Xbadfile.c')
let after =<< trim [CODE] let after =<< trim [CODE]
call writefile([&errorfile, string(getpos("."))], "Xtestout") call writefile([&errorfile, string(getpos("."))], "XtestoutQarg")
copen copen
w >> Xtestout w >> XtestoutQarg
qall qall
[CODE] [CODE]
@@ -305,30 +305,30 @@ func Test_q_arg()
call assert_equal('errors.err', &errorfile) call assert_equal('errors.err', &errorfile)
call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'errors.err') call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'errors.err')
if RunVim([], after, '-q') if RunVim([], after, '-q')
let lines = readfile('Xtestout') let lines = readfile('XtestoutQarg')
call assert_equal(['errors.err', call assert_equal(['errors.err',
\ '[0, 4, 12, 0]', \ '[0, 4, 12, 0]',
\ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"], \ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"],
\ lines) \ lines)
endif endif
call delete('Xtestout') call delete('XtestoutQarg')
call delete('errors.err') call delete('errors.err')
" Test with explicit argument '-q Xerrors' (with space). " Test with explicit argument '-q XerrorsQarg' (with space).
call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'Xerrors') call writefile(["Xbadfile.c:4:12: error: expected ';' before '}' token"], 'XerrorsQarg')
if RunVim([], after, '-q Xerrors') if RunVim([], after, '-q XerrorsQarg')
let lines = readfile('Xtestout') let lines = readfile('XtestoutQarg')
call assert_equal(['Xerrors', call assert_equal(['XerrorsQarg',
\ '[0, 4, 12, 0]', \ '[0, 4, 12, 0]',
\ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"], \ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"],
\ lines) \ lines)
endif endif
call delete('Xtestout') call delete('XtestoutQarg')
" Test with explicit argument '-qXerrors' (without space). " Test with explicit argument '-qXerrorsQarg' (without space).
if RunVim([], after, '-qXerrors') if RunVim([], after, '-qXerrorsQarg')
let lines = readfile('Xtestout') let lines = readfile('XtestoutQarg')
call assert_equal(['Xerrors', call assert_equal(['XerrorsQarg',
\ '[0, 4, 12, 0]', \ '[0, 4, 12, 0]',
\ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"], \ "Xbadfile.c|4 col 12| error: expected ';' before '}' token"],
\ lines) \ lines)
@@ -339,8 +339,8 @@ func Test_q_arg()
call assert_equal(3, v:shell_error) call assert_equal(3, v:shell_error)
call delete('Xbadfile.c') call delete('Xbadfile.c')
call delete('Xtestout') call delete('XtestoutQarg')
call delete('Xerrors') call delete('XerrorsQarg')
endfunc endfunc
" Test the -V[N]{filename} argument to set the 'verbose' option to N " Test the -V[N]{filename} argument to set the 'verbose' option to N

View File

@@ -399,6 +399,11 @@ endfunc
func Test_undofile_earlier() func Test_undofile_earlier()
throw 'Skipped: Nvim does not support test_settime()' throw 'Skipped: Nvim does not support test_settime()'
if has('win32')
" FIXME: This test is flaky on MS-Windows.
let g:test_is_flaky = 1
endif
" Issue #1254 " Issue #1254
" create undofile with timestamps older than Vim startup time. " create undofile with timestamps older than Vim startup time.
let t0 = localtime() - 43200 let t0 = localtime() - 43200