From b002499c1978c98cc4dfc3a3f2326997720d571a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 5 Nov 2022 08:22:46 +0800 Subject: vim-patch:8.2.0958: not sufficient testing for buffer writing Problem: Not sufficient testing for buffer writing. Solution: Add a few tests. (Yegappan Lakshmanan, closes vim/vim#6238) https://github.com/vim/vim/commit/1de5f7c81d5e78fb4d612134bd2dfa6ee9183fae --- src/nvim/testdir/test_backup.vim | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/nvim/testdir/test_backup.vim') diff --git a/src/nvim/testdir/test_backup.vim b/src/nvim/testdir/test_backup.vim index ce2bfe72bc..7eff818732 100644 --- a/src/nvim/testdir/test_backup.vim +++ b/src/nvim/testdir/test_backup.vim @@ -1,5 +1,7 @@ " Tests for the backup function +source check.vim + func Test_backup() set backup backupdir=. backupskip= new @@ -56,3 +58,19 @@ func Test_backup2_backupcopy() 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() + throw 'Skipped: Nvim auto-creates backup directory' + 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 -- cgit From 728c69bc8d52a3f2281a76e4142b2d766dc45da0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Nov 2022 22:13:36 +0800 Subject: vim-patch:8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD (#20967) Problem: Some tests fail on Cirrus CI and/or with FreeBSD. Solution: Make 'backupskip' empty. Do not run tests as root. Check for directory when using viminfo. (Ozaki Kiichi, closes vim/vim#6596) https://github.com/vim/vim/commit/b86abadf87bd0f85f800077171ec4b98aefff776 --- src/nvim/testdir/test_backup.vim | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/nvim/testdir/test_backup.vim') diff --git a/src/nvim/testdir/test_backup.vim b/src/nvim/testdir/test_backup.vim index 7eff818732..d304773da4 100644 --- a/src/nvim/testdir/test_backup.vim +++ b/src/nvim/testdir/test_backup.vim @@ -19,6 +19,22 @@ func Test_backup() call delete('Xbackup.txt~') endfunc +func Test_backup_backupskip() + set backup backupdir=. backupskip=*.txt + new + call setline(1, ['line1', 'line2']) + :f Xbackup.txt + :w! Xbackup.txt + " backup file is only created after + " writing a second time (before overwriting) + :w! Xbackup.txt + call assert_false(filereadable('Xbackup.txt~')) + bw! + set backup&vim backupdir&vim backupskip&vim + call delete('Xbackup.txt') + call delete('Xbackup.txt~') +endfunc + func Test_backup2() set backup backupdir=.// backupskip= new @@ -30,7 +46,7 @@ func Test_backup2() :w! Xbackup.txt sp *Xbackup.txt~ call assert_equal(['line1', 'line2', 'line3'], getline(1,'$')) - let f=expand('%') + let f = expand('%') call assert_match('%testdir%Xbackup.txt\~', f) bw! bw! @@ -50,7 +66,7 @@ func Test_backup2_backupcopy() :w! Xbackup.txt sp *Xbackup.txt~ call assert_equal(['line1', 'line2', 'line3'], getline(1,'$')) - let f=expand('%') + let f = expand('%') call assert_match('%testdir%Xbackup.txt\~', f) bw! bw! @@ -62,14 +78,11 @@ endfunc " Test for using a non-existing directory as a backup directory func Test_non_existing_backupdir() throw 'Skipped: Nvim auto-creates backup directory' - CheckNotBSD - let save_backup = &backupdir - set backupdir=./non_existing_dir + set backupdir=./non_existing_dir backupskip= 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 + set backupdir&vim backupskip&vim call delete('Xfile') endfunc -- cgit