forked from aniani/vim
patch 9.0.0380: deleting files in tests is a hassle
Problem: Deleting files in tests is a hassle. Solution: Use the new 'D' flag of writefile().
This commit is contained in:
@@ -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('%'))
|
||||||
@@ -108,7 +108,6 @@ func Test_argadd_empty_curbuf()
|
|||||||
call assert_equal('Xargadd', '%'->bufname())
|
call assert_equal('Xargadd', '%'->bufname())
|
||||||
call assert_equal(2, line('$'))
|
call assert_equal(2, line('$'))
|
||||||
|
|
||||||
call delete('Xargadd')
|
|
||||||
%argd
|
%argd
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
@@ -506,9 +505,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
|
||||||
@@ -524,18 +523,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()
|
||||||
|
@@ -89,12 +89,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')
|
||||||
@@ -124,9 +124,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()
|
||||||
|
@@ -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')
|
||||||
@@ -124,7 +122,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:')
|
||||||
@@ -136,7 +134,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
|
||||||
|
|
||||||
@@ -246,8 +243,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")
|
||||||
@@ -261,8 +258,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
|
||||||
@@ -326,7 +321,7 @@ func Test_WinScrolled()
|
|||||||
au WinScrolled * let g:amatch = str2nr(expand('<amatch>'))
|
au WinScrolled * let g:amatch = str2nr(expand('<amatch>'))
|
||||||
au WinScrolled * let g:afile = str2nr(expand('<afile>'))
|
au WinScrolled * let g:afile = str2nr(expand('<afile>'))
|
||||||
END
|
END
|
||||||
call writefile(lines, 'Xtest_winscrolled')
|
call writefile(lines, 'Xtest_winscrolled', 'D')
|
||||||
let buf = RunVimInTerminal('-S Xtest_winscrolled', {'rows': 6})
|
let buf = RunVimInTerminal('-S Xtest_winscrolled', {'rows': 6})
|
||||||
|
|
||||||
call term_sendkeys(buf, ":echo g:scrolled\<CR>")
|
call term_sendkeys(buf, ":echo g:scrolled\<CR>")
|
||||||
@@ -361,7 +356,6 @@ func Test_WinScrolled()
|
|||||||
call WaitForAssert({-> assert_match('^v:true ', term_getline(buf, 6))}, 1000)
|
call WaitForAssert({-> assert_match('^v:true ', term_getline(buf, 6))}, 1000)
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete('Xtest_winscrolled')
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_WinScrolled_mouse()
|
func Test_WinScrolled_mouse()
|
||||||
@@ -375,7 +369,7 @@ func Test_WinScrolled_mouse()
|
|||||||
let g:scrolled = 0
|
let g:scrolled = 0
|
||||||
au WinScrolled * let g:scrolled += 1
|
au WinScrolled * let g:scrolled += 1
|
||||||
END
|
END
|
||||||
call writefile(lines, 'Xtest_winscrolled_mouse')
|
call writefile(lines, 'Xtest_winscrolled_mouse', 'D')
|
||||||
let buf = RunVimInTerminal('-S Xtest_winscrolled_mouse', {'rows': 10})
|
let buf = RunVimInTerminal('-S Xtest_winscrolled_mouse', {'rows': 10})
|
||||||
|
|
||||||
" With the upper split focused, send a scroll-down event to the unfocused one.
|
" With the upper split focused, send a scroll-down event to the unfocused one.
|
||||||
@@ -392,7 +386,6 @@ func Test_WinScrolled_mouse()
|
|||||||
call WaitForAssert({-> assert_match('^2', term_getline(buf, 10))}, 1000)
|
call WaitForAssert({-> assert_match('^2', term_getline(buf, 10))}, 1000)
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete('Xtest_winscrolled_mouse')
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_WinScrolled_close_curwin()
|
func Test_WinScrolled_close_curwin()
|
||||||
@@ -405,7 +398,7 @@ func Test_WinScrolled_close_curwin()
|
|||||||
au WinScrolled * close
|
au WinScrolled * close
|
||||||
au VimLeave * call writefile(['123456'], 'Xtestout')
|
au VimLeave * call writefile(['123456'], 'Xtestout')
|
||||||
END
|
END
|
||||||
call writefile(lines, 'Xtest_winscrolled_close_curwin')
|
call writefile(lines, 'Xtest_winscrolled_close_curwin', 'D')
|
||||||
let buf = RunVimInTerminal('-S Xtest_winscrolled_close_curwin', {'rows': 6})
|
let buf = RunVimInTerminal('-S Xtest_winscrolled_close_curwin', {'rows': 6})
|
||||||
|
|
||||||
" This was using freed memory
|
" This was using freed memory
|
||||||
@@ -415,7 +408,6 @@ func Test_WinScrolled_close_curwin()
|
|||||||
|
|
||||||
call assert_equal(['123456'], readfile('Xtestout'))
|
call assert_equal(['123456'], readfile('Xtestout'))
|
||||||
|
|
||||||
call delete('Xtest_winscrolled_close_curwin')
|
|
||||||
call delete('Xtestout')
|
call delete('Xtestout')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -431,7 +423,7 @@ func Test_WinScrolled_long_wrapped()
|
|||||||
call setline(1, repeat('foo', height * width))
|
call setline(1, repeat('foo', height * width))
|
||||||
call cursor(1, height * width)
|
call cursor(1, height * width)
|
||||||
END
|
END
|
||||||
call writefile(lines, 'Xtest_winscrolled_long_wrapped')
|
call writefile(lines, 'Xtest_winscrolled_long_wrapped', 'D')
|
||||||
let buf = RunVimInTerminal('-S Xtest_winscrolled_long_wrapped', {'rows': 6})
|
let buf = RunVimInTerminal('-S Xtest_winscrolled_long_wrapped', {'rows': 6})
|
||||||
|
|
||||||
call term_sendkeys(buf, ":echo g:scrolled\<CR>")
|
call term_sendkeys(buf, ":echo g:scrolled\<CR>")
|
||||||
@@ -448,8 +440,6 @@ func Test_WinScrolled_long_wrapped()
|
|||||||
call term_sendkeys(buf, '$')
|
call term_sendkeys(buf, '$')
|
||||||
call term_sendkeys(buf, ":echo g:scrolled\<CR>")
|
call term_sendkeys(buf, ":echo g:scrolled\<CR>")
|
||||||
call WaitForAssert({-> assert_match('^3 ', term_getline(buf, 6))}, 1000)
|
call WaitForAssert({-> assert_match('^3 ', term_getline(buf, 6))}, 1000)
|
||||||
|
|
||||||
call delete('Xtest_winscrolled_long_wrapped')
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_WinClosed()
|
func Test_WinClosed()
|
||||||
@@ -772,13 +762,13 @@ func Test_autocmd_bufwipe_in_SessLoadPost()
|
|||||||
au VimLeave * call WriteErrors()
|
au VimLeave * call WriteErrors()
|
||||||
[CODE]
|
[CODE]
|
||||||
|
|
||||||
call writefile(content, 'Xvimrc')
|
call writefile(content, 'Xvimrc', 'D')
|
||||||
call system(GetVimCommand('Xvimrc') .. ' --not-a-term --noplugins -S Session.vim -c cq')
|
call system(GetVimCommand('Xvimrc') .. ' --not-a-term --noplugins -S Session.vim -c cq')
|
||||||
let errors = join(readfile('Xerrors'))
|
let errors = join(readfile('Xerrors'))
|
||||||
call assert_match('E814:', errors)
|
call assert_match('E814:', errors)
|
||||||
|
|
||||||
set swapfile
|
set swapfile
|
||||||
for file in ['Session.vim', 'Xvimrc', 'Xerrors']
|
for file in ['Session.vim', 'Xerrors']
|
||||||
call delete(file)
|
call delete(file)
|
||||||
endfor
|
endfor
|
||||||
endfunc
|
endfunc
|
||||||
@@ -795,11 +785,10 @@ func Test_autocmd_blast_badd()
|
|||||||
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())
|
call assert_match('OK', readfile('Xerrors')->join())
|
||||||
|
|
||||||
call delete('XblastBall')
|
|
||||||
call delete('Xerrors')
|
call delete('Xerrors')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -832,7 +821,7 @@ func Test_autocmd_bufwipe_in_SessLoadPost2()
|
|||||||
au VimLeave * call WriteErrors()
|
au VimLeave * call WriteErrors()
|
||||||
[CODE]
|
[CODE]
|
||||||
|
|
||||||
call writefile(content, 'Xvimrc')
|
call writefile(content, 'Xvimrc', 'D')
|
||||||
call system(GetVimCommand('Xvimrc') .. ' --not-a-term --noplugins -S Session.vim -c cq')
|
call system(GetVimCommand('Xvimrc') .. ' --not-a-term --noplugins -S Session.vim -c cq')
|
||||||
let errors = join(readfile('Xerrors'))
|
let errors = join(readfile('Xerrors'))
|
||||||
" This probably only ever matches on unix.
|
" This probably only ever matches on unix.
|
||||||
@@ -840,7 +829,7 @@ func Test_autocmd_bufwipe_in_SessLoadPost2()
|
|||||||
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', 'Xerrors']
|
||||||
call delete(file)
|
call delete(file)
|
||||||
endfor
|
endfor
|
||||||
endfunc
|
endfunc
|
||||||
@@ -1542,9 +1531,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
|
||||||
@@ -1566,9 +1555,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
|
||||||
|
|
||||||
@@ -1578,11 +1564,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
|
||||||
@@ -1604,8 +1590,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
|
||||||
|
|
||||||
@@ -1632,8 +1616,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
|
||||||
@@ -1659,8 +1643,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
|
||||||
@@ -1729,8 +1711,8 @@ 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
|
||||||
@@ -1746,15 +1728,13 @@ func Test_BufWritePre()
|
|||||||
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()
|
||||||
@@ -1773,15 +1753,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 --not-a-term -S Xtest')
|
call system(GetVimCommandClean() .. ' -N --not-a-term -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
|
||||||
|
|
||||||
@@ -1809,7 +1786,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
|
||||||
@@ -1884,7 +1861,6 @@ func Test_Cmd_Autocmds()
|
|||||||
au! FileWriteCmd
|
au! FileWriteCmd
|
||||||
au! FileAppendCmd
|
au! FileAppendCmd
|
||||||
%bwipe!
|
%bwipe!
|
||||||
call delete('Xxx')
|
|
||||||
enew!
|
enew!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -1909,7 +1885,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
|
||||||
@@ -1917,7 +1893,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
|
||||||
@@ -2324,7 +2299,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.
|
||||||
@@ -2342,7 +2317,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
|
||||||
|
|
||||||
@@ -2432,13 +2406,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()
|
||||||
@@ -2590,7 +2563,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
|
||||||
@@ -2714,7 +2687,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
|
||||||
|
|
||||||
@@ -2762,7 +2734,7 @@ 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 triggered once or
|
" Sometimes we loop to handle a K_IGNORE, SafeState may be triggered once or
|
||||||
@@ -2782,7 +2754,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()
|
||||||
@@ -3024,11 +2995,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
|
||||||
@@ -3041,11 +3012,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
|
||||||
|
@@ -703,6 +703,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 */
|
||||||
|
/**/
|
||||||
|
380,
|
||||||
/**/
|
/**/
|
||||||
379,
|
379,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user