Skip to content

Commit f4f79b8

Browse files
committed
patch 7.4.1179
Problem: test_writefile and test_viml do not delete the tempfile. Solution: Delete the tempfile. (Charles Cooper) Add DeleteTheScript().
1 parent 767d8c1 commit f4f79b8

3 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/testdir/test_viml.vim

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,26 @@ endfunction
5555
" ExecAsScript - Source a temporary script made from a function. {{{2
5656
"
5757
" Make a temporary script file from the function a:funcname, ":source" it, and
58-
" delete it afterwards.
58+
" delete it afterwards. However, if an exception is thrown the file may remain,
59+
" the caller should call DeleteTheScript() afterwards.
60+
let s:script_name = ''
5961
function! ExecAsScript(funcname)
6062
" Make a script from the function passed as argument.
61-
let script = MakeScript(a:funcname)
63+
let s:script_name = MakeScript(a:funcname)
6264

6365
" Source and delete the script.
64-
exec "source" script
65-
call delete(script)
66+
exec "source" s:script_name
67+
call delete(s:script_name)
68+
let s:script_name = ''
6669
endfunction
6770

71+
function! DeleteTheScript()
72+
if s:script_name
73+
call delete(s:script_name)
74+
let s:script_name = ''
75+
endif
76+
endfunc
77+
6878
com! -nargs=1 -bar ExecAsScript call ExecAsScript(<f-args>)
6979

7080

@@ -143,6 +153,7 @@ func Test_endwhile_script()
143153
XpathINIT
144154
ExecAsScript T1_F
145155
Xpath 'F'
156+
call DeleteTheScript()
146157

147158
try
148159
ExecAsScript T1_G
@@ -152,6 +163,7 @@ func Test_endwhile_script()
152163
Xpath 'x'
153164
endtry
154165
Xpath 'G'
166+
call DeleteTheScript()
155167

156168
call assert_equal('abcFhijxG', g:Xpath)
157169
endfunc
@@ -260,6 +272,7 @@ function Test_finish()
260272
XpathINIT
261273
ExecAsScript T4_F
262274
Xpath '5'
275+
call DeleteTheScript()
263276

264277
call assert_equal('ab3e3b2c25', g:Xpath)
265278
endfunction

src/testdir/test_writefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ STARTTEST
1313
:$put =readfile(f)
1414
:1 delete _
1515
:w! test.out
16+
:call delete(f)
1617
:qa!
1718
ENDTEST
1819

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,8 @@ static char *(features[]) =
746746

747747
static int included_patches[] =
748748
{ /* Add new patch number below this line */
749+
/**/
750+
1179,
749751
/**/
750752
1178,
751753
/**/

0 commit comments

Comments
 (0)