patch 9.0.0525: manually deleting temp test files
Problem: Manually deleting temp test files.
Solution: Add the 'D' flag to writefile().
diff --git a/src/testdir/test_debugger.vim b/src/testdir/test_debugger.vim
index e873b77..61cd5c9 100644
--- a/src/testdir/test_debugger.vim
+++ b/src/testdir/test_debugger.vim
@@ -81,10 +81,10 @@
endfor
enddef
END
- call writefile(lines, 'Xtest.vim')
+ call writefile(lines, 'XtestDebug.vim', 'D')
" Start Vim in a terminal
- let buf = RunVimInTerminal('-S Xtest.vim', {})
+ let buf = RunVimInTerminal('-S XtestDebug.vim', {})
" Start the Vim debugger
call RunDbgCmd(buf, ':debug echo Foo()', ['cmd: echo Foo()'])
@@ -343,19 +343,18 @@
let var3 = 30
let var4 = 40
END
- call writefile(lines, 'Xtest.vim')
+ call writefile(lines, 'XdebugBreakadd.vim', 'D')
" Start Vim in a terminal
- let buf = RunVimInTerminal('Xtest.vim', {})
- call RunDbgCmd(buf, ':breakadd file 2 Xtest.vim')
+ let buf = RunVimInTerminal('XdebugBreakadd.vim', {})
+ call RunDbgCmd(buf, ':breakadd file 2 XdebugBreakadd.vim')
call RunDbgCmd(buf, ':4 | breakadd here')
- call RunDbgCmd(buf, ':source Xtest.vim', ['line 2: let var2 = 20'])
+ call RunDbgCmd(buf, ':source XdebugBreakadd.vim', ['line 2: let var2 = 20'])
call RunDbgCmd(buf, 'cont', ['line 4: let var4 = 40'])
call RunDbgCmd(buf, 'cont')
call StopVimInTerminal(buf)
- call delete('Xtest.vim')
%bw!
call assert_fails('breakadd here', 'E32:')
@@ -369,31 +368,30 @@
let lines =<< trim END
let g:Xtest_var += 1
END
- call writefile(lines, 'Xtest.vim')
+ call writefile(lines, 'XdebugBreakExpr.vim', 'D')
" Start Vim in a terminal
- let buf = RunVimInTerminal('Xtest.vim', {})
+ let buf = RunVimInTerminal('XdebugBreakExpr.vim', {})
call RunDbgCmd(buf, ':let g:Xtest_var = 10')
call RunDbgCmd(buf, ':breakadd expr g:Xtest_var')
call RunDbgCmd(buf, ':source %')
- let expected =<< eval trim END
+ let expected =<< trim eval END
Oldval = "10"
Newval = "11"
- {fnamemodify('Xtest.vim', ':p')}
+ {fnamemodify('XdebugBreakExpr.vim', ':p')}
line 1: let g:Xtest_var += 1
END
call RunDbgCmd(buf, ':source %', expected)
call RunDbgCmd(buf, 'cont')
- let expected =<< eval trim END
+ let expected =<< trim eval END
Oldval = "11"
Newval = "12"
- {fnamemodify('Xtest.vim', ':p')}
+ {fnamemodify('XdebugBreakExpr.vim', ':p')}
line 1: let g:Xtest_var += 1
END
call RunDbgCmd(buf, ':source %', expected)
call StopVimInTerminal(buf)
- call delete('Xtest.vim')
endfunc
def Test_Debugger_breakadd_vim9_expr()
@@ -406,10 +404,10 @@
endfunc
breakdel *
END
- writefile(lines, 'Xtest.vim')
+ writefile(lines, 'XdebugBreak9expr.vim', 'D')
# Start Vim in a terminal
- var buf = g:RunVimInTerminal('-S Xtest.vim', {wait_for_ruler: 0})
+ var buf = g:RunVimInTerminal('-S XdebugBreak9expr.vim', {wait_for_ruler: 0})
call g:TermWait(buf, g:RunningWithValgrind() ? 1000 : 50)
# Despite the failure the functions are defined
@@ -419,7 +417,6 @@
['function LaterFunc()', 'endfunction'], {match: 'pattern'})
call g:StopVimInTerminal(buf)
- call delete('Xtest.vim')
enddef
def Test_Debugger_break_at_return()
@@ -432,17 +429,16 @@
enddef
breakadd func GetNum
END
- writefile(lines, 'Xtest.vim')
+ writefile(lines, 'XdebugBreakRet.vim', 'D')
# Start Vim in a terminal
- var buf = g:RunVimInTerminal('-S Xtest.vim', {wait_for_ruler: 0})
+ var buf = g:RunVimInTerminal('-S XdebugBreakRet.vim', {wait_for_ruler: 0})
call g:TermWait(buf, g:RunningWithValgrind() ? 1000 : 50)
g:RunDbgCmd(buf, ':call GetNum()',
['line 1: return 1 + 2 + 3'], {match: 'pattern'})
call g:StopVimInTerminal(buf)
- call delete('Xtest.vim')
enddef
func Test_Backtrace_Through_Source()
@@ -461,7 +457,7 @@
call CallAFunction()
endfunc
END
- call writefile(file1, 'Xtest1.vim')
+ call writefile(file1, 'Xtest1.vim', 'D')
let file2 =<< trim END
func DoAThing()
@@ -474,7 +470,7 @@
call File2Function()
END
- call writefile(file2, 'Xtest2.vim')
+ call writefile(file2, 'Xtest2.vim', 'D')
let buf = RunVimInTerminal('-S Xtest1.vim', {})
@@ -616,8 +612,6 @@
\ 'line 1: call DoAThing()'])
call StopVimInTerminal(buf)
- call delete('Xtest1.vim')
- call delete('Xtest2.vim')
endfunc
func Test_Backtrace_Autocmd()
@@ -638,7 +632,7 @@
au User TestGlobalFunction :call GlobalFunction() | echo "Done"
END
- call writefile(file1, 'Xtest1.vim')
+ call writefile(file1, 'Xtest1.vim', 'D')
let file2 =<< trim END
func DoAThing()
@@ -651,7 +645,7 @@
call File2Function()
END
- call writefile(file2, 'Xtest2.vim')
+ call writefile(file2, 'Xtest2.vim', 'D')
let buf = RunVimInTerminal('-S Xtest1.vim', {})
@@ -871,8 +865,6 @@
\ 'cmd: echo "Done"'])
call StopVimInTerminal(buf)
- call delete('Xtest1.vim')
- call delete('Xtest2.vim')
endfunc
func Test_Backtrace_CmdLine()
@@ -893,7 +885,7 @@
au User TestGlobalFunction :call GlobalFunction() | echo "Done"
END
- call writefile(file1, 'Xtest1.vim')
+ call writefile(file1, 'Xtest1.vim', 'D')
let file2 =<< trim END
func DoAThing()
@@ -906,7 +898,7 @@
call File2Function()
END
- call writefile(file2, 'Xtest2.vim')
+ call writefile(file2, 'Xtest2.vim', 'D')
let buf = RunVimInTerminal(
\ '-S Xtest1.vim -c "debug call GlobalFunction()"',
@@ -932,8 +924,6 @@
\ 'line 1: call CallAFunction()'])
call StopVimInTerminal(buf)
- call delete('Xtest1.vim')
- call delete('Xtest2.vim')
endfunc
func Test_Backtrace_DefFunction()
@@ -958,7 +948,7 @@
defcompile
END
- call writefile(file1, 'Xtest1.vim')
+ call writefile(file1, 'Xtest1.vim', 'D')
let file2 =<< trim END
vim9script
@@ -976,7 +966,7 @@
defcompile
File2Function()
END
- call writefile(file2, 'Xtest2.vim')
+ call writefile(file2, 'Xtest2.vim', 'D')
let buf = RunVimInTerminal('-S Xtest1.vim', {})
@@ -1027,8 +1017,6 @@
\ #{match: 'pattern'})
call StopVimInTerminal(buf)
- call delete('Xtest1.vim')
- call delete('Xtest2.vim')
endfunc
func Test_DefFunction_expr()
@@ -1042,14 +1030,13 @@
enddef
defcompile
END
- call writefile(file3, 'Xtest3.vim')
+ call writefile(file3, 'Xtest3.vim', 'D')
let buf = RunVimInTerminal('-S Xtest3.vim', {})
call RunDbgCmd(buf, ':breakadd expr g:someVar')
call RunDbgCmd(buf, ':call g:ChangeVar()', ['Oldval = "''foo''"', 'Newval = "''bar''"', 'function ChangeVar', 'line 2: echo "changed"'])
call StopVimInTerminal(buf)
- call delete('Xtest3.vim')
endfunc
func Test_debug_def_and_legacy_function()
@@ -1078,7 +1065,7 @@
breakadd func 2 g:SomeFunc
END
- call writefile(file, 'XtestDebug.vim')
+ call writefile(file, 'XtestDebug.vim', 'D')
let buf = RunVimInTerminal('-S XtestDebug.vim', {})
@@ -1095,7 +1082,6 @@
call RunDbgCmd(buf, 'cont')
call StopVimInTerminal(buf)
- call delete('XtestDebug.vim')
endfunc
func Test_debug_def_function()
@@ -1151,7 +1137,7 @@
| eval 2 + 3
enddef
END
- call writefile(file, 'Xtest.vim')
+ call writefile(file, 'Xtest.vim', 'D')
let buf = RunVimInTerminal('-S Xtest.vim', {})
@@ -1218,7 +1204,6 @@
call RunDbgCmd(buf, 'cont')
call StopVimInTerminal(buf)
- call delete('Xtest.vim')
endfunc
func Test_debug_def_function_with_lambda()
@@ -1232,7 +1217,7 @@
enddef
breakadd func 2 g:Func
END
- call writefile(lines, 'XtestLambda.vim')
+ call writefile(lines, 'XtestLambda.vim', 'D')
let buf = RunVimInTerminal('-S XtestLambda.vim', {})
@@ -1245,7 +1230,6 @@
call RunDbgCmd(buf, 'cont')
call StopVimInTerminal(buf)
- call delete('XtestLambda.vim')
endfunc
func Test_debug_backtrace_level()
@@ -1263,7 +1247,7 @@
call s:File1Func( 'arg1' )
END
- call writefile(lines, 'Xtest1.vim')
+ call writefile(lines, 'Xtest1.vim', 'D')
let lines =<< trim END
let s:file2_var = 'file2'
@@ -1276,7 +1260,7 @@
call s:File2Func( 'arg2' )
END
- call writefile(lines, 'Xtest2.vim')
+ call writefile(lines, 'Xtest2.vim', 'D')
let file1 = getcwd() .. '/Xtest1.vim'
let file2 = getcwd() .. '/Xtest2.vim'
@@ -1437,8 +1421,6 @@
call RunDbgCmd(buf, 'cont')
call StopVimInTerminal(buf)
- call delete('Xtest1.vim')
- call delete('Xtest2.vim')
endfunc
" Test for setting a breakpoint on a :endif where the :if condition is false
diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim
index 8cb5060..9308d04 100644
--- a/src/testdir/test_diffmode.vim
+++ b/src/testdir/test_diffmode.vim
Binary files differ
diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim
index 8420b53..a8a55a7 100644
--- a/src/testdir/test_digraph.vim
+++ b/src/testdir/test_digraph.vim
@@ -494,9 +494,8 @@
func Test_loadkeymap_error()
CheckFeature keymap
call assert_fails('loadkeymap', 'E105:')
- call writefile(['loadkeymap', 'a'], 'Xkeymap')
+ call writefile(['loadkeymap', 'a'], 'Xkeymap', 'D')
call assert_fails('source Xkeymap', 'E791:')
- call delete('Xkeymap')
endfunc
" Test for the characters displayed on the screen when entering a digraph
diff --git a/src/testdir/test_display.vim b/src/testdir/test_display.vim
index 9fd0126..af18b7e 100644
--- a/src/testdir/test_display.vim
+++ b/src/testdir/test_display.vim
@@ -78,7 +78,7 @@
set t_cs=
set laststatus=2
END
- call writefile(lines, 'Xtestscroll')
+ call writefile(lines, 'Xtestscroll', 'D')
let buf = RunVimInTerminal('-S Xtestscroll', #{rows: 10})
call VerifyScreenDump(buf, 'Test_scroll_no_region_1', {})
@@ -102,7 +102,6 @@
" clean up
call StopVimInTerminal(buf)
- call delete('Xtestscroll')
endfunc
func Test_display_listchars_precedes()
@@ -172,14 +171,13 @@
exe ":norm! o\<esc>110ia\<esc>"
END
let filename = 'Xdrawscreen'
- call writefile(lines, filename)
+ call writefile(lines, filename, 'D')
let buf = RunVimInTerminal('-S '.filename, #{rows: 5, cols: 50})
call term_sendkeys(buf, "k")
call VerifyScreenDump(buf, 'Test_winline_rnu', {})
" clean up
call StopVimInTerminal(buf)
- call delete(filename)
endfunc
" check a long file name does not result in the hit-enter prompt
@@ -187,28 +185,27 @@
CheckScreendump
let longName = 'x'->repeat(min([&columns, 255]))
- call writefile([], longName)
+ call writefile([], longName, 'D')
let buf = RunVimInTerminal('-N -u NONE ' .. longName, #{rows: 8})
call VerifyScreenDump(buf, 'Test_long_file_name_1', {})
" clean up
call StopVimInTerminal(buf)
- call delete(longName)
endfunc
func Test_unprintable_fileformats()
CheckScreendump
- call writefile(["unix\r", "two"], 'Xunix.txt')
- call writefile(["mac\r", "two"], 'Xmac.txt')
+ call writefile(["unix\r", "two"], 'Xunix.txt', 'D')
+ call writefile(["mac\r", "two"], 'Xmac.txt', 'D')
let lines =<< trim END
edit Xunix.txt
split Xmac.txt
edit ++ff=mac
END
let filename = 'Xunprintable'
- call writefile(lines, filename)
+ call writefile(lines, filename, 'D')
let buf = RunVimInTerminal('-S '.filename, #{rows: 9, cols: 50})
call VerifyScreenDump(buf, 'Test_display_unprintable_01', {})
call term_sendkeys(buf, "\<C-W>\<C-W>\<C-L>")
@@ -216,9 +213,6 @@
" clean up
call StopVimInTerminal(buf)
- call delete('Xunix.txt')
- call delete('Xmac.txt')
- call delete(filename)
endfunc
" Test for scrolling that modifies buffer during visual block
@@ -233,7 +227,7 @@
END
let filename = 'Xvisualblockmodifiedscroll'
- call writefile(lines, filename)
+ call writefile(lines, filename, 'D')
let buf = RunVimInTerminal('-S '.filename, #{rows: 7})
call term_sendkeys(buf, "V\<C-D>\<C-D>")
@@ -241,7 +235,6 @@
call VerifyScreenDump(buf, 'Test_display_visual_block_scroll', {})
call StopVimInTerminal(buf)
- call delete(filename)
endfunc
func Test_display_scroll_at_topline()
@@ -267,14 +260,13 @@
call sign_place(2, 'bar', 'foo', bufnr(), { 'lnum': 1 })
autocmd CursorMoved * if getcurpos()[1] == 2 | call sign_unplace('bar', { 'id': 1 }) | endif
END
- call writefile(lines, 'XupdateVisual.vim')
+ call writefile(lines, 'XupdateVisual.vim', 'D')
let buf = RunVimInTerminal('-S XupdateVisual.vim', #{rows: 8, cols: 60})
call term_sendkeys(buf, "VG7kk")
call VerifyScreenDump(buf, 'Test_display_scroll_update_visual', {})
call StopVimInTerminal(buf)
- call delete('XupdateVisual.vim')
endfunc
" Test for 'eob' (EndOfBuffer) item in 'fillchars'
@@ -373,7 +365,7 @@
call setline(1, ['window 4']->repeat(3))
setlocal fillchars=stl:4,stlnc:d,vert:>,eob:o
END
- call writefile(lines, 'Xdisplayfillchars')
+ call writefile(lines, 'Xdisplayfillchars', 'D')
let buf = RunVimInTerminal('-S Xdisplayfillchars', #{rows: 12})
call VerifyScreenDump(buf, 'Test_display_fillchars_1', {})
@@ -381,7 +373,6 @@
call VerifyScreenDump(buf, 'Test_display_fillchars_2', {})
call StopVimInTerminal(buf)
- call delete('Xdisplayfillchars')
endfunc
func Test_display_linebreak_breakat()
@@ -409,7 +400,7 @@
vsplit
100wincmd <
END
- call writefile(lines, 'XdispLastline')
+ call writefile(lines, 'XdispLastline', 'D')
let buf = RunVimInTerminal('-S XdispLastline', #{rows: 10})
call VerifyScreenDump(buf, 'Test_display_lastline_1', {})
@@ -423,7 +414,6 @@
call VerifyScreenDump(buf, 'Test_display_lastline_4', {})
call StopVimInTerminal(buf)
- call delete('XdispLastline')
endfunc