Patch 8.2.0958

8 views
Skip to first unread message

Bram Moolenaar

unread,
Jun 11, 2020, 1:23:29 PM6/11/20
to vim...@googlegroups.com

Patch 8.2.0958
Problem: Not sufficient testing for buffer writing.
Solution: Add a few tests. (Yegappan Lakshmanan, closes #6238)
Files: src/testdir/test_backup.vim, src/testdir/test_writefile.vim


*** ../vim-8.2.0957/src/testdir/test_backup.vim 2018-08-09 22:24:06.000000000 +0200
--- src/testdir/test_backup.vim 2020-06-11 19:21:02.497038419 +0200
***************
*** 1,5 ****
--- 1,7 ----
" Tests for the backup function

+ source check.vim
+
func Test_backup()
set backup backupdir=. backupskip=
new
***************
*** 56,58 ****
--- 58,75 ----
call delete(f)
set backup&vim backupdir&vim backupcopy&vim backupskip&vim
endfunc
+
+ " Test for using a non-existing directory as a backup directory
+ func Test_non_existing_backupdir()
+ CheckNotBSD
+ let save_backup = &backupdir
+ set backupdir=./non_existing_dir
+ call writefile(['line1'], 'Xfile')
+ new Xfile
+ " TODO: write doesn't fail in Cirrus FreeBSD CI test
+ call assert_fails('write', 'E510:')
+ let &backupdir = save_backup
+ call delete('Xfile')
+ endfunc
+
+ " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0957/src/testdir/test_writefile.vim 2020-05-31 21:27:58.335221898 +0200
--- src/testdir/test_writefile.vim 2020-06-11 19:21:02.497038419 +0200
***************
*** 383,389 ****
--- 383,437 ----
set cpo+=W
call assert_fails('write!', 'E504:')
let &cpo = save_cpo
+ call setline(1, ['line1'])
+ write!
+ call assert_equal(['line1'], readfile('Xfile'))
call delete('Xfile')
endfunc

+ " Test for 'patchmode'
+ func Test_patchmode()
+ CheckNotBSD
+ call writefile(['one'], 'Xfile')
+ set patchmode=.orig nobackup writebackup
+ new Xfile
+ call setline(1, 'two')
+ " first write should create the .orig file
+ write
+ " TODO: Xfile.orig is not created in Cirrus FreeBSD CI test
+ call assert_equal(['one'], readfile('Xfile.orig'))
+ call setline(1, 'three')
+ " subsequent writes should not create/modify the .orig file
+ write
+ call assert_equal(['one'], readfile('Xfile.orig'))
+ set patchmode& backup& writebackup&
+ call delete('Xfile')
+ call delete('Xfile.orig')
+ endfunc
+
+ " Test for writing to a file in a readonly directory
+ func Test_write_readonly_dir()
+ if !has('unix') || has('bsd')
+ " On MS-Windows, modifying files in a read-only directory is allowed.
+ " In Cirrus-CI for Freebsd, tests are run under a root account where
+ " modifying files in a read-only directory are allowed.
+ return
+ endif
+ call mkdir('Xdir')
+ call writefile(['one'], 'Xdir/Xfile1')
+ call setfperm('Xdir', 'r-xr--r--')
+ " try to create a new file in the directory
+ new Xdir/Xfile2
+ call setline(1, 'two')
+ call assert_fails('write', 'E212:')
+ " try to create a backup file in the directory
+ edit! Xdir/Xfile1
+ set backupdir=./Xdir
+ set patchmode=.orig
+ call assert_fails('write', 'E509:')
+ call setfperm('Xdir', 'rwxr--r--')
+ call delete('Xdir', 'rf')
+ set backupdir& patchmode&
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0957/src/version.c 2020-06-11 12:30:09.281198615 +0200
--- src/version.c 2020-06-11 19:22:10.492750747 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 958,
/**/

--
I still remember when I gave up Smoking, Drinking and Sex. It was the
most *horrifying* hour of my life!

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages