patch 9.0.0411: only created files can be cleaned up with one call
Problem: Only created files can be cleaned up with one call.
Solution: Add flags to mkdir() to delete with a deferred function.
Expand the writefile() name to a full path to handle changing
directory.
diff --git a/src/testdir/test_autochdir.vim b/src/testdir/test_autochdir.vim
index 332de8f..eb40253 100644
--- a/src/testdir/test_autochdir.vim
+++ b/src/testdir/test_autochdir.vim
@@ -28,9 +28,9 @@
func Test_set_filename_other_window()
let cwd = getcwd()
call test_autochdir()
- call mkdir('Xa')
- call mkdir('Xb')
- call mkdir('Xc')
+ call mkdir('Xa', 'R')
+ call mkdir('Xb', 'R')
+ call mkdir('Xc', 'R')
try
args Xa/aaa.txt Xb/bbb.txt
set acd
@@ -45,9 +45,6 @@
bwipe! aaa.txt
bwipe! bbb.txt
bwipe! ccc.txt
- call delete('Xa', 'rf')
- call delete('Xb', 'rf')
- call delete('Xc', 'rf')
endtry
endfunc
@@ -56,7 +53,7 @@
set acd
call test_autochdir()
- call mkdir('XacdDir')
+ call mkdir('XacdDir', 'R')
let winid = win_getid()
new XacdDir/file
call assert_match('testdir.XacdDir$', getcwd())
@@ -68,7 +65,6 @@
bwipe!
set noacd
call chdir(cwd)
- call delete('XacdDir', 'rf')
endfunc
func Test_verbose_pwd()
@@ -78,7 +74,7 @@
edit global.txt
call assert_match('\[global\].*testdir$', execute('verbose pwd'))
- call mkdir('Xautodir')
+ call mkdir('Xautodir', 'R')
split Xautodir/local.txt
lcd Xautodir
call assert_match('\[window\].*testdir[/\\]Xautodir', execute('verbose pwd'))
@@ -112,7 +108,6 @@
bwipe!
call chdir(cwd)
- call delete('Xautodir', 'rf')
endfunc
func Test_multibyte()
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 028e3d2..669089d 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -707,14 +707,13 @@
call assert_equal('++', g:val)
" Also get BufEnter when editing a directory
- call mkdir('Xbufenterdir')
+ call mkdir('Xbufenterdir', 'D')
split Xbufenterdir
call assert_equal('+++', g:val)
" On MS-Windows we can't edit the directory, make sure we wipe the right
" buffer.
bwipe! Xbufenterdir
- call delete('Xbufenterdir', 'd')
au! BufEnter
" Editing a "nofile" buffer doesn't read the file but does trigger BufEnter
@@ -1902,11 +1901,10 @@
new
file Xbufwritecmd
set buftype=acwrite
- call mkdir('Xbufwritecmd')
+ call mkdir('Xbufwritecmd', 'D')
write
" BufWriteCmd should be triggered even if a directory has the same name
call assert_equal(1, g:written)
- call delete('Xbufwritecmd', 'd')
unlet g:written
au! BufWriteCmd
bwipe!
@@ -2710,7 +2708,7 @@
endfunc
func Test_autocmd_in_try_block()
- call mkdir('Xintrydir')
+ call mkdir('Xintrydir', 'R')
au BufEnter * let g:fname = expand('%')
try
edit Xintrydir/
@@ -2719,7 +2717,6 @@
unlet g:fname
au! BufEnter
- call delete('Xintrydir', 'rf')
endfunc
func Test_autocmd_SafeState()
diff --git a/src/testdir/test_eval_stuff.vim b/src/testdir/test_eval_stuff.vim
index 3669cfd..0081d89 100644
--- a/src/testdir/test_eval_stuff.vim
+++ b/src/testdir/test_eval_stuff.vim
Binary files differ
diff --git a/src/testdir/test_writefile.vim b/src/testdir/test_writefile.vim
index dddc5c9..f2b8aba 100644
--- a/src/testdir/test_writefile.vim
+++ b/src/testdir/test_writefile.vim
@@ -950,6 +950,19 @@
call assert_equal('', glob('XdefdeferDelete'))
endfunc
+func DoWriteFile()
+ call writefile(['text'], 'Xthefile', 'D')
+ cd ..
+endfunc
+
+func Test_write_defer_delete_chdir()
+ let dir = getcwd()
+ call DoWriteFile()
+ call assert_notequal(dir, getcwd())
+ call chdir(dir)
+ call assert_equal('', glob('Xthefile'))
+endfunc
+
" Check that buffer is written before triggering QuitPre
func Test_wq_quitpre_autocommand()
edit Xsomefile