Skip to content

Commit 45bbaef

Browse files
committed
patch 9.0.0418: manually deleting temp test files
Problem: Manually deleting temp test files. Solution: Use the 'D' flag of writefile() and mkdir().
1 parent 2a4c885 commit 45bbaef

File tree

11 files changed

+85
-162
lines changed

11 files changed

+85
-162
lines changed

src/testdir/test_cd.vim

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,17 @@ func Test_cd_minus()
5858
call writefile(v:errors, 'Xresult')
5959
qall!
6060
[SCRIPT]
61-
call writefile(lines, 'Xscript')
61+
call writefile(lines, 'Xscript', 'D')
6262
if RunVim([], [], '--clean -S Xscript')
6363
call assert_equal([], readfile('Xresult'))
6464
endif
65-
call delete('Xscript')
6665
call delete('Xresult')
6766
endfunc
6867

6968
" Test for chdir()
7069
func Test_chdir_func()
7170
let topdir = getcwd()
72-
call mkdir('Xchdir/y/z', 'p')
71+
call mkdir('Xchdir/y/z', 'pR')
7372

7473
" Create a few tabpages and windows with different directories
7574
new
@@ -110,13 +109,12 @@ func Test_chdir_func()
110109

111110
only | tabonly
112111
call chdir(topdir)
113-
call delete('Xchdir', 'rf')
114112
endfunc
115113

116114
" Test for changing to the previous directory '-'
117115
func Test_prev_dir()
118116
let topdir = getcwd()
119-
call mkdir('Xprevdir/a/b/c', 'p')
117+
call mkdir('Xprevdir/a/b/c', 'pR')
120118

121119
" Create a few tabpages and windows with different directories
122120
new | only
@@ -173,7 +171,6 @@ func Test_prev_dir()
173171

174172
only | tabonly
175173
call chdir(topdir)
176-
call delete('Xprevdir', 'rf')
177174
endfunc
178175

179176
func Test_lcd_split()
@@ -201,22 +198,18 @@ func Test_cd_from_non_existing_dir()
201198
endfunc
202199

203200
func Test_cd_completion()
204-
call mkdir('XComplDir1', 'p')
205-
call mkdir('XComplDir2', 'p')
206-
call writefile([], 'XComplFile')
201+
call mkdir('XComplDir1', 'D')
202+
call mkdir('XComplDir2', 'D')
203+
call writefile([], 'XComplFile', 'D')
207204

208205
for cmd in ['cd', 'chdir', 'lcd', 'lchdir', 'tcd', 'tchdir']
209206
call feedkeys(':' .. cmd .. " XCompl\<C-A>\<C-B>\"\<CR>", 'tx')
210207
call assert_equal('"' .. cmd .. ' XComplDir1/ XComplDir2/', @:)
211208
endfor
212-
213-
call delete('XComplDir1', 'd')
214-
call delete('XComplDir2', 'd')
215-
call delete('XComplFile')
216209
endfunc
217210

218211
func Test_cd_unknown_dir()
219-
call mkdir('Xa')
212+
call mkdir('Xa', 'R')
220213
cd Xa
221214
call writefile(['text'], 'Xb.txt')
222215
edit Xa/Xb.txt
@@ -229,14 +222,13 @@ func Test_cd_unknown_dir()
229222

230223
bwipe!
231224
exe "bwipe! " .. first_buf
232-
call delete('Xa', 'rf')
233225
endfunc
234226

235227
func Test_getcwd_actual_dir()
236228
CheckOption autochdir
237229

238230
let startdir = getcwd()
239-
call mkdir('Xactual')
231+
call mkdir('Xactual', 'R')
240232
call test_autochdir()
241233
set autochdir
242234
edit Xactual/file.txt
@@ -250,7 +242,6 @@ func Test_getcwd_actual_dir()
250242
set noautochdir
251243
bwipe!
252244
call chdir(startdir)
253-
call delete('Xactual', 'rf')
254245
endfunc
255246

256247
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_changelist.vim

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ func Test_getchangelist()
6464
call assert_equal([], 10->getchangelist())
6565
call assert_equal([[], 0], getchangelist())
6666

67-
call writefile(['line1', 'line2', 'line3'], 'Xclistfile1.txt')
68-
call writefile(['line1', 'line2', 'line3'], 'Xclistfile2.txt')
67+
call writefile(['line1', 'line2', 'line3'], 'Xclistfile1.txt', 'D')
68+
call writefile(['line1', 'line2', 'line3'], 'Xclistfile2.txt', 'D')
6969

7070
edit Xclistfile1.txt
7171
let buf_1 = bufnr()
@@ -100,8 +100,6 @@ func Test_getchangelist()
100100
\ getchangelist(buf_2))
101101

102102
bwipe!
103-
call delete('Xclistfile1.txt')
104-
call delete('Xclistfile2.txt')
105103
endfunc
106104

107105
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_channel.vim

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ func Stop_g_job()
714714
endfunc
715715

716716
func Test_nl_read_file()
717-
call writefile(['echo something', 'echoerr wrong', 'double this'], 'Xinput')
717+
call writefile(['echo something', 'echoerr wrong', 'double this'], 'Xinput', 'D')
718718
let g:job = job_start(s:python . " test_channel_pipe.py",
719719
\ {'in_io': 'file', 'in_name': 'Xinput'})
720720
call assert_equal("run", job_status(g:job))
@@ -726,7 +726,6 @@ func Test_nl_read_file()
726726
call assert_equal("AND this", ch_readraw(handle))
727727
finally
728728
call Stop_g_job()
729-
call delete('Xinput')
730729
endtry
731730
call assert_fails("echo ch_read(test_null_channel(), {'callback' : 'abc'})", 'E475:')
732731
endfunc
@@ -1161,14 +1160,13 @@ func Test_write_to_buffer_and_scroll()
11611160
endif
11621161
call job_start(cmd, #{out_io: 'buffer', out_name: 'Xscrollbuffer'})
11631162
END
1164-
call writefile(lines, 'XtestBufferScroll')
1163+
call writefile(lines, 'XtestBufferScroll', 'D')
11651164
let buf = RunVimInTerminal('-S XtestBufferScroll', #{rows: 10})
11661165
call TermWait(buf, 50)
11671166
call VerifyScreenDump(buf, 'Test_job_buffer_scroll_1', {})
11681167

11691168
" clean up
11701169
call StopVimInTerminal(buf)
1171-
call delete('XtestBufferScroll')
11721170
endfunc
11731171

11741172
func Test_pipe_null()
@@ -2178,7 +2176,7 @@ endfunc
21782176
func Test_job_tty_in_out()
21792177
CheckUnix
21802178

2181-
call writefile(['test'], 'Xtestin')
2179+
call writefile(['test'], 'Xtestin', 'D')
21822180
let in_opts = [{},
21832181
\ {'in_io': 'null'},
21842182
\ {'in_io': 'file', 'in_name': 'Xtestin'}]
@@ -2220,7 +2218,6 @@ func Test_job_tty_in_out()
22202218
call WaitForAssert({-> assert_equal('dead', job_status(job))})
22212219
endfor
22222220

2223-
call delete('Xtestin')
22242221
call delete('Xtestout')
22252222
call delete('Xtesterr')
22262223
endfunc
@@ -2281,9 +2278,9 @@ func Test_zz_ch_log()
22812278
let text = readfile('Xlog')
22822279
call assert_match("hello there", text[1])
22832280
call assert_match("%s%s", text[2])
2284-
call mkdir("Xchlogdir1")
2281+
call mkdir("Xchlogdir1", 'D')
22852282
call assert_fails("call ch_logfile('Xchlogdir1')", 'E484:')
2286-
cal delete("Xchlogdir1", 'd')
2283+
22872284
call delete('Xlog')
22882285
endfunc
22892286

src/testdir/test_checkpath.vim

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
" Test for 'include' without \zs or \ze
44
func Test_checkpath1()
5-
call mkdir("Xcheckdir1/dir2", "p")
5+
call mkdir("Xcheckdir1/dir2", "pR")
66
call writefile(['#include "bar.a"'], 'Xcheckdir1/dir2/foo.a')
77
call writefile(['#include "baz.a"'], 'Xcheckdir1/dir2/bar.a')
88
call writefile(['#include "foo.a"'], 'Xcheckdir1/dir2/baz.a')
@@ -23,7 +23,6 @@ func Test_checkpath1()
2323

2424
enew
2525
call delete("./Xbase.a")
26-
call delete("Xcheckdir1", "rf")
2726
set path&
2827
endfunc
2928

@@ -33,11 +32,11 @@ endfunc
3332

3433
" Test for 'include' with \zs and \ze
3534
func Test_checkpath2()
36-
call mkdir("Xcheckdir2/dir2", "p")
35+
call mkdir("Xcheckdir2/dir2", "pR")
3736
call writefile(['%inc /bar/'], 'Xcheckdir2/dir2/foo.b')
3837
call writefile(['%inc /baz/'], 'Xcheckdir2/dir2/bar.b')
3938
call writefile(['%inc /foo/'], 'Xcheckdir2/dir2/baz.b')
40-
call writefile(['%inc /foo/'], 'Xbase.b')
39+
call writefile(['%inc /foo/'], 'Xbase.b', 'D')
4140

4241
let &include='^\s*%inc\s*/\zs[^/]\+\ze'
4342
let &includeexpr='DotsToSlashes()'
@@ -56,8 +55,6 @@ func Test_checkpath2()
5655
\ ' foo (Already listed)'], res)
5756

5857
enew
59-
call delete("./Xbase.b")
60-
call delete("Xcheckdir2", "rf")
6158
set path&
6259
set include&
6360
set includeexpr&
@@ -72,12 +69,12 @@ endfunc
7269

7370
" Test for 'include' with \zs and no \ze
7471
func Test_checkpath3()
75-
call mkdir("Xcheckdir3/dir2", "p")
72+
call mkdir("Xcheckdir3/dir2", "pR")
7673
call writefile(['%inc bar.c'], 'Xcheckdir3/dir2/foo.c')
7774
call writefile(['%inc baz.c'], 'Xcheckdir3/dir2/bar.c')
7875
call writefile(['%inc foo.c'], 'Xcheckdir3/dir2/baz.c')
7976
call writefile(['%inc foo.c'], 'Xcheckdir3/dir2/FALSE.c')
80-
call writefile(['%inc FALSE.c foo.c'], 'Xbase.c')
77+
call writefile(['%inc FALSE.c foo.c'], 'Xbase.c', 'D')
8178

8279
let &include='^\s*%inc\s*\%([[:upper:]][^[:space:]]*\s\+\)\?\zs\S\+\ze'
8380
let &includeexpr='StripNewlineChar()'
@@ -96,8 +93,6 @@ func Test_checkpath3()
9693
\ ' foo.c (Already listed)'], res)
9794

9895
enew
99-
call delete("./Xbase.c")
100-
call delete("Xcheckdir3", "rf")
10196
set path&
10297
set include&
10398
set includeexpr&

0 commit comments

Comments
 (0)