]> granicus.if.org Git - vim/commitdiff
patch 7.4.1179 v7.4.1179
authorBram Moolenaar <Bram@vim.org>
Mon, 25 Jan 2016 19:38:30 +0000 (20:38 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 25 Jan 2016 19:38:30 +0000 (20:38 +0100)
Problem:    test_writefile and test_viml do not delete the tempfile.
Solution:   Delete the tempfile. (Charles Cooper)  Add DeleteTheScript().

src/testdir/test_viml.vim
src/testdir/test_writefile.in
src/version.c

index 6b2b6b988b084875eab1ff9ee7fd6ca2163689cc..3c140c84d73f73066f7ff95a1f53d971e8aa4e14 100644 (file)
@@ -55,16 +55,26 @@ endfunction
 " ExecAsScript - Source a temporary script made from a function.           {{{2
 "
 " Make a temporary script file from the function a:funcname, ":source" it, and
-" delete it afterwards.
+" delete it afterwards.  However, if an exception is thrown the file may remain,
+" the caller should call DeleteTheScript() afterwards.
+let s:script_name = ''
 function! ExecAsScript(funcname)
     " Make a script from the function passed as argument.
-    let script = MakeScript(a:funcname)
+    let s:script_name = MakeScript(a:funcname)
 
     " Source and delete the script.
-    exec "source" script
-    call delete(script)
+    exec "source" s:script_name
+    call delete(s:script_name)
+    let s:script_name = ''
 endfunction
 
+function! DeleteTheScript()
+    if s:script_name
+       call delete(s:script_name)
+       let s:script_name = ''
+    endif
+endfunc
+
 com! -nargs=1 -bar ExecAsScript call ExecAsScript(<f-args>)
 
 
@@ -143,6 +153,7 @@ func Test_endwhile_script()
   XpathINIT
   ExecAsScript T1_F
   Xpath 'F'
+  call DeleteTheScript()
 
   try
     ExecAsScript T1_G
@@ -152,6 +163,7 @@ func Test_endwhile_script()
     Xpath 'x'
   endtry
   Xpath 'G'
+  call DeleteTheScript()
 
   call assert_equal('abcFhijxG', g:Xpath)
 endfunc
@@ -260,6 +272,7 @@ function Test_finish()
     XpathINIT
     ExecAsScript T4_F
     Xpath '5'
+    call DeleteTheScript()
 
     call assert_equal('ab3e3b2c25', g:Xpath)
 endfunction
index f2dc7d50bbda4dfb58926a6a811e2b1dbef6db1f..6b354c510a3d9704d784c8c3d3fc35a709f19380 100644 (file)
@@ -13,6 +13,7 @@ STARTTEST
 :$put =readfile(f)
 :1 delete _
 :w! test.out
+:call delete(f)
 :qa!
 ENDTEST
 
index 0a0bc1d179d551adc38483d0650b4f8433254b8b..073f551dd12e0171e8c0cbdec138bfe90566358a 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1179,
 /**/
     1178,
 /**/