diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/old/testdir/test_autochdir.vim | 19 | ||||
-rw-r--r-- | test/old/testdir/test_autocmd.vim | 17 | ||||
-rw-r--r-- | test/old/testdir/test_eval_stuff.vim | 64 | ||||
-rw-r--r-- | test/old/testdir/test_writefile.vim | 13 | ||||
-rw-r--r-- | test/unit/os/fs_spec.lua | 2 |
5 files changed, 89 insertions, 26 deletions
diff --git a/test/old/testdir/test_autochdir.vim b/test/old/testdir/test_autochdir.vim index a8810047a0..652ce8b794 100644 --- a/test/old/testdir/test_autochdir.vim +++ b/test/old/testdir/test_autochdir.vim @@ -30,9 +30,9 @@ func Test_set_filename_other_window() CheckFunction test_autochdir 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 @@ -44,9 +44,6 @@ func Test_set_filename_other_window() finally set noacd call chdir(cwd) - call delete('Xa', 'rf') - call delete('Xb', 'rf') - call delete('Xc', 'rf') bwipe! aaa.txt bwipe! bbb.txt bwipe! ccc.txt @@ -59,10 +56,10 @@ func Test_acd_win_execute() set acd call test_autochdir() - call mkdir('Xfile') + call mkdir('XacdDir', 'R') let winid = win_getid() - new Xfile/file - call assert_match('testdir.Xfile$', getcwd()) + new XacdDir/file + call assert_match('testdir.XacdDir$', getcwd()) cd .. call assert_match('testdir$', getcwd()) call win_execute(winid, 'echo') @@ -71,7 +68,6 @@ func Test_acd_win_execute() bwipe! set noacd call chdir(cwd) - call delete('Xfile', 'rf') endfunc func Test_verbose_pwd() @@ -82,7 +78,7 @@ func Test_verbose_pwd() 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')) @@ -116,7 +112,6 @@ func Test_verbose_pwd() bwipe! call chdir(cwd) - call delete('Xautodir', 'rf') endfunc func Test_multibyte() diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim index 6d7f1649b3..ec671369f5 100644 --- a/test/old/testdir/test_autocmd.vim +++ b/test/old/testdir/test_autocmd.vim @@ -918,14 +918,13 @@ func Test_BufEnter() call assert_equal('++', g:val) " Also get BufEnter when editing a directory - call mkdir('Xdir') - split Xdir + 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! Xdir - call delete('Xdir', 'd') + bwipe! Xbufenterdir au! BufEnter " Editing a "nofile" buffer doesn't read the file but does trigger BufEnter @@ -2186,11 +2185,10 @@ func Test_BufWriteCmd() 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! @@ -2947,16 +2945,15 @@ func Test_throw_in_BufWritePre() endfunc func Test_autocmd_in_try_block() - call mkdir('Xdir') + call mkdir('Xintrydir', 'R') au BufEnter * let g:fname = expand('%') try - edit Xdir/ + edit Xintrydir/ endtry - call assert_match('Xdir', g:fname) + call assert_match('Xintrydir', g:fname) unlet g:fname au! BufEnter - call delete('Xdir', 'rf') endfunc func Test_autocmd_CmdWinEnter() diff --git a/test/old/testdir/test_eval_stuff.vim b/test/old/testdir/test_eval_stuff.vim index 7acc91c17b..20eb873326 100644 --- a/test/old/testdir/test_eval_stuff.vim +++ b/test/old/testdir/test_eval_stuff.vim @@ -36,12 +36,70 @@ func Test_mkdir_p() endtry " 'p' doesn't suppress real errors call writefile([], 'Xfile') - call assert_fails('call mkdir("Xfile", "p")', 'E739') + call assert_fails('call mkdir("Xfile", "p")', 'E739:') call delete('Xfile') call delete('Xmkdir', 'rf') call assert_equal(0, mkdir(v:_null_string)) - call assert_fails('call mkdir([])', 'E730') - call assert_fails('call mkdir("abc", [], [])', 'E745') + call assert_fails('call mkdir([])', 'E730:') + call assert_fails('call mkdir("abc", [], [])', 'E745:') +endfunc + +func DoMkdirDel(name) + call mkdir(a:name, 'pD') + call assert_true(isdirectory(a:name)) +endfunc + +func DoMkdirDelAddFile(name) + call mkdir(a:name, 'pD') + call assert_true(isdirectory(a:name)) + call writefile(['text'], a:name .. '/file') +endfunc + +func DoMkdirDelRec(name) + call mkdir(a:name, 'pR') + call assert_true(isdirectory(a:name)) +endfunc + +func DoMkdirDelRecAddFile(name) + call mkdir(a:name, 'pR') + call assert_true(isdirectory(a:name)) + call writefile(['text'], a:name .. '/file') +endfunc + +func Test_mkdir_defer_del() + " Xtopdir/tmp is created thus deleted, not Xtopdir itself + call mkdir('Xtopdir', 'R') + call DoMkdirDel('Xtopdir/tmp') + call assert_true(isdirectory('Xtopdir')) + call assert_false(isdirectory('Xtopdir/tmp')) + + " Deletion fails because "tmp" contains "sub" + call DoMkdirDel('Xtopdir/tmp/sub') + call assert_true(isdirectory('Xtopdir')) + call assert_true(isdirectory('Xtopdir/tmp')) + call delete('Xtopdir/tmp', 'rf') + + " Deletion fails because "tmp" contains "file" + call DoMkdirDelAddFile('Xtopdir/tmp') + call assert_true(isdirectory('Xtopdir')) + call assert_true(isdirectory('Xtopdir/tmp')) + call assert_true(filereadable('Xtopdir/tmp/file')) + call delete('Xtopdir/tmp', 'rf') + + " Xtopdir/tmp is created thus deleted, not Xtopdir itself + call DoMkdirDelRec('Xtopdir/tmp') + call assert_true(isdirectory('Xtopdir')) + call assert_false(isdirectory('Xtopdir/tmp')) + + " Deletion works even though "tmp" contains "sub" + call DoMkdirDelRec('Xtopdir/tmp/sub') + call assert_true(isdirectory('Xtopdir')) + call assert_false(isdirectory('Xtopdir/tmp')) + + " Deletion works even though "tmp" contains "file" + call DoMkdirDelRecAddFile('Xtopdir/tmp') + call assert_true(isdirectory('Xtopdir')) + call assert_false(isdirectory('Xtopdir/tmp')) endfunc func Test_line_continuation() diff --git a/test/old/testdir/test_writefile.vim b/test/old/testdir/test_writefile.vim index 5e6428ded8..312d45e18f 100644 --- a/test/old/testdir/test_writefile.vim +++ b/test/old/testdir/test_writefile.vim @@ -956,6 +956,19 @@ func Test_write_with_deferred_delete() " 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 diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua index 95a12f5b17..c32098a395 100644 --- a/test/unit/os/fs_spec.lua +++ b/test/unit/os/fs_spec.lua @@ -748,7 +748,7 @@ describe('fs.c', function() local function os_mkdir_recurse(path, mode) local failed_str = ffi.new('char *[1]', {nil}) - local ret = fs.os_mkdir_recurse(path, mode, failed_str) + local ret = fs.os_mkdir_recurse(path, mode, failed_str, nil) local str = failed_str[0] if str ~= nil then str = ffi.string(str) |