mirror of
https://github.com/vim/vim.git
synced 2025-10-02 05:04:20 -04:00
patch 8.2.2169: Vim9: test leaves file behind
Problem: Vim9: test leaves file behind. Solution: Rename script files. (Dominique Pellé, closes #7511) Use try/finally.
This commit is contained in:
@@ -2412,7 +2412,7 @@ def Test_vim9_comment()
|
|||||||
'delcommand Echo',
|
'delcommand Echo',
|
||||||
])
|
])
|
||||||
CheckScriptSuccess([
|
CheckScriptSuccess([
|
||||||
'vim9script'
|
'vim9script',
|
||||||
'command Echo cd # comment',
|
'command Echo cd # comment',
|
||||||
'Echo',
|
'Echo',
|
||||||
'delcommand Echo',
|
'delcommand Echo',
|
||||||
@@ -2949,6 +2949,7 @@ def Test_restoring_cpo()
|
|||||||
endif
|
endif
|
||||||
delete('Xsourced')
|
delete('Xsourced')
|
||||||
delete('Xclose')
|
delete('Xclose')
|
||||||
|
delete('Xdone')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
|
||||||
|
@@ -5,13 +5,18 @@ let s:sequence = 1
|
|||||||
|
|
||||||
" Check that "lines" inside a ":def" function has no error.
|
" Check that "lines" inside a ":def" function has no error.
|
||||||
func CheckDefSuccess(lines)
|
func CheckDefSuccess(lines)
|
||||||
let fname = 'Xdef' .. s:sequence
|
let cwd = getcwd()
|
||||||
|
let fname = 'XdefSuccess' .. s:sequence
|
||||||
let s:sequence += 1
|
let s:sequence += 1
|
||||||
call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], fname)
|
call writefile(['def Func()'] + a:lines + ['enddef', 'defcompile'], fname)
|
||||||
exe 'so ' .. fname
|
try
|
||||||
call Func()
|
exe 'so ' .. fname
|
||||||
delfunc! Func
|
call Func()
|
||||||
call delete(fname)
|
delfunc! Func
|
||||||
|
finally
|
||||||
|
call chdir(cwd)
|
||||||
|
call delete(fname)
|
||||||
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Check that "lines" inside ":def" results in an "error" message.
|
" Check that "lines" inside ":def" results in an "error" message.
|
||||||
@@ -19,12 +24,17 @@ endfunc
|
|||||||
" Add a line before and after to make it less likely that the line number is
|
" Add a line before and after to make it less likely that the line number is
|
||||||
" accidentally correct.
|
" accidentally correct.
|
||||||
func CheckDefFailure(lines, error, lnum = -3)
|
func CheckDefFailure(lines, error, lnum = -3)
|
||||||
let fname = 'Xdef' .. s:sequence
|
let cwd = getcwd()
|
||||||
call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef', 'defcompile'], fname)
|
let fname = 'XdefFailure' .. s:sequence
|
||||||
call assert_fails('so ' .. fname, a:error, a:lines, a:lnum + 1)
|
|
||||||
delfunc! Func
|
|
||||||
call delete(fname)
|
|
||||||
let s:sequence += 1
|
let s:sequence += 1
|
||||||
|
call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef', 'defcompile'], fname)
|
||||||
|
try
|
||||||
|
call assert_fails('so ' .. fname, a:error, a:lines, a:lnum + 1)
|
||||||
|
finally
|
||||||
|
call chdir(cwd)
|
||||||
|
call delete(fname)
|
||||||
|
delfunc! Func
|
||||||
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Check that "lines" inside ":def" results in an "error" message when executed.
|
" Check that "lines" inside ":def" results in an "error" message when executed.
|
||||||
@@ -32,29 +42,44 @@ endfunc
|
|||||||
" Add a line before and after to make it less likely that the line number is
|
" Add a line before and after to make it less likely that the line number is
|
||||||
" accidentally correct.
|
" accidentally correct.
|
||||||
func CheckDefExecFailure(lines, error, lnum = -3)
|
func CheckDefExecFailure(lines, error, lnum = -3)
|
||||||
let fname = 'Xdef' .. s:sequence
|
let cwd = getcwd()
|
||||||
|
let fname = 'XdefExecFailure' .. s:sequence
|
||||||
let s:sequence += 1
|
let s:sequence += 1
|
||||||
call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef'], fname)
|
call writefile(['def Func()', '# comment'] + a:lines + ['#comment', 'enddef'], fname)
|
||||||
exe 'so ' .. fname
|
try
|
||||||
call assert_fails('call Func()', a:error, a:lines, a:lnum + 1)
|
exe 'so ' .. fname
|
||||||
delfunc! Func
|
call assert_fails('call Func()', a:error, a:lines, a:lnum + 1)
|
||||||
call delete(fname)
|
finally
|
||||||
|
call chdir(cwd)
|
||||||
|
call delete(fname)
|
||||||
|
delfunc! Func
|
||||||
|
endtry
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
def CheckScriptFailure(lines: list<string>, error: string, lnum = -3)
|
def CheckScriptFailure(lines: list<string>, error: string, lnum = -3)
|
||||||
var fname = 'Xdef' .. s:sequence
|
var cwd = getcwd()
|
||||||
|
var fname = 'XScriptFailure' .. s:sequence
|
||||||
s:sequence += 1
|
s:sequence += 1
|
||||||
writefile(lines, fname)
|
writefile(lines, fname)
|
||||||
assert_fails('so ' .. fname, error, lines, lnum)
|
try
|
||||||
delete(fname)
|
assert_fails('so ' .. fname, error, lines, lnum)
|
||||||
|
finally
|
||||||
|
chdir(cwd)
|
||||||
|
delete(fname)
|
||||||
|
endtry
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def CheckScriptSuccess(lines: list<string>)
|
def CheckScriptSuccess(lines: list<string>)
|
||||||
var fname = 'Xdef' .. s:sequence
|
var cwd = getcwd()
|
||||||
|
var fname = 'XScriptSuccess' .. s:sequence
|
||||||
s:sequence += 1
|
s:sequence += 1
|
||||||
writefile(lines, fname)
|
writefile(lines, fname)
|
||||||
exe 'so ' .. fname
|
try
|
||||||
delete(fname)
|
exe 'so ' .. fname
|
||||||
|
finally
|
||||||
|
chdir(cwd)
|
||||||
|
delete(fname)
|
||||||
|
endtry
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def CheckDefAndScriptSuccess(lines: list<string>)
|
def CheckDefAndScriptSuccess(lines: list<string>)
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
2169,
|
||||||
/**/
|
/**/
|
||||||
2168,
|
2168,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user