mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 9.0.0613: running source tests leaves file behind
Problem: Running source tests leaves file behind. Solution: Add the "D" flag to writefile(). (Dominique Pellé, closes #11243) Also do this for other writefile() calls and drop delete().
This commit is contained in:
committed by
Bram Moolenaar
parent
47da934844
commit
caa1d19da1
@@ -6,7 +6,7 @@ source view_util.vim
|
|||||||
func Test_source_autocmd()
|
func Test_source_autocmd()
|
||||||
call writefile([
|
call writefile([
|
||||||
\ 'let did_source = 1',
|
\ 'let did_source = 1',
|
||||||
\ ], 'Xsourced')
|
\ ], 'Xsourced', 'D')
|
||||||
au SourcePre *source* let did_source_pre = 1
|
au SourcePre *source* let did_source_pre = 1
|
||||||
au SourcePost *source* let did_source_post = 1
|
au SourcePost *source* let did_source_post = 1
|
||||||
|
|
||||||
@@ -16,7 +16,6 @@ func Test_source_autocmd()
|
|||||||
call assert_equal(g:did_source_pre, 1)
|
call assert_equal(g:did_source_pre, 1)
|
||||||
call assert_equal(g:did_source_post, 1)
|
call assert_equal(g:did_source_post, 1)
|
||||||
|
|
||||||
call delete('Xsourced')
|
|
||||||
au! SourcePre
|
au! SourcePre
|
||||||
au! SourcePost
|
au! SourcePost
|
||||||
unlet g:did_source
|
unlet g:did_source
|
||||||
@@ -42,12 +41,11 @@ endfunc
|
|||||||
|
|
||||||
func Test_source_sandbox()
|
func Test_source_sandbox()
|
||||||
new
|
new
|
||||||
call writefile(["Ohello\<Esc>"], 'Xsourcehello')
|
call writefile(["Ohello\<Esc>"], 'Xsourcehello', 'D')
|
||||||
source! Xsourcehello | echo
|
source! Xsourcehello | echo
|
||||||
call assert_equal('hello', getline(1))
|
call assert_equal('hello', getline(1))
|
||||||
call assert_fails('sandbox source! Xsourcehello', 'E48:')
|
call assert_fails('sandbox source! Xsourcehello', 'E48:')
|
||||||
bwipe!
|
bwipe!
|
||||||
call delete('Xsourcehello')
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" When deleting a file and immediately creating a new one the inode may be
|
" When deleting a file and immediately creating a new one the inode may be
|
||||||
@@ -63,10 +61,9 @@ endfunc
|
|||||||
|
|
||||||
" When sourcing a vim script, shebang should be ignored.
|
" When sourcing a vim script, shebang should be ignored.
|
||||||
func Test_source_ignore_shebang()
|
func Test_source_ignore_shebang()
|
||||||
call writefile(['#!./xyzabc', 'let g:val=369'], 'Xsisfile.vim')
|
call writefile(['#!./xyzabc', 'let g:val=369'], 'Xsisfile.vim', 'D')
|
||||||
source Xsisfile.vim
|
source Xsisfile.vim
|
||||||
call assert_equal(g:val, 369)
|
call assert_equal(g:val, 369)
|
||||||
call delete('Xsisfile.vim')
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for expanding <sfile> in an autocmd and for <slnum> and <sflnum>
|
" Test for expanding <sfile> in an autocmd and for <slnum> and <sflnum>
|
||||||
@@ -82,12 +79,11 @@ func Test_source_autocmd_sfile()
|
|||||||
let g:Sflnum = expand('<sflnum>')
|
let g:Sflnum = expand('<sflnum>')
|
||||||
augroup! sfiletest
|
augroup! sfiletest
|
||||||
[CODE]
|
[CODE]
|
||||||
call writefile(code, 'Xscript.vim')
|
call writefile(code, 'Xscript.vim', 'D')
|
||||||
source Xscript.vim
|
source Xscript.vim
|
||||||
call assert_equal('Xscript.vim', g:Sfile)
|
call assert_equal('Xscript.vim', g:Sfile)
|
||||||
call assert_equal('7', g:Slnum)
|
call assert_equal('7', g:Slnum)
|
||||||
call assert_equal('8', g:Sflnum)
|
call assert_equal('8', g:Sflnum)
|
||||||
call delete('Xscript.vim')
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_source_error()
|
func Test_source_error()
|
||||||
@@ -105,14 +101,13 @@ endfunc
|
|||||||
" Test for sourcing a script recursively
|
" Test for sourcing a script recursively
|
||||||
func Test_nested_script()
|
func Test_nested_script()
|
||||||
CheckRunVimInTerminal
|
CheckRunVimInTerminal
|
||||||
call writefile([':source! Xscript.vim', ''], 'Xscript.vim')
|
call writefile([':source! Xscript.vim', ''], 'Xscript.vim', 'D')
|
||||||
let buf = RunVimInTerminal('', {'rows': 6})
|
let buf = RunVimInTerminal('', {'rows': 6})
|
||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
call term_sendkeys(buf, ":set noruler\n")
|
call term_sendkeys(buf, ":set noruler\n")
|
||||||
call term_sendkeys(buf, ":source! Xscript.vim\n")
|
call term_sendkeys(buf, ":source! Xscript.vim\n")
|
||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
call WaitForAssert({-> assert_match('E22: Scripts nested too deep\s*', term_getline(buf, 6))})
|
call WaitForAssert({-> assert_match('E22: Scripts nested too deep\s*', term_getline(buf, 6))})
|
||||||
call delete('Xscript.vim')
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -285,14 +280,13 @@ func Test_source_buffer()
|
|||||||
let g:ScriptID3 = expand("<SID>")
|
let g:ScriptID3 = expand("<SID>")
|
||||||
let g:Slnum3 = expand("<slnum>")
|
let g:Slnum3 = expand("<slnum>")
|
||||||
END
|
END
|
||||||
call writefile(lines, 'Xscript')
|
call writefile(lines, 'Xscript', 'D')
|
||||||
source Xscript
|
source Xscript
|
||||||
call assert_true(g:ScriptID1 != g:ScriptID2)
|
call assert_true(g:ScriptID1 != g:ScriptID2)
|
||||||
call assert_equal(g:ScriptID1, g:ScriptID3)
|
call assert_equal(g:ScriptID1, g:ScriptID3)
|
||||||
call assert_equal('2', g:Slnum1)
|
call assert_equal('2', g:Slnum1)
|
||||||
call assert_equal('1', g:Slnum2)
|
call assert_equal('1', g:Slnum2)
|
||||||
call assert_equal('12', g:Slnum3)
|
call assert_equal('12', g:Slnum3)
|
||||||
call delete('Xscript')
|
|
||||||
|
|
||||||
" test for sourcing a heredoc
|
" test for sourcing a heredoc
|
||||||
%d _
|
%d _
|
||||||
@@ -659,10 +653,9 @@ func Test_source_buffer_long_line()
|
|||||||
norm i0000000000000000000
|
norm i0000000000000000000
|
||||||
silent! so
|
silent! so
|
||||||
END
|
END
|
||||||
call writefile(lines, 'Xtest.vim')
|
call writefile(lines, 'Xtest.vim', 'D')
|
||||||
source Xtest.vim
|
source Xtest.vim
|
||||||
bwipe!
|
bwipe!
|
||||||
call delete('Xtest.vim')
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_source_buffer_with_NUL_char()
|
func Test_source_buffer_with_NUL_char()
|
||||||
@@ -675,7 +668,7 @@ func Test_source_buffer_with_NUL_char()
|
|||||||
END
|
END
|
||||||
" Can't have a NL in heredoc
|
" Can't have a NL in heredoc
|
||||||
let lines += ["silent! vim9 echo [0 \<NL> ? 'a' : 'b']"]
|
let lines += ["silent! vim9 echo [0 \<NL> ? 'a' : 'b']"]
|
||||||
call writefile(lines, 'XsourceNul', '')
|
call writefile(lines, 'XsourceNul', 'D')
|
||||||
edit XsourceNul
|
edit XsourceNul
|
||||||
source
|
source
|
||||||
|
|
||||||
|
@@ -699,6 +699,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 */
|
||||||
|
/**/
|
||||||
|
613,
|
||||||
/**/
|
/**/
|
||||||
612,
|
612,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user