From af23d173883f47fd02a9a380c719e4428370b484 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 7 Mar 2023 04:13:04 +0100 Subject: test: move oldtests to test directory (#22536) The new oldtest directory is in test/old/testdir. The reason for this is that many tests have hardcoded the parent directory name to be 'testdir'. --- test/old/testdir/test_backup.vim | 89 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 test/old/testdir/test_backup.vim (limited to 'test/old/testdir/test_backup.vim') diff --git a/test/old/testdir/test_backup.vim b/test/old/testdir/test_backup.vim new file mode 100644 index 0000000000..d304773da4 --- /dev/null +++ b/test/old/testdir/test_backup.vim @@ -0,0 +1,89 @@ +" Tests for the backup function + +source check.vim + +func Test_backup() + set backup backupdir=. backupskip= + 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 + let l = readfile('Xbackup.txt~') + call assert_equal(['line1', 'line2'], l) + bw! + set backup&vim backupdir&vim backupskip&vim + call delete('Xbackup.txt') + 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 + call setline(1, ['line1', 'line2', 'line3']) + :f Xbackup.txt + :w! Xbackup.txt + " backup file is only created after + " writing a second time (before overwriting) + :w! Xbackup.txt + sp *Xbackup.txt~ + call assert_equal(['line1', 'line2', 'line3'], getline(1,'$')) + let f = expand('%') + call assert_match('%testdir%Xbackup.txt\~', f) + bw! + bw! + call delete('Xbackup.txt') + call delete(f) + set backup&vim backupdir&vim backupskip&vim +endfunc + +func Test_backup2_backupcopy() + set backup backupdir=.// backupcopy=yes backupskip= + new + call setline(1, ['line1', 'line2', 'line3']) + :f Xbackup.txt + :w! Xbackup.txt + " backup file is only created after + " writing a second time (before overwriting) + :w! Xbackup.txt + sp *Xbackup.txt~ + call assert_equal(['line1', 'line2', 'line3'], getline(1,'$')) + let f = expand('%') + call assert_match('%testdir%Xbackup.txt\~', f) + bw! + bw! + call delete('Xbackup.txt') + 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' + set backupdir=./non_existing_dir backupskip= + call writefile(['line1'], 'Xfile') + new Xfile + call assert_fails('write', 'E510:') + set backupdir&vim backupskip&vim + call delete('Xfile') +endfunc + +" vim: shiftwidth=2 sts=2 expandtab -- cgit From 28c2e83fb424395dbbdeacfc98f07ad4fa6c74c2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 21 Aug 2023 16:27:14 +0800 Subject: vim-patch:9.0.0313: using common name in tests leads to flaky tests Problem: Using common name in tests leads to flaky tests. Solution: Rename files and directories to be more specific. https://github.com/vim/vim/commit/e7cda97b6b578b33a42de0d27ac2876337c641ca Co-authored-by: Bram Moolenaar --- test/old/testdir/test_backup.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/old/testdir/test_backup.vim') diff --git a/test/old/testdir/test_backup.vim b/test/old/testdir/test_backup.vim index d304773da4..2331d3fb7d 100644 --- a/test/old/testdir/test_backup.vim +++ b/test/old/testdir/test_backup.vim @@ -79,11 +79,11 @@ endfunc func Test_non_existing_backupdir() throw 'Skipped: Nvim auto-creates backup directory' set backupdir=./non_existing_dir backupskip= - call writefile(['line1'], 'Xfile') - new Xfile + call writefile(['line1'], 'Xbackupdir') + new Xbackupdir call assert_fails('write', 'E510:') set backupdir&vim backupskip&vim - call delete('Xfile') + call delete('Xbackupdir') endfunc " vim: shiftwidth=2 sts=2 expandtab -- cgit From c170708023149221e5364a72094aa9ab94bfe8cd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 22 Aug 2023 17:44:04 +0800 Subject: vim-patch:9.0.0391: using separate delete() call instead of writefile() 'D' flag Problem: Using separate delete() call instead of writefile() 'D' flag. Solution: Use the writefile 'D' flag. https://github.com/vim/vim/commit/3411265a3698c3d5ef56d9b0c3bb237a9f5fdba1 Co-authored-by: Bram Moolenaar --- test/old/testdir/test_backup.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/old/testdir/test_backup.vim') diff --git a/test/old/testdir/test_backup.vim b/test/old/testdir/test_backup.vim index 2331d3fb7d..862ec2e4a1 100644 --- a/test/old/testdir/test_backup.vim +++ b/test/old/testdir/test_backup.vim @@ -79,11 +79,11 @@ endfunc func Test_non_existing_backupdir() throw 'Skipped: Nvim auto-creates backup directory' set backupdir=./non_existing_dir backupskip= - call writefile(['line1'], 'Xbackupdir') + call writefile(['line1'], 'Xbackupdir', 'D') new Xbackupdir call assert_fails('write', 'E510:') + set backupdir&vim backupskip&vim - call delete('Xbackupdir') endfunc " vim: shiftwidth=2 sts=2 expandtab -- cgit