vim-patch:partial:9.0.0418: manually deleting temp test files

Problem:    Manually deleting temp test files.
Solution:   Use the 'D' flag of writefile() and mkdir().

45bbaef038

This only includes test_cd.vim changes.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq 2024-07-12 07:25:46 +08:00
parent a61666293d
commit f1827d877d

View File

@ -58,18 +58,17 @@ func Test_cd_minus()
call writefile(v:errors, 'Xresult') call writefile(v:errors, 'Xresult')
qall! qall!
[SCRIPT] [SCRIPT]
call writefile(lines, 'Xscript') call writefile(lines, 'Xscript', 'D')
if RunVim([], [], '--clean -S Xscript') if RunVim([], [], '--clean -S Xscript')
call assert_equal([], readfile('Xresult')) call assert_equal([], readfile('Xresult'))
endif endif
call delete('Xscript')
call delete('Xresult') call delete('Xresult')
endfunc endfunc
" Test for chdir() " Test for chdir()
func Test_chdir_func() func Test_chdir_func()
let topdir = getcwd() let topdir = getcwd()
call mkdir('Xchdir/y/z', 'p') call mkdir('Xchdir/y/z', 'pR')
" Create a few tabpages and windows with different directories " Create a few tabpages and windows with different directories
new new
@ -110,13 +109,12 @@ func Test_chdir_func()
only | tabonly only | tabonly
call chdir(topdir) call chdir(topdir)
call delete('Xchdir', 'rf')
endfunc endfunc
" Test for changing to the previous directory '-' " Test for changing to the previous directory '-'
func Test_prev_dir() func Test_prev_dir()
let topdir = getcwd() let topdir = getcwd()
call mkdir('Xprevdir/a/b/c', 'p') call mkdir('Xprevdir/a/b/c', 'pR')
" Create a few tabpages and windows with different directories " Create a few tabpages and windows with different directories
new | only new | only
@ -173,7 +171,6 @@ func Test_prev_dir()
only | tabonly only | tabonly
call chdir(topdir) call chdir(topdir)
call delete('Xprevdir', 'rf')
endfunc endfunc
func Test_lcd_split() func Test_lcd_split()
@ -201,22 +198,18 @@ func Test_cd_from_non_existing_dir()
endfunc endfunc
func Test_cd_completion() func Test_cd_completion()
call mkdir('XComplDir1', 'p') call mkdir('XComplDir1', 'D')
call mkdir('XComplDir2', 'p') call mkdir('XComplDir2', 'D')
call writefile([], 'XComplFile') call writefile([], 'XComplFile', 'D')
for cmd in ['cd', 'chdir', 'lcd', 'lchdir', 'tcd', 'tchdir'] for cmd in ['cd', 'chdir', 'lcd', 'lchdir', 'tcd', 'tchdir']
call feedkeys(':' .. cmd .. " XCompl\<C-A>\<C-B>\"\<CR>", 'tx') call feedkeys(':' .. cmd .. " XCompl\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"' .. cmd .. ' XComplDir1/ XComplDir2/', @:) call assert_equal('"' .. cmd .. ' XComplDir1/ XComplDir2/', @:)
endfor endfor
call delete('XComplDir1', 'd')
call delete('XComplDir2', 'd')
call delete('XComplFile')
endfunc endfunc
func Test_cd_unknown_dir() func Test_cd_unknown_dir()
call mkdir('Xa') call mkdir('Xa', 'R')
cd Xa cd Xa
call writefile(['text'], 'Xb.txt') call writefile(['text'], 'Xb.txt')
edit Xa/Xb.txt edit Xa/Xb.txt
@ -229,7 +222,6 @@ func Test_cd_unknown_dir()
bwipe! bwipe!
exe "bwipe! " .. first_buf exe "bwipe! " .. first_buf
call delete('Xa', 'rf')
endfunc endfunc
func Test_getcwd_actual_dir() func Test_getcwd_actual_dir()
@ -237,7 +229,7 @@ func Test_getcwd_actual_dir()
CheckOption autochdir CheckOption autochdir
let startdir = getcwd() let startdir = getcwd()
call mkdir('Xactual') call mkdir('Xactual', 'R')
call test_autochdir() call test_autochdir()
set autochdir set autochdir
edit Xactual/file.txt edit Xactual/file.txt
@ -251,7 +243,6 @@ func Test_getcwd_actual_dir()
set noautochdir set noautochdir
bwipe! bwipe!
call chdir(startdir) call chdir(startdir)
call delete('Xactual', 'rf')
endfunc endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab