Mercurial > vim
diff src/testdir/test_rename.vim @ 30669:de319bf98a39 v9.0.0669
patch 9.0.0669: too many delete() calls in tests
Commit: https://github.com/vim/vim/commit/db77cb3c08784e6038dd029271b2080c1b2d9acb
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Oct 5 21:45:30 2022 +0100
patch 9.0.0669: too many delete() calls in tests
Problem: Too many delete() calls in tests.
Solution: Use deferred delete where possible.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 05 Oct 2022 23:00:04 +0200 |
parents | ff21e2962490 |
children |
line wrap: on
line diff
--- a/src/testdir/test_rename.vim +++ b/src/testdir/test_rename.vim @@ -12,7 +12,7 @@ func Test_rename_file_to_file() " When the destination file already exists, it should be overwritten. call writefile(['foo'], 'Xrename1') - call writefile(['bar'], 'Xrename2') + call writefile(['bar'], 'Xrename2', 'D') call assert_equal(0, rename('Xrename1', 'Xrename2')) call assert_equal('', glob('Xrename1')) @@ -36,7 +36,7 @@ func Test_rename_file_ignore_case() endfunc func Test_rename_same_file() - call writefile(['foo'], 'Xrename') + call writefile(['foo'], 'Xrename', 'D') " When the source and destination are the same file, nothing " should be done. The source file should not be deleted. @@ -45,8 +45,6 @@ func Test_rename_same_file() call assert_equal(0, rename('./Xrename', 'Xrename')) call assert_equal(['foo'], readfile('Xrename')) - - call delete('Xrename') endfunc func Test_rename_dir_to_dir() @@ -63,21 +61,18 @@ func Test_rename_dir_to_dir() endfunc func Test_rename_same_dir() - call mkdir('Xrenamedir') + call mkdir('Xrenamedir', 'R') call writefile(['foo'], 'Xrenamedir/Xrenamefile') call assert_equal(0, rename('Xrenamedir', 'Xrenamedir')) call assert_equal(['foo'], readfile('Xrenamedir/Xrenamefile')) - - call delete('Xrenamedir/Xrenamefile') - call delete('Xrenamedir', 'd') endfunc func Test_rename_copy() " Check that when original file can't be deleted, rename() " still succeeds but copies the file. - call mkdir('Xrenamedir') + call mkdir('Xrenamedir', 'R') call writefile(['foo'], 'Xrenamedir/Xrenamefile') call setfperm('Xrenamedir', 'r-xr-xr-x') @@ -91,13 +86,11 @@ func Test_rename_copy() call assert_equal(['foo'], readfile('Xrenamefile')) call setfperm('Xrenamedir', 'rwxrwxrwx') - call delete('Xrenamedir/Xrenamefile') - call delete('Xrenamedir', 'd') call delete('Xrenamefile') endfunc func Test_rename_fails() - call writefile(['foo'], 'Xrenamefile') + call writefile(['foo'], 'Xrenamefile', 'D') " Can't rename into a non-existing directory. call assert_notequal(0, rename('Xrenamefile', 'Xdoesnotexist/Xrenamefile')) @@ -115,8 +108,6 @@ func Test_rename_fails() call assert_fails('call rename("Xrenamefile", [])', 'E730:') call assert_fails('call rename(0z, "Xrenamefile")', 'E976:') - - call delete('Xrenamefile') endfunc " vim: shiftwidth=2 sts=2 expandtab