Patch 9.0.0613
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().
Files:      src/testdir/test_source.vim


*** ../vim-9.0.0612/src/testdir/test_source.vim 2022-09-22 21:35:16.041424474 
+0100
--- src/testdir/test_source.vim 2022-09-28 10:41:52.081854022 +0100
***************
*** 6,12 ****
  func Test_source_autocmd()
    call writefile([
        \ 'let did_source = 1',
!       \ ], 'Xsourced')
    au SourcePre *source* let did_source_pre = 1
    au SourcePost *source* let did_source_post = 1
  
--- 6,12 ----
  func Test_source_autocmd()
    call writefile([
        \ 'let did_source = 1',
!       \ ], 'Xsourced', 'D')
    au SourcePre *source* let did_source_pre = 1
    au SourcePost *source* let did_source_post = 1
  
***************
*** 16,22 ****
    call assert_equal(g:did_source_pre, 1)
    call assert_equal(g:did_source_post, 1)
  
-   call delete('Xsourced')
    au! SourcePre
    au! SourcePost
    unlet g:did_source
--- 16,21 ----
***************
*** 42,53 ****
  
  func Test_source_sandbox()
    new
!   call writefile(["Ohello\<Esc>"], 'Xsourcehello')
    source! Xsourcehello | echo
    call assert_equal('hello', getline(1))
    call assert_fails('sandbox source! Xsourcehello', 'E48:')
    bwipe!
-   call delete('Xsourcehello')
  endfunc
  
  " When deleting a file and immediately creating a new one the inode may be
--- 41,51 ----
  
  func Test_source_sandbox()
    new
!   call writefile(["Ohello\<Esc>"], 'Xsourcehello', 'D')
    source! Xsourcehello | echo
    call assert_equal('hello', getline(1))
    call assert_fails('sandbox source! Xsourcehello', 'E48:')
    bwipe!
  endfunc
  
  " When deleting a file and immediately creating a new one the inode may be
***************
*** 63,72 ****
  
  " When sourcing a vim script, shebang should be ignored.
  func Test_source_ignore_shebang()
!   call writefile(['#!./xyzabc', 'let g:val=369'], 'Xsisfile.vim')
    source Xsisfile.vim
    call assert_equal(g:val, 369)
-   call delete('Xsisfile.vim')
  endfunc
  
  " Test for expanding <sfile> in an autocmd and for <slnum> and <sflnum>
--- 61,69 ----
  
  " When sourcing a vim script, shebang should be ignored.
  func Test_source_ignore_shebang()
!   call writefile(['#!./xyzabc', 'let g:val=369'], 'Xsisfile.vim', 'D')
    source Xsisfile.vim
    call assert_equal(g:val, 369)
  endfunc
  
  " Test for expanding <sfile> in an autocmd and for <slnum> and <sflnum>
***************
*** 82,93 ****
      let g:Sflnum = expand('<sflnum>')
      augroup! sfiletest
    [CODE]
!   call writefile(code, 'Xscript.vim')
    source Xscript.vim
    call assert_equal('Xscript.vim', g:Sfile)
    call assert_equal('7', g:Slnum)
    call assert_equal('8', g:Sflnum)
-   call delete('Xscript.vim')
  endfunc
  
  func Test_source_error()
--- 79,89 ----
      let g:Sflnum = expand('<sflnum>')
      augroup! sfiletest
    [CODE]
!   call writefile(code, 'Xscript.vim', 'D')
    source Xscript.vim
    call assert_equal('Xscript.vim', g:Sfile)
    call assert_equal('7', g:Slnum)
    call assert_equal('8', g:Sflnum)
  endfunc
  
  func Test_source_error()
***************
*** 105,118 ****
  " Test for sourcing a script recursively
  func Test_nested_script()
    CheckRunVimInTerminal
!   call writefile([':source! Xscript.vim', ''], 'Xscript.vim')
    let buf = RunVimInTerminal('', {'rows': 6})
    call term_wait(buf)
    call term_sendkeys(buf, ":set noruler\n")
    call term_sendkeys(buf, ":source! Xscript.vim\n")
    call term_wait(buf)
    call WaitForAssert({-> assert_match('E22: Scripts nested too deep\s*', 
term_getline(buf, 6))})
-   call delete('Xscript.vim')
    call StopVimInTerminal(buf)
  endfunc
  
--- 101,113 ----
  " Test for sourcing a script recursively
  func Test_nested_script()
    CheckRunVimInTerminal
!   call writefile([':source! Xscript.vim', ''], 'Xscript.vim', 'D')
    let buf = RunVimInTerminal('', {'rows': 6})
    call term_wait(buf)
    call term_sendkeys(buf, ":set noruler\n")
    call term_sendkeys(buf, ":source! Xscript.vim\n")
    call term_wait(buf)
    call WaitForAssert({-> assert_match('E22: Scripts nested too deep\s*', 
term_getline(buf, 6))})
    call StopVimInTerminal(buf)
  endfunc
  
***************
*** 285,298 ****
       let g:ScriptID3 = expand("<SID>")
       let g:Slnum3 = expand("<slnum>")
    END
!   call writefile(lines, 'Xscript')
    source Xscript
    call assert_true(g:ScriptID1 != g:ScriptID2)
    call assert_equal(g:ScriptID1, g:ScriptID3)
    call assert_equal('2', g:Slnum1)
    call assert_equal('1', g:Slnum2)
    call assert_equal('12', g:Slnum3)
-   call delete('Xscript')
  
    " test for sourcing a heredoc
    %d _
--- 280,292 ----
       let g:ScriptID3 = expand("<SID>")
       let g:Slnum3 = expand("<slnum>")
    END
!   call writefile(lines, 'Xscript', 'D')
    source Xscript
    call assert_true(g:ScriptID1 != g:ScriptID2)
    call assert_equal(g:ScriptID1, g:ScriptID3)
    call assert_equal('2', g:Slnum1)
    call assert_equal('1', g:Slnum2)
    call assert_equal('12', g:Slnum3)
  
    " test for sourcing a heredoc
    %d _
***************
*** 659,668 ****
        norm i0000000000000000000
        silent! so
    END
!   call writefile(lines, 'Xtest.vim')
    source Xtest.vim
    bwipe!
-   call delete('Xtest.vim')
  endfunc
  
  func Test_source_buffer_with_NUL_char()
--- 653,661 ----
        norm i0000000000000000000
        silent! so
    END
!   call writefile(lines, 'Xtest.vim', 'D')
    source Xtest.vim
    bwipe!
  endfunc
  
  func Test_source_buffer_with_NUL_char()
***************
*** 675,681 ****
    END
    " Can't have a NL in heredoc
    let lines += ["silent! vim9 echo [0 \<NL> ? 'a' : 'b']"]
!   call writefile(lines, 'XsourceNul', '')
    edit XsourceNul
    source
  
--- 668,674 ----
    END
    " Can't have a NL in heredoc
    let lines += ["silent! vim9 echo [0 \<NL> ? 'a' : 'b']"]
!   call writefile(lines, 'XsourceNul', 'D')
    edit XsourceNul
    source
  
*** ../vim-9.0.0612/src/version.c       2022-09-27 22:18:10.364276480 +0100
--- src/version.c       2022-09-28 10:44:14.553759258 +0100
***************
*** 701,702 ****
--- 701,704 ----
  {   /* Add new patch number below this line */
+ /**/
+     613,
  /**/

-- 
panic("Foooooooood fight!");
        -- In the kernel source aha1542.c, after detecting a bad segment list

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220928094623.8C2FE1C044A%40moolenaar.net.

Raspunde prin e-mail lui