patch 9.0.0418: manually deleting temp test files
Problem: Manually deleting temp test files.
Solution: Use the 'D' flag of writefile() and mkdir().
diff --git a/src/testdir/test_cpoptions.vim b/src/testdir/test_cpoptions.vim
index 600132d..979c00b 100644
--- a/src/testdir/test_cpoptions.vim
+++ b/src/testdir/test_cpoptions.vim
@@ -8,7 +8,7 @@
" file name.
func Test_cpo_a()
let save_cpo = &cpo
- call writefile(['one'], 'XfileCpoA')
+ call writefile(['one'], 'XfileCpoA', 'D')
" Wipe out all the buffers, so that the alternate file is empty
edit Xfoo | %bw
set cpo-=a
@@ -20,7 +20,6 @@
read XfileCpoA
call assert_equal('XfileCpoA', @#)
close!
- call delete('XfileCpoA')
let &cpo = save_cpo
endfunc
@@ -99,21 +98,20 @@
" Test for the 'C' flag in 'cpo' (line continuation)
func Test_cpo_C()
let save_cpo = &cpo
- call writefile(['let l = [', '\ 1,', '\ 2]'], 'XfileCpoC')
+ call writefile(['let l = [', '\ 1,', '\ 2]'], 'XfileCpoC', 'D')
set cpo-=C
source XfileCpoC
call assert_equal([1, 2], g:l)
set cpo+=C
call assert_fails('source XfileCpoC', ['E697:', 'E10:'])
- call delete('XfileCpoC')
let &cpo = save_cpo
endfunc
" Test for the 'd' flag in 'cpo' (tags relative to the current file)
func Test_cpo_d()
let save_cpo = &cpo
- call mkdir('XdirCpoD')
- call writefile(["one\tXfile1\t/^one$/"], 'tags')
+ call mkdir('XdirCpoD', 'R')
+ call writefile(["one\tXfile1\t/^one$/"], 'tags', 'D')
call writefile(["two\tXfile2\t/^two$/"], 'XdirCpoD/tags')
set tags=./tags
set cpo-=d
@@ -121,9 +119,8 @@
call assert_equal('two', taglist('.*')[0].name)
set cpo+=d
call assert_equal('one', taglist('.*')[0].name)
+
%bw!
- call delete('tags')
- call delete('XdirCpoD', 'rf')
set tags&
let &cpo = save_cpo
endfunc
@@ -415,14 +412,13 @@
let save_cpo = &cpo
new XfileCpoO
call setline(1, 'one')
- call writefile(['two'], 'XfileCpoO')
+ call writefile(['two'], 'XfileCpoO', 'D')
set cpo-=O
call assert_fails('write', 'E13:')
set cpo+=O
write
call assert_equal(['one'], readfile('XfileCpoO'))
close!
- call delete('XfileCpoO')
let &cpo = save_cpo
endfunc
@@ -432,7 +428,7 @@
" name)
func Test_cpo_P()
let save_cpo = &cpo
- call writefile([], 'XfileCpoP')
+ call writefile([], 'XfileCpoP', 'D')
new
call setline(1, 'one')
set cpo+=F
@@ -443,7 +439,6 @@
write >> XfileCpoP
call assert_equal('XfileCpoP', @%)
close!
- call delete('XfileCpoP')
let &cpo = save_cpo
endfunc
@@ -635,7 +630,7 @@
" Test for the 'Z' flag in 'cpo' (write! resets 'readonly')
func Test_cpo_Z()
let save_cpo = &cpo
- call writefile([], 'XfileCpoZ')
+ call writefile([], 'XfileCpoZ', 'D')
new XfileCpoZ
setlocal readonly
set cpo-=Z
@@ -646,7 +641,6 @@
write!
call assert_equal(1, &readonly)
close!
- call delete('XfileCpoZ')
let &cpo = save_cpo
endfunc
@@ -723,7 +717,7 @@
" flag)
func Test_cpo_plus()
let save_cpo = &cpo
- call writefile([], 'XfileCpoPlus')
+ call writefile([], 'XfileCpoPlus', 'D')
new XfileCpoPlus
call setline(1, 'foo')
write X1
@@ -732,7 +726,6 @@
write X2
call assert_equal(0, &modified)
close!
- call delete('XfileCpoPlus')
call delete('X1')
call delete('X2')
let &cpo = save_cpo
@@ -835,7 +828,7 @@
" Test for the '&' flag in 'cpo'. The swap file is kept when a buffer is still
" loaded and ':preserve' is used.
func Test_cpo_ampersand()
- call writefile(['one'], 'XfileCpoAmp')
+ call writefile(['one'], 'XfileCpoAmp', 'D')
let after =<< trim [CODE]
set cpo+=&
preserve
@@ -845,7 +838,6 @@
call assert_equal(1, filereadable('.XfileCpoAmp.swp'))
call delete('.XfileCpoAmp.swp')
endif
- call delete('XfileCpoAmp')
endfunc
" Test for the '\' flag in 'cpo' (backslash in a [] range in a search pattern)