annotate src/testdir/test_backup.vim @ 20812:d8628d75c47a v8.2.0958

patch 8.2.0958: not sufficient testing for buffer writing Commit: https://github.com/vim/vim/commit/1de5f7c81d5e78fb4d612134bd2dfa6ee9183fae Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 11 19:22:43 2020 +0200 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 https://github.com/vim/vim/issues/6238)
author Bram Moolenaar <Bram@vim.org>
date Thu, 11 Jun 2020 19:30:04 +0200
parents 77968a364ec4
children 93dae47699fb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for the backup function
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
20812
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
3 source check.vim
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
4
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 func Test_backup()
14501
77968a364ec4 patch 8.1.0264: backup tests fail when CWD is in /tmp
Christian Brabandt <cb@256bit.org>
parents: 14483
diff changeset
6 set backup backupdir=. backupskip=
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 new
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 call setline(1, ['line1', 'line2'])
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 :f Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 :w! Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 " backup file is only created after
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " writing a second time (before overwriting)
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 :w! Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 let l = readfile('Xbackup.txt~')
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_equal(['line1', 'line2'], l)
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 bw!
14501
77968a364ec4 patch 8.1.0264: backup tests fail when CWD is in /tmp
Christian Brabandt <cb@256bit.org>
parents: 14483
diff changeset
17 set backup&vim backupdir&vim backupskip&vim
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call delete('Xbackup.txt')
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call delete('Xbackup.txt~')
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 endfunc
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 func Test_backup2()
14501
77968a364ec4 patch 8.1.0264: backup tests fail when CWD is in /tmp
Christian Brabandt <cb@256bit.org>
parents: 14483
diff changeset
23 set backup backupdir=.// backupskip=
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 new
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call setline(1, ['line1', 'line2', 'line3'])
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 :f Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 :w! Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 " backup file is only created after
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 " writing a second time (before overwriting)
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 :w! Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 sp *Xbackup.txt~
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call assert_equal(['line1', 'line2', 'line3'], getline(1,'$'))
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 let f=expand('%')
14483
7fd8cb54da4a patch 8.1.0255: backup test fails when using shadow directory
Christian Brabandt <cb@256bit.org>
parents: 14475
diff changeset
34 call assert_match('%testdir%Xbackup.txt\~', f)
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 bw!
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 bw!
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 call delete('Xbackup.txt')
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 call delete(f)
14501
77968a364ec4 patch 8.1.0264: backup tests fail when CWD is in /tmp
Christian Brabandt <cb@256bit.org>
parents: 14483
diff changeset
39 set backup&vim backupdir&vim backupskip&vim
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 endfunc
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 func Test_backup2_backupcopy()
14501
77968a364ec4 patch 8.1.0264: backup tests fail when CWD is in /tmp
Christian Brabandt <cb@256bit.org>
parents: 14483
diff changeset
43 set backup backupdir=.// backupcopy=yes backupskip=
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 new
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 call setline(1, ['line1', 'line2', 'line3'])
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 :f Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 :w! Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 " backup file is only created after
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 " writing a second time (before overwriting)
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 :w! Xbackup.txt
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 sp *Xbackup.txt~
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call assert_equal(['line1', 'line2', 'line3'], getline(1,'$'))
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 let f=expand('%')
14483
7fd8cb54da4a patch 8.1.0255: backup test fails when using shadow directory
Christian Brabandt <cb@256bit.org>
parents: 14475
diff changeset
54 call assert_match('%testdir%Xbackup.txt\~', f)
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 bw!
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 bw!
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 call delete('Xbackup.txt')
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 call delete(f)
14501
77968a364ec4 patch 8.1.0264: backup tests fail when CWD is in /tmp
Christian Brabandt <cb@256bit.org>
parents: 14483
diff changeset
59 set backup&vim backupdir&vim backupcopy&vim backupskip&vim
14475
dddba3937532 patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 endfunc
20812
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
61
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
62 " Test for using a non-existing directory as a backup directory
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
63 func Test_non_existing_backupdir()
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
64 CheckNotBSD
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
65 let save_backup = &backupdir
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
66 set backupdir=./non_existing_dir
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
67 call writefile(['line1'], 'Xfile')
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
68 new Xfile
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
69 " TODO: write doesn't fail in Cirrus FreeBSD CI test
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
70 call assert_fails('write', 'E510:')
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
71 let &backupdir = save_backup
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
72 call delete('Xfile')
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
73 endfunc
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
74
d8628d75c47a patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 14501
diff changeset
75 " vim: shiftwidth=2 sts=2 expandtab