Mercurial > vim
annotate src/testdir/test_backup.vim @ 26576:5ea6db641b5e v8.2.3817
patch 8.2.3817: Vim9: Not using NL as command end does not work for :autocmd
Commit: https://github.com/vim/vim/commit/f87dac04c351583241ea1c4ec4228516431e6f22
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 15 17:53:40 2021 +0000
patch 8.2.3817: Vim9: Not using NL as command end does not work for :autocmd
Problem: Vim9: Not using NL as command end does not work for :autocmd.
Solution: Only ignore NL for commands with an expression argument.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 15 Dec 2021 19:00:02 +0100 |
parents | 93dae47699fb |
children | c8b1a683323c |
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 |
21580
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
22 func Test_backup_backupskip() |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
23 set backup backupdir=. backupskip=*.txt |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
24 new |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
25 call setline(1, ['line1', 'line2']) |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
26 :f Xbackup.txt |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
27 :w! Xbackup.txt |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
28 " backup file is only created after |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
29 " writing a second time (before overwriting) |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
30 :w! Xbackup.txt |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
31 call assert_false(filereadable('Xbackup.txt~')) |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
32 bw! |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
33 set backup&vim backupdir&vim backupskip&vim |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
34 call delete('Xbackup.txt') |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
35 call delete('Xbackup.txt~') |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
36 endfunc |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
37 |
14475
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 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
|
39 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
|
40 new |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 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
|
42 :f Xbackup.txt |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 :w! Xbackup.txt |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 " 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
|
45 " 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
|
46 :w! Xbackup.txt |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 sp *Xbackup.txt~ |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 call assert_equal(['line1', 'line2', 'line3'], getline(1,'$')) |
21580
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
49 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
|
50 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
|
51 bw! |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 bw! |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 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
|
54 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
|
55 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
|
56 endfunc |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 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
|
59 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
|
60 new |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 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
|
62 :f Xbackup.txt |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 :w! Xbackup.txt |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 " 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
|
65 " 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
|
66 :w! Xbackup.txt |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 sp *Xbackup.txt~ |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 call assert_equal(['line1', 'line2', 'line3'], getline(1,'$')) |
21580
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
69 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
|
70 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
|
71 bw! |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 bw! |
dddba3937532
patch 8.1.0251: using full path is not supported for 'backupdir'
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 endfunc |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
14501
diff
changeset
|
77 |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
14501
diff
changeset
|
78 " 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
|
79 func Test_non_existing_backupdir() |
21580
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
80 set backupdir=./non_existing_dir backupskip= |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
14501
diff
changeset
|
81 call writefile(['line1'], 'Xfile') |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
14501
diff
changeset
|
82 new Xfile |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
14501
diff
changeset
|
83 call assert_fails('write', 'E510:') |
21580
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
84 set backupdir&vim backupskip&vim |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
14501
diff
changeset
|
85 call delete('Xfile') |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
14501
diff
changeset
|
86 endfunc |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
14501
diff
changeset
|
87 |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
14501
diff
changeset
|
88 " vim: shiftwidth=2 sts=2 expandtab |