Mercurial > vim
annotate src/testdir/test_writefile.vim @ 30517:9e6796c75c07 v9.0.0594
patch 9.0.0594: Makefile error message causes a shell error
Commit: https://github.com/vim/vim/commit/2cb4a89797477fc90c9d84b0d45e869369e39c75
Author: dundargoc <gocdundar@gmail.com>
Date: Mon Sep 26 16:02:48 2022 +0100
patch 9.0.0594: Makefile error message causes a shell error
Problem: Makefile error message causes a shell error.
Solution: Put the message in single quotes. (closes https://github.com/vim/vim/issues/11232)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 26 Sep 2022 17:15:02 +0200 |
parents | ea2935ec4435 |
children | bff3fa5f4c74 |
rev | line source |
---|---|
18386
105c6cf8b266
patch 8.1.2187: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents:
16869
diff
changeset
|
1 " Tests for the writefile() function and some :write commands. |
10068
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
19277
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
3 source check.vim |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
4 source term_util.vim |
19277
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
5 |
11519
4a1f7849fe86
patch 8.0.0642: writefile() continues after detecting an error
Christian Brabandt <cb@256bit.org>
parents:
10068
diff
changeset
|
6 func Test_writefile() |
10068
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 let f = tempname() |
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 call writefile(["over","written"], f, "b") |
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 call writefile(["hello","world"], f, "b") |
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 call writefile(["!", "good"], f, "a") |
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 call writefile(["morning"], f, "ab") |
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 call writefile(["", "vimmers"], f, "ab") |
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 let l = readfile(f) |
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call assert_equal("hello", l[0]) |
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 call assert_equal("world!", l[1]) |
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 call assert_equal("good", l[2]) |
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 call assert_equal("morning", l[3]) |
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 call assert_equal("vimmers", l[4]) |
c577c6a2e88b
commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 call delete(f) |
19695
1697a25328fd
patch 8.2.0404: writefile() error does not give a hint
Bram Moolenaar <Bram@vim.org>
parents:
19425
diff
changeset
|
20 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
21 call assert_fails('call writefile("text", "Xwffile")', 'E475: Invalid argument: writefile() first argument must be a List or a Blob') |
11519
4a1f7849fe86
patch 8.0.0642: writefile() continues after detecting an error
Christian Brabandt <cb@256bit.org>
parents:
10068
diff
changeset
|
22 endfunc |
4a1f7849fe86
patch 8.0.0642: writefile() continues after detecting an error
Christian Brabandt <cb@256bit.org>
parents:
10068
diff
changeset
|
23 |
18386
105c6cf8b266
patch 8.1.2187: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents:
16869
diff
changeset
|
24 func Test_writefile_ignore_regexp_error() |
105c6cf8b266
patch 8.1.2187: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents:
16869
diff
changeset
|
25 write Xt[z-a]est.txt |
105c6cf8b266
patch 8.1.2187: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents:
16869
diff
changeset
|
26 call delete('Xt[z-a]est.txt') |
105c6cf8b266
patch 8.1.2187: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents:
16869
diff
changeset
|
27 endfunc |
105c6cf8b266
patch 8.1.2187: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents:
16869
diff
changeset
|
28 |
11519
4a1f7849fe86
patch 8.0.0642: writefile() continues after detecting an error
Christian Brabandt <cb@256bit.org>
parents:
10068
diff
changeset
|
29 func Test_writefile_fails_gently() |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
30 call assert_fails('call writefile(["test"], "Xwffile", [])', 'E730:') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
31 call assert_false(filereadable("Xwffile")) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
32 call delete("Xwffile") |
11519
4a1f7849fe86
patch 8.0.0642: writefile() continues after detecting an error
Christian Brabandt <cb@256bit.org>
parents:
10068
diff
changeset
|
33 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
34 call assert_fails('call writefile(["test", [], [], [], "tset"], "Xwffile")', 'E730:') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
35 call assert_false(filereadable("Xwffile")) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
36 call delete("Xwffile") |
11519
4a1f7849fe86
patch 8.0.0642: writefile() continues after detecting an error
Christian Brabandt <cb@256bit.org>
parents:
10068
diff
changeset
|
37 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
38 call assert_fails('call writefile([], "Xwffile", [])', 'E730:') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
39 call assert_false(filereadable("Xwffile")) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
40 call delete("Xwffile") |
11519
4a1f7849fe86
patch 8.0.0642: writefile() continues after detecting an error
Christian Brabandt <cb@256bit.org>
parents:
10068
diff
changeset
|
41 |
4a1f7849fe86
patch 8.0.0642: writefile() continues after detecting an error
Christian Brabandt <cb@256bit.org>
parents:
10068
diff
changeset
|
42 call assert_fails('call writefile([], [])', 'E730:') |
4a1f7849fe86
patch 8.0.0642: writefile() continues after detecting an error
Christian Brabandt <cb@256bit.org>
parents:
10068
diff
changeset
|
43 endfunc |
11605
16ccaedce025
patch 8.0.0685: when conversion fails written file may be truncated
Christian Brabandt <cb@256bit.org>
parents:
11519
diff
changeset
|
44 |
16ccaedce025
patch 8.0.0685: when conversion fails written file may be truncated
Christian Brabandt <cb@256bit.org>
parents:
11519
diff
changeset
|
45 func Test_writefile_fails_conversion() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21580
diff
changeset
|
46 CheckFeature iconv |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21580
diff
changeset
|
47 if has('sun') |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21580
diff
changeset
|
48 throw 'Skipped: does not work on SunOS' |
11605
16ccaedce025
patch 8.0.0685: when conversion fails written file may be truncated
Christian Brabandt <cb@256bit.org>
parents:
11519
diff
changeset
|
49 endif |
16694
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
50 " Without a backup file the write won't happen if there is a conversion |
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
51 " error. |
16869
e264d45f268a
patch 8.1.1436: writefile test fails when run under /tmp
Bram Moolenaar <Bram@vim.org>
parents:
16694
diff
changeset
|
52 set nobackup nowritebackup backupdir=. backupskip= |
11605
16ccaedce025
patch 8.0.0685: when conversion fails written file may be truncated
Christian Brabandt <cb@256bit.org>
parents:
11519
diff
changeset
|
53 new |
16ccaedce025
patch 8.0.0685: when conversion fails written file may be truncated
Christian Brabandt <cb@256bit.org>
parents:
11519
diff
changeset
|
54 let contents = ["line one", "line two"] |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
55 call writefile(contents, 'Xwfcfile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
56 edit Xwfcfile |
11605
16ccaedce025
patch 8.0.0685: when conversion fails written file may be truncated
Christian Brabandt <cb@256bit.org>
parents:
11519
diff
changeset
|
57 call setline(1, ["first line", "cannot convert \u010b", "third line"]) |
16694
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
58 call assert_fails('write ++enc=cp932', 'E513:') |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
59 call assert_equal(contents, readfile('Xwfcfile')) |
11605
16ccaedce025
patch 8.0.0685: when conversion fails written file may be truncated
Christian Brabandt <cb@256bit.org>
parents:
11519
diff
changeset
|
60 |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
61 " With 'backupcopy' set, if there is a conversion error, the backup file is |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
62 " still created. |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
63 set backupcopy=yes writebackup& backup& |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
64 call delete('Xwfcfile' .. &backupext) |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
65 call assert_fails('write ++enc=cp932', 'E513:') |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
66 call assert_equal(contents, readfile('Xwfcfile')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
67 call assert_equal(contents, readfile('Xwfcfile' .. &backupext)) |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
68 set backupcopy& |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
69 %bw! |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
70 |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
71 " Conversion error during write |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
72 new |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
73 call setline(1, ["\U10000000"]) |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
74 let output = execute('write! ++enc=utf-16 Xwfcfile') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
75 call assert_match('CONVERSION ERROR', output) |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
76 let output = execute('write! ++enc=ucs-2 Xwfcfile') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
77 call assert_match('CONVERSION ERROR', output) |
30090
bd62c3173f72
patch 9.0.0381: writefile test leaves files behind
Bram Moolenaar <Bram@vim.org>
parents:
30083
diff
changeset
|
78 call delete('Xwfcfilz~') |
bd62c3173f72
patch 9.0.0381: writefile test leaves files behind
Bram Moolenaar <Bram@vim.org>
parents:
30083
diff
changeset
|
79 call delete('Xwfcfily~') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
80 %bw! |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
81 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
82 call delete('Xwfcfile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
83 call delete('Xwfcfile' .. &backupext) |
11605
16ccaedce025
patch 8.0.0685: when conversion fails written file may be truncated
Christian Brabandt <cb@256bit.org>
parents:
11519
diff
changeset
|
84 bwipe! |
16869
e264d45f268a
patch 8.1.1436: writefile test fails when run under /tmp
Bram Moolenaar <Bram@vim.org>
parents:
16694
diff
changeset
|
85 set backup& writebackup& backupdir&vim backupskip&vim |
11605
16ccaedce025
patch 8.0.0685: when conversion fails written file may be truncated
Christian Brabandt <cb@256bit.org>
parents:
11519
diff
changeset
|
86 endfunc |
12624
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
87 |
16694
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
88 func Test_writefile_fails_conversion2() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21580
diff
changeset
|
89 CheckFeature iconv |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21580
diff
changeset
|
90 if has('sun') |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21580
diff
changeset
|
91 throw 'Skipped: does not work on SunOS' |
16694
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
92 endif |
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
93 " With a backup file the write happens even if there is a conversion error, |
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
94 " but then the backup file must remain |
16869
e264d45f268a
patch 8.1.1436: writefile test fails when run under /tmp
Bram Moolenaar <Bram@vim.org>
parents:
16694
diff
changeset
|
95 set nobackup writebackup backupdir=. backupskip= |
16694
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
96 let contents = ["line one", "line two"] |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
97 call writefile(contents, 'Xwf2file_conversion_err') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
98 edit Xwf2file_conversion_err |
16694
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
99 call setline(1, ["first line", "cannot convert \u010b", "third line"]) |
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
100 set fileencoding=latin1 |
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
101 let output = execute('write') |
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
102 call assert_match('CONVERSION ERROR', output) |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
103 call assert_equal(contents, readfile('Xwf2file_conversion_err~')) |
16694
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
104 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
105 call delete('Xwf2file_conversion_err') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
106 call delete('Xwf2file_conversion_err~') |
16694
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
107 bwipe! |
16869
e264d45f268a
patch 8.1.1436: writefile test fails when run under /tmp
Bram Moolenaar <Bram@vim.org>
parents:
16694
diff
changeset
|
108 set backup& writebackup& backupdir&vim backupskip&vim |
16694
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
109 endfunc |
ed9b15758241
patch 8.1.1349: if writing runs into conversion error backup file is deleted
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
110 |
12624
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
111 func SetFlag(timer) |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
112 let g:flag = 1 |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
113 endfunc |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
114 |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
115 func Test_write_quit_split() |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
116 " Prevent exiting by splitting window on file write. |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
117 augroup testgroup |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
118 autocmd BufWritePre * split |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
119 augroup END |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
120 e! Xwqsfile |
12624
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
121 call setline(1, 'nothing') |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
122 wq |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
123 |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
124 if has('timers') |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
125 " timer will not run if "exiting" is still set |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
126 let g:flag = 0 |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
127 call timer_start(1, 'SetFlag') |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
128 sleep 50m |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
129 call assert_equal(1, g:flag) |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
130 unlet g:flag |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
131 endif |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
132 au! testgroup |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
133 bwipe Xwqsfile |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
134 call delete('Xwqsfile') |
12624
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
135 endfunc |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
136 |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
137 func Test_nowrite_quit_split() |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
138 " Prevent exiting by opening a help window. |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
139 e! Xnqsfile |
12624
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
140 help |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
141 wincmd w |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
142 exe winnr() . 'q' |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
143 |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
144 if has('timers') |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
145 " timer will not run if "exiting" is still set |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
146 let g:flag = 0 |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
147 call timer_start(1, 'SetFlag') |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
148 sleep 50m |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
149 call assert_equal(1, g:flag) |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
150 unlet g:flag |
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
151 endif |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
152 bwipe Xnqsfile |
12624
ae2802b6bf7d
patch 8.0.1190: unusable after opening new window in BufWritePre event
Christian Brabandt <cb@256bit.org>
parents:
11605
diff
changeset
|
153 endfunc |
12857
ffdf2e4b5d9a
patch 8.0.1305: writefile() never calls fsync()
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
154 |
ffdf2e4b5d9a
patch 8.0.1305: writefile() never calls fsync()
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
155 func Test_writefile_sync_arg() |
ffdf2e4b5d9a
patch 8.0.1305: writefile() never calls fsync()
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
156 " This doesn't check if fsync() works, only that the argument is accepted. |
ffdf2e4b5d9a
patch 8.0.1305: writefile() never calls fsync()
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
157 call writefile(['one'], 'Xtest', 's') |
ffdf2e4b5d9a
patch 8.0.1305: writefile() never calls fsync()
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
158 call writefile(['two'], 'Xtest', 'S') |
ffdf2e4b5d9a
patch 8.0.1305: writefile() never calls fsync()
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
159 call delete('Xtest') |
ffdf2e4b5d9a
patch 8.0.1305: writefile() never calls fsync()
Christian Brabandt <cb@256bit.org>
parents:
12624
diff
changeset
|
160 endfunc |
12926
98503d690368
patch 8.0.1339: no test for what 8.0.1335 fixes
Christian Brabandt <cb@256bit.org>
parents:
12857
diff
changeset
|
161 |
98503d690368
patch 8.0.1339: no test for what 8.0.1335 fixes
Christian Brabandt <cb@256bit.org>
parents:
12857
diff
changeset
|
162 func Test_writefile_sync_dev_stdout() |
21580
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
21532
diff
changeset
|
163 CheckUnix |
13744
d6553cde1292
patch 8.0.1744: on some systems /dev/stdout isn't writable
Christian Brabandt <cb@256bit.org>
parents:
12926
diff
changeset
|
164 if filewritable('/dev/stdout') |
d6553cde1292
patch 8.0.1744: on some systems /dev/stdout isn't writable
Christian Brabandt <cb@256bit.org>
parents:
12926
diff
changeset
|
165 " Just check that this doesn't cause an error. |
d6553cde1292
patch 8.0.1744: on some systems /dev/stdout isn't writable
Christian Brabandt <cb@256bit.org>
parents:
12926
diff
changeset
|
166 call writefile(['one'], '/dev/stdout') |
d6553cde1292
patch 8.0.1744: on some systems /dev/stdout isn't writable
Christian Brabandt <cb@256bit.org>
parents:
12926
diff
changeset
|
167 else |
d6553cde1292
patch 8.0.1744: on some systems /dev/stdout isn't writable
Christian Brabandt <cb@256bit.org>
parents:
12926
diff
changeset
|
168 throw 'Skipped: /dev/stdout is not writable' |
d6553cde1292
patch 8.0.1744: on some systems /dev/stdout isn't writable
Christian Brabandt <cb@256bit.org>
parents:
12926
diff
changeset
|
169 endif |
12926
98503d690368
patch 8.0.1339: no test for what 8.0.1335 fixes
Christian Brabandt <cb@256bit.org>
parents:
12857
diff
changeset
|
170 endfunc |
14642
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
171 |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
172 func Test_writefile_autowrite() |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
173 set autowrite |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
174 new |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
175 next Xa Xb Xc |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
176 call setline(1, 'aaa') |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
177 next |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
178 call assert_equal(['aaa'], readfile('Xa')) |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
179 call setline(1, 'bbb') |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
180 call assert_fails('edit XX') |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
181 call assert_false(filereadable('Xb')) |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
182 |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
183 set autowriteall |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
184 edit XX |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
185 call assert_equal(['bbb'], readfile('Xb')) |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
186 |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
187 bwipe! |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
188 call delete('Xa') |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
189 call delete('Xb') |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
190 set noautowrite |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
191 endfunc |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
192 |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
193 func Test_writefile_autowrite_nowrite() |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
194 set autowrite |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
195 new |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
196 next Xa Xb Xc |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
197 set buftype=nowrite |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
198 call setline(1, 'aaa') |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
199 let buf = bufnr('%') |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
200 " buffer contents silently lost |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
201 edit XX |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
202 call assert_false(filereadable('Xa')) |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
203 rewind |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
204 call assert_equal('', getline(1)) |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
205 |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
206 bwipe! |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
207 set noautowrite |
96858d612aff
patch 8.1.0334: 'autowrite' takes effect when buffer is not to be written
Christian Brabandt <cb@256bit.org>
parents:
13744
diff
changeset
|
208 endfunc |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
209 |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
210 " Test for ':w !<cmd>' to pipe lines from the current buffer to an external |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
211 " command. |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
212 func Test_write_pipe_to_cmd() |
19277
1b02482e6a61
patch 8.2.0197: some Ex commands not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19231
diff
changeset
|
213 CheckUnix |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
214 new |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
215 call setline(1, ['L1', 'L2', 'L3', 'L4']) |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
216 2,3w !cat > Xptfile |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
217 call assert_equal(['L2', 'L3'], readfile('Xptfile')) |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
218 close! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
219 call delete('Xptfile') |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
220 endfunc |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
221 |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
222 " Test for :saveas |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
223 func Test_saveas() |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
224 call assert_fails('saveas', 'E471:') |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
225 call writefile(['L1'], 'Xsafile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
226 new Xsafile |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
227 new |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
228 call setline(1, ['L1']) |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
229 call assert_fails('saveas Xsafile', 'E139:') |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
230 close! |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
231 enew | only |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
232 call delete('Xsafile') |
25569
8e9886ce88b3
patch 8.2.3321: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
233 |
8e9886ce88b3
patch 8.2.3321: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
234 " :saveas should detect and set the file type. |
8e9886ce88b3
patch 8.2.3321: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
235 syntax on |
8e9886ce88b3
patch 8.2.3321: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
236 saveas! Xsaveas.pl |
8e9886ce88b3
patch 8.2.3321: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
237 call assert_equal('perl', &filetype) |
8e9886ce88b3
patch 8.2.3321: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
238 syntax off |
8e9886ce88b3
patch 8.2.3321: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
239 %bw! |
8e9886ce88b3
patch 8.2.3321: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents:
24747
diff
changeset
|
240 call delete('Xsaveas.pl') |
30347
ea2935ec4435
patch 9.0.0509: confusing error for "saveas" command with "nofile" buffer
Bram Moolenaar <Bram@vim.org>
parents:
30150
diff
changeset
|
241 |
ea2935ec4435
patch 9.0.0509: confusing error for "saveas" command with "nofile" buffer
Bram Moolenaar <Bram@vim.org>
parents:
30150
diff
changeset
|
242 " :saveas fails for "nofile" buffer |
ea2935ec4435
patch 9.0.0509: confusing error for "saveas" command with "nofile" buffer
Bram Moolenaar <Bram@vim.org>
parents:
30150
diff
changeset
|
243 set buftype=nofile |
ea2935ec4435
patch 9.0.0509: confusing error for "saveas" command with "nofile" buffer
Bram Moolenaar <Bram@vim.org>
parents:
30150
diff
changeset
|
244 call assert_fails('saveas Xsafile', 'E676: No matching autocommands for buftype=nofile buffer') |
ea2935ec4435
patch 9.0.0509: confusing error for "saveas" command with "nofile" buffer
Bram Moolenaar <Bram@vim.org>
parents:
30150
diff
changeset
|
245 |
ea2935ec4435
patch 9.0.0509: confusing error for "saveas" command with "nofile" buffer
Bram Moolenaar <Bram@vim.org>
parents:
30150
diff
changeset
|
246 bwipe! |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
247 endfunc |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
248 |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
249 func Test_write_errors() |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
250 " Test for writing partial buffer |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
251 call writefile(['L1', 'L2', 'L3'], 'Xwefile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
252 new Xwefile |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
253 call assert_fails('1,2write', 'E140:') |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
254 close! |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
255 |
19384
6c944fee0d7e
patch 8.2.0250: test_clear_search_pat() is unused
Bram Moolenaar <Bram@vim.org>
parents:
19277
diff
changeset
|
256 call assert_fails('w > Xtest', 'E494:') |
19425
67fbe280a502
patch 8.2.0270: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19384
diff
changeset
|
257 |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
258 " Try to overwrite a directory |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
259 if has('unix') |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
260 call mkdir('Xwerdir1') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
261 call assert_fails('write Xwerdir1', 'E17:') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
262 call delete('Xwerdir1', 'd') |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
263 endif |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
264 |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
265 " Test for :wall for a buffer with no name |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
266 enew | only |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
267 call setline(1, ['L1']) |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
268 call assert_fails('wall', 'E141:') |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
269 enew! |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
270 |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
271 " Test for writing a 'readonly' file |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
272 new Xwefile |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
273 set readonly |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
274 call assert_fails('write', 'E45:') |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
275 close |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
276 |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
277 " Test for writing to a read-only file |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
278 new Xwefile |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
279 call setfperm('Xwefile', 'r--r--r--') |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
280 call assert_fails('write', 'E505:') |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
281 call setfperm('Xwefile', 'rw-rw-rw-') |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
282 close |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
283 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
284 call delete('Xwefile') |
20178
2fb397573541
patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents:
19695
diff
changeset
|
285 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
286 call writefile(test_null_list(), 'Xwefile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
287 call assert_false(filereadable('Xwefile')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
288 call writefile(test_null_blob(), 'Xwefile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
289 call assert_false(filereadable('Xwefile')) |
20178
2fb397573541
patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents:
19695
diff
changeset
|
290 call assert_fails('call writefile([], "")', 'E482:') |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
291 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
292 " very long file name |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
293 let long_fname = repeat('n', 5000) |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
294 call assert_fails('exe "w " .. long_fname', 'E75:') |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
295 call assert_fails('call writefile([], long_fname)', 'E482:') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
296 |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
297 " Test for writing to a block device on Unix-like systems |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
298 if has('unix') && getfperm('/dev/loop0') != '' |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
299 \ && getftype('/dev/loop0') == 'bdev' && !IsRoot() |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
300 new |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
301 edit /dev/loop0 |
24634
d3c4ecf67604
patch 8.2.2856: get readonly error for device that can't be written to
Bram Moolenaar <Bram@vim.org>
parents:
24620
diff
changeset
|
302 call assert_fails('write', 'E503: ') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
303 call assert_fails('write!', 'E503: ') |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
304 close! |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
305 endif |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
306 endfunc |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
307 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
308 " Test for writing to a file which is modified after Vim read it |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
309 func Test_write_file_mtime() |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
310 CheckEnglish |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
311 CheckRunVimInTerminal |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
312 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
313 " First read the file into a buffer |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
314 call writefile(["Line1", "Line2"], 'Xwfmfile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
315 let old_ftime = getftime('Xwfmfile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
316 let buf = RunVimInTerminal('Xwfmfile', #{rows : 10}) |
21897
e0af4660dfc7
patch 8.2.1498: on slow systems tests can be flaky
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
317 call TermWait(buf) |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
318 call term_sendkeys(buf, ":set noswapfile\<CR>") |
21897
e0af4660dfc7
patch 8.2.1498: on slow systems tests can be flaky
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
319 call TermWait(buf) |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
320 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
321 " Modify the file directly. Make sure the file modification time is |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
322 " different. Note that on Linux/Unix, the file is considered modified |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
323 " outside, only if the difference is 2 seconds or more |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
324 sleep 1 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
325 call writefile(["Line3", "Line4"], 'Xwfmfile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
326 let new_ftime = getftime('Xwfmfile') |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
327 while new_ftime - old_ftime < 2 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
328 sleep 100m |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
329 call writefile(["Line3", "Line4"], 'Xwfmfile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
330 let new_ftime = getftime('Xwfmfile') |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
331 endwhile |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
332 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
333 " Try to overwrite the file and check for the prompt |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
334 call term_sendkeys(buf, ":w\<CR>") |
21897
e0af4660dfc7
patch 8.2.1498: on slow systems tests can be flaky
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
335 call TermWait(buf) |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
336 call WaitForAssert({-> assert_equal("WARNING: The file has been changed since reading it!!!", term_getline(buf, 9))}) |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
337 call assert_equal("Do you really want to write to it (y/n)?", |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
338 \ term_getline(buf, 10)) |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
339 call term_sendkeys(buf, "n\<CR>") |
21897
e0af4660dfc7
patch 8.2.1498: on slow systems tests can be flaky
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
340 call TermWait(buf) |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
341 call assert_equal(new_ftime, getftime('Xwfmfile')) |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
342 call term_sendkeys(buf, ":w\<CR>") |
21897
e0af4660dfc7
patch 8.2.1498: on slow systems tests can be flaky
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
343 call TermWait(buf) |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
344 call term_sendkeys(buf, "y\<CR>") |
21897
e0af4660dfc7
patch 8.2.1498: on slow systems tests can be flaky
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
345 call TermWait(buf) |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
346 call WaitForAssert({-> assert_equal('Line2', readfile('Xwfmfile')[1])}) |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
347 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
348 " clean up |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
349 call StopVimInTerminal(buf) |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
350 call delete('Xwfmfile') |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
351 endfunc |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
352 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
353 " Test for an autocmd unloading a buffer during a write command |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
354 func Test_write_autocmd_unloadbuf_lockmark() |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
355 augroup WriteTest |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
356 autocmd BufWritePre Xwaufile enew | write |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
357 augroup END |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
358 e Xwaufile |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21897
diff
changeset
|
359 call assert_fails('lockmarks write', ['E32:', 'E203:']) |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
360 augroup WriteTest |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
361 au! |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
362 augroup END |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
363 augroup! WriteTest |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
364 endfunc |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
365 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
366 " Test for writing a buffer with 'acwrite' but without autocmds |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
367 func Test_write_acwrite_error() |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
368 new Xwaefile |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
369 call setline(1, ['line1', 'line2', 'line3']) |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
370 set buftype=acwrite |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
371 call assert_fails('write', 'E676:') |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
372 call assert_fails('1,2write!', 'E676:') |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
373 call assert_fails('w >>', 'E676:') |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
374 close! |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
375 endfunc |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
376 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
377 " Test for adding and removing lines from an autocmd when writing a buffer |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
378 func Test_write_autocmd_add_remove_lines() |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
379 new Xwaafile |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
380 call setline(1, ['aaa', 'bbb', 'ccc', 'ddd']) |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
381 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
382 " Autocmd deleting lines from the file when writing a partial file |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
383 augroup WriteTest2 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
384 au! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
385 autocmd FileWritePre Xwaafile 1,2d |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
386 augroup END |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
387 call assert_fails('2,3w!', 'E204:') |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
388 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
389 " Autocmd adding lines to a file when writing a partial file |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
390 augroup WriteTest2 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
391 au! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
392 autocmd FileWritePre Xwaafile call append(0, ['xxx', 'yyy']) |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
393 augroup END |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
394 %d |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
395 call setline(1, ['aaa', 'bbb', 'ccc', 'ddd']) |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
396 1,2w! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
397 call assert_equal(['xxx', 'yyy', 'aaa', 'bbb'], readfile('Xwaafile')) |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
398 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
399 " Autocmd deleting lines from the file when writing the whole file |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
400 augroup WriteTest2 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
401 au! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
402 autocmd BufWritePre Xwaafile 1,2d |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
403 augroup END |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
404 %d |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
405 call setline(1, ['aaa', 'bbb', 'ccc', 'ddd']) |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
406 w |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
407 call assert_equal(['ccc', 'ddd'], readfile('Xwaafile')) |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
408 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
409 augroup WriteTest2 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
410 au! |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
411 augroup END |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
412 augroup! WriteTest2 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
413 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
414 close! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
415 call delete('Xwaafile') |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
416 endfunc |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
417 |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
418 " Test for writing to a readonly file |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
419 func Test_write_readonly() |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
420 call writefile([], 'Xwrofile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
421 call setfperm('Xwrofile', "r--------") |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
422 edit Xwrofile |
21580
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
21532
diff
changeset
|
423 set noreadonly backupskip= |
20625
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
424 call assert_fails('write', 'E505:') |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
425 let save_cpo = &cpo |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
426 set cpo+=W |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
427 call assert_fails('write!', 'E504:') |
116c7bd5e980
patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
428 let &cpo = save_cpo |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
429 call setline(1, ['line1']) |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
430 write! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
431 call assert_equal(['line1'], readfile('Xwrofile')) |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
432 |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
433 " Auto-saving a readonly file should fail with 'autowriteall' |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
434 %bw! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
435 e Xwrofile |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
436 set noreadonly autowriteall |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
437 call setline(1, ['aaaa']) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
438 call assert_fails('n', 'E505:') |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
439 set cpo+=W |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
440 call assert_fails('n', 'E504:') |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
441 set cpo-=W |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
442 set autowriteall& |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
443 |
21580
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
21532
diff
changeset
|
444 set backupskip& |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
445 call delete('Xwrofile') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
446 %bw! |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
447 endfunc |
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
448 |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
449 " Test for 'patchmode' |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
450 func Test_patchmode() |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
451 call writefile(['one'], 'Xpafile') |
21580
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
21532
diff
changeset
|
452 set patchmode=.orig nobackup backupskip= writebackup |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
453 new Xpafile |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
454 call setline(1, 'two') |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
455 " first write should create the .orig file |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
456 write |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
457 call assert_equal(['one'], readfile('Xpafile.orig')) |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
458 call setline(1, 'three') |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
459 " subsequent writes should not create/modify the .orig file |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
460 write |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
461 call assert_equal(['one'], readfile('Xpafile.orig')) |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
462 |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
463 " use 'patchmode' with 'nobackup' and 'nowritebackup' to create an empty |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
464 " original file |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
465 call delete('Xpafile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
466 call delete('Xpafile.orig') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
467 %bw! |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
468 set patchmode=.orig nobackup nowritebackup |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
469 edit Xpafile |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
470 call setline(1, ['xxx']) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
471 write |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
472 call assert_equal(['xxx'], readfile('Xpafile')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
473 call assert_equal([], readfile('Xpafile.orig')) |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
474 |
21580
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
21532
diff
changeset
|
475 set patchmode& backup& backupskip& writebackup& |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
476 call delete('Xpafile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
477 call delete('Xpafile.orig') |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
478 endfunc |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
479 |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
480 " Test for writing to a file in a readonly directory |
24057
eeb5518a37aa
patch 8.2.2570: tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents:
23314
diff
changeset
|
481 " NOTE: if you run tests as root this will fail. Don't run tests as root! |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
482 func Test_write_readonly_dir() |
21580
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
21532
diff
changeset
|
483 " On MS-Windows, modifying files in a read-only directory is allowed. |
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
21532
diff
changeset
|
484 CheckUnix |
24164
2259c73cc1d9
patch 8.2.2623: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents:
24057
diff
changeset
|
485 " Root can do it too. |
2259c73cc1d9
patch 8.2.2623: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents:
24057
diff
changeset
|
486 CheckNotRoot |
2259c73cc1d9
patch 8.2.2623: some tests fail when run as root
Bram Moolenaar <Bram@vim.org>
parents:
24057
diff
changeset
|
487 |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
488 call mkdir('Xrodir/') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
489 call writefile(['one'], 'Xrodir/Xfile1') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
490 call setfperm('Xrodir', 'r-xr--r--') |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
491 " try to create a new file in the directory |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
492 new Xrodir/Xfile2 |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
493 call setline(1, 'two') |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
494 call assert_fails('write', 'E212:') |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
495 " try to create a backup file in the directory |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
496 edit! Xrodir/Xfile1 |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
497 set backupdir=./Xrodir backupskip= |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
498 set patchmode=.orig |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
499 call assert_fails('write', 'E509:') |
29970
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
500 call setfperm('Xrodir', 'rwxr--r--') |
d891115c0aea
patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents:
28081
diff
changeset
|
501 call delete('Xrodir', 'rf') |
21580
93dae47699fb
patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
21532
diff
changeset
|
502 set backupdir& backupskip& patchmode& |
20812
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
503 endfunc |
d8628d75c47a
patch 8.2.0958: not sufficient testing for buffer writing
Bram Moolenaar <Bram@vim.org>
parents:
20625
diff
changeset
|
504 |
20861
1725bb56178a
patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
505 " Test for writing a file using invalid file encoding |
1725bb56178a
patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
506 func Test_write_invalid_encoding() |
1725bb56178a
patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
507 new |
1725bb56178a
patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
508 call setline(1, 'abc') |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
509 call assert_fails('write ++enc=axbyc Xiefile', 'E213:') |
20861
1725bb56178a
patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
510 close! |
1725bb56178a
patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
511 endfunc |
1725bb56178a
patch 8.2.0982: insufficient testing for reading/writing files
Bram Moolenaar <Bram@vim.org>
parents:
20812
diff
changeset
|
512 |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
513 " Tests for reading and writing files with conversion for Win32. |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
514 func Test_write_file_encoding() |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
515 CheckMSWindows |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
516 let save_encoding = &encoding |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
517 let save_fileencodings = &fileencodings |
24747
7da496081b91
patch 8.2.2912: MS-Windows: most users expect using Unicode
Bram Moolenaar <Bram@vim.org>
parents:
24723
diff
changeset
|
518 set encoding=latin1 fileencodings& |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
519 let text =<< trim END |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
520 1 utf-8 text: Ð”Ð»Ñ Vim version 6.2. ПоÑледнее изменение: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
521 2 cp1251 text: Äëÿ Vim version 6.2. Ïîñëåäíåå èçìåíåíèå: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
522 3 cp866 text: „«ï Vim version 6.2. ®á«¥¤¥¥ ¨§¬¥¥¨¥: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
523 END |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
524 call writefile(text, 'Xwfefile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
525 edit Xwfefile |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
526 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
527 " write tests: |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
528 " combine three values for 'encoding' with three values for 'fileencoding' |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
529 " also write files for read tests |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
530 call cursor(1, 1) |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
531 set encoding=utf-8 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
532 .w! ++enc=utf-8 Xwfetest |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
533 .w ++enc=cp1251 >> Xwfetest |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
534 .w ++enc=cp866 >> Xwfetest |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
535 .w! ++enc=utf-8 Xutf8 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
536 let expected =<< trim END |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
537 1 utf-8 text: Ð”Ð»Ñ Vim version 6.2. ПоÑледнее изменение: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
538 1 utf-8 text: Äëÿ Vim version 6.2. Ïîñëåäíåå èçìåíåíèå: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
539 1 utf-8 text: „«ï Vim version 6.2. ®á«¥¤¥¥ ¨§¬¥¥¨¥: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
540 END |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
541 call assert_equal(expected, readfile('Xwfetest')) |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
542 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
543 call cursor(2, 1) |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
544 set encoding=cp1251 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
545 .w! ++enc=utf-8 Xwfetest |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
546 .w ++enc=cp1251 >> Xwfetest |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
547 .w ++enc=cp866 >> Xwfetest |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
548 .w! ++enc=cp1251 Xcp1251 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
549 let expected =<< trim END |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
550 2 cp1251 text: Ð”Ð»Ñ Vim version 6.2. ПоÑледнее изменение: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
551 2 cp1251 text: Äëÿ Vim version 6.2. Ïîñëåäíåå èçìåíåíèå: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
552 2 cp1251 text: „«ï Vim version 6.2. ®á«¥¤¥¥ ¨§¬¥¥¨¥: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
553 END |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
554 call assert_equal(expected, readfile('Xwfetest')) |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
555 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
556 call cursor(3, 1) |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
557 set encoding=cp866 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
558 .w! ++enc=utf-8 Xwfetest |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
559 .w ++enc=cp1251 >> Xwfetest |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
560 .w ++enc=cp866 >> Xwfetest |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
561 .w! ++enc=cp866 Xcp866 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
562 let expected =<< trim END |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
563 3 cp866 text: Ð”Ð»Ñ Vim version 6.2. ПоÑледнее изменение: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
564 3 cp866 text: Äëÿ Vim version 6.2. Ïîñëåäíåå èçìåíåíèå: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
565 3 cp866 text: „«ï Vim version 6.2. ®á«¥¤¥¥ ¨§¬¥¥¨¥: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
566 END |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
567 call assert_equal(expected, readfile('Xwfetest')) |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
568 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
569 " read three 'fileencoding's with utf-8 'encoding' |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
570 set encoding=utf-8 fencs=utf-8,cp1251 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
571 e Xutf8 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
572 .w! ++enc=utf-8 Xwfetest |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
573 e Xcp1251 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
574 .w ++enc=utf-8 >> Xwfetest |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
575 set fencs=utf-8,cp866 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
576 e Xcp866 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
577 .w ++enc=utf-8 >> Xwfetest |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
578 let expected =<< trim END |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
579 1 utf-8 text: Ð”Ð»Ñ Vim version 6.2. ПоÑледнее изменение: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
580 2 cp1251 text: Ð”Ð»Ñ Vim version 6.2. ПоÑледнее изменение: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
581 3 cp866 text: Ð”Ð»Ñ Vim version 6.2. ПоÑледнее изменение: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
582 END |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
583 call assert_equal(expected, readfile('Xwfetest')) |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
584 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
585 " read three 'fileencoding's with cp1251 'encoding' |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
586 set encoding=utf-8 fencs=utf-8,cp1251 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
587 e Xutf8 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
588 .w! ++enc=cp1251 Xwfetest |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
589 e Xcp1251 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
590 .w ++enc=cp1251 >> Xwfetest |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
591 set fencs=utf-8,cp866 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
592 e Xcp866 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
593 .w ++enc=cp1251 >> Xwfetest |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
594 let expected =<< trim END |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
595 1 utf-8 text: Äëÿ Vim version 6.2. Ïîñëåäíåå èçìåíåíèå: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
596 2 cp1251 text: Äëÿ Vim version 6.2. Ïîñëåäíåå èçìåíåíèå: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
597 3 cp866 text: Äëÿ Vim version 6.2. Ïîñëåäíåå èçìåíåíèå: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
598 END |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
599 call assert_equal(expected, readfile('Xwfetest')) |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
600 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
601 " read three 'fileencoding's with cp866 'encoding' |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
602 set encoding=cp866 fencs=utf-8,cp1251 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
603 e Xutf8 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
604 .w! ++enc=cp866 Xwfetest |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
605 e Xcp1251 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
606 .w ++enc=cp866 >> Xwfetest |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
607 set fencs=utf-8,cp866 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
608 e Xcp866 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
609 .w ++enc=cp866 >> Xwfetest |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
610 let expected =<< trim END |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
611 1 utf-8 text: „«ï Vim version 6.2. ®á«¥¤¥¥ ¨§¬¥¥¨¥: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
612 2 cp1251 text: „«ï Vim version 6.2. ®á«¥¤¥¥ ¨§¬¥¥¨¥: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
613 3 cp866 text: „«ï Vim version 6.2. ®á«¥¤¥¥ ¨§¬¥¥¨¥: 1970 Jan 01 |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
614 END |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
615 call assert_equal(expected, readfile('Xwfetest')) |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
616 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
617 call delete('Xwfefile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
618 call delete('Xwfetest') |
21510
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
619 call delete('Xutf8') |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
620 call delete('Xcp1251') |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
621 call delete('Xcp866') |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
622 let &encoding = save_encoding |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
623 let &fileencodings = save_fileencodings |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
624 %bw! |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
625 endfunc |
31cb78014fe4
patch 8.2.1305: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
626 |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
627 " Test for writing and reading a file starting with a BOM. |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
628 " Byte Order Mark (BOM) character for various encodings is below: |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
629 " UTF-8 : EF BB BF |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
630 " UTF-16 (BE): FE FF |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
631 " UTF-16 (LE): FF FE |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
632 " UTF-32 (BE): 00 00 FE FF |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
633 " UTF-32 (LE): FF FE 00 00 |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
634 func Test_readwrite_file_with_bom() |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
635 let utf8_bom = "\xEF\xBB\xBF" |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
636 let utf16be_bom = "\xFE\xFF" |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
637 let utf16le_bom = "\xFF\xFE" |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
638 let utf32be_bom = "\n\n\xFE\xFF" |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
639 let utf32le_bom = "\xFF\xFE\n\n" |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
640 let save_fileencoding = &fileencoding |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
641 set cpoptions+=S |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
642 |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
643 " Check that editing a latin1 file doesn't see a BOM |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
644 call writefile(["\xFE\xFElatin-1"], 'Xrwtest1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
645 edit Xrwtest1 |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
646 call assert_equal('latin1', &fileencoding) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
647 call assert_equal(0, &bomb) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
648 set fenc=latin1 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
649 write Xrwfile2 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
650 call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xrwfile2', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
651 set bomb fenc=latin1 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
652 write Xrwtest3 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
653 call assert_equal(["\xFE\xFElatin-1", ''], readfile('Xrwtest3', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
654 set bomb& |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
655 |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
656 " Check utf-8 BOM |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
657 %bw! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
658 call writefile([utf8_bom .. "utf-8"], 'Xrwtest1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
659 edit! Xrwtest1 |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
660 call assert_equal('utf-8', &fileencoding) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
661 call assert_equal(1, &bomb) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
662 call assert_equal('utf-8', getline(1)) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
663 set fenc=latin1 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
664 write! Xrwfile2 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
665 call assert_equal(['utf-8', ''], readfile('Xrwfile2', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
666 set fenc=utf-8 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
667 w! Xrwtest3 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
668 call assert_equal([utf8_bom .. "utf-8", ''], readfile('Xrwtest3', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
669 |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
670 " Check utf-8 with an error (will fall back to latin-1) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
671 %bw! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
672 call writefile([utf8_bom .. "utf-8\x80err"], 'Xrwtest1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
673 edit! Xrwtest1 |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
674 call assert_equal('latin1', &fileencoding) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
675 call assert_equal(0, &bomb) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
676 call assert_equal("\xC3\xAF\xC2\xBB\xC2\xBFutf-8\xC2\x80err", getline(1)) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
677 set fenc=latin1 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
678 write! Xrwfile2 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
679 call assert_equal([utf8_bom .. "utf-8\x80err", ''], readfile('Xrwfile2', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
680 set fenc=utf-8 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
681 w! Xrwtest3 |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
682 call assert_equal(["\xC3\xAF\xC2\xBB\xC2\xBFutf-8\xC2\x80err", ''], |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
683 \ readfile('Xrwtest3', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
684 |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
685 " Check ucs-2 BOM |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
686 %bw! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
687 call writefile([utf16be_bom .. "\nu\nc\ns\n-\n2\n"], 'Xrwtest1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
688 edit! Xrwtest1 |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
689 call assert_equal('utf-16', &fileencoding) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
690 call assert_equal(1, &bomb) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
691 call assert_equal('ucs-2', getline(1)) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
692 set fenc=latin1 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
693 write! Xrwfile2 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
694 call assert_equal(["ucs-2", ''], readfile('Xrwfile2', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
695 set fenc=ucs-2 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
696 w! Xrwtest3 |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
697 call assert_equal([utf16be_bom .. "\nu\nc\ns\n-\n2\n", ''], |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
698 \ readfile('Xrwtest3', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
699 |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
700 " Check ucs-2le BOM |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
701 %bw! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
702 call writefile([utf16le_bom .. "u\nc\ns\n-\n2\nl\ne\n"], 'Xrwtest1') |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
703 " Need to add a NUL byte after the NL byte |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
704 call writefile(0z00, 'Xrwtest1', 'a') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
705 edit! Xrwtest1 |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
706 call assert_equal('utf-16le', &fileencoding) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
707 call assert_equal(1, &bomb) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
708 call assert_equal('ucs-2le', getline(1)) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
709 set fenc=latin1 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
710 write! Xrwfile2 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
711 call assert_equal(["ucs-2le", ''], readfile('Xrwfile2', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
712 set fenc=ucs-2le |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
713 w! Xrwtest3 |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
714 call assert_equal([utf16le_bom .. "u\nc\ns\n-\n2\nl\ne\n", "\n"], |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
715 \ readfile('Xrwtest3', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
716 |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
717 " Check ucs-4 BOM |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
718 %bw! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
719 call writefile([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n"], 'Xrwtest1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
720 edit! Xrwtest1 |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
721 call assert_equal('ucs-4', &fileencoding) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
722 call assert_equal(1, &bomb) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
723 call assert_equal('ucs-4', getline(1)) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
724 set fenc=latin1 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
725 write! Xrwfile2 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
726 call assert_equal(["ucs-4", ''], readfile('Xrwfile2', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
727 set fenc=ucs-4 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
728 w! Xrwtest3 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
729 call assert_equal([utf32be_bom .. "\n\n\nu\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\n", ''], readfile('Xrwtest3', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
730 |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
731 " Check ucs-4le BOM |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
732 %bw! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
733 call writefile([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n"], 'Xrwtest1') |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
734 " Need to add three NUL bytes after the NL byte |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
735 call writefile(0z000000, 'Xrwtest1', 'a') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
736 edit! Xrwtest1 |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
737 call assert_equal('ucs-4le', &fileencoding) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
738 call assert_equal(1, &bomb) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
739 call assert_equal('ucs-4le', getline(1)) |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
740 set fenc=latin1 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
741 write! Xrwfile2 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
742 call assert_equal(["ucs-4le", ''], readfile('Xrwfile2', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
743 set fenc=ucs-4le |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
744 w! Xrwtest3 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
745 call assert_equal([utf32le_bom .. "u\n\n\nc\n\n\ns\n\n\n-\n\n\n4\n\n\nl\n\n\ne\n\n\n", "\n\n\n"], readfile('Xrwtest3', 'b')) |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
746 |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
747 set cpoptions-=S |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
748 let &fileencoding = save_fileencoding |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
749 call delete('Xrwtest1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
750 call delete('Xrwfile2') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
751 call delete('Xrwtest3') |
21532
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
752 %bw! |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
753 endfunc |
dc1c26547a42
patch 8.2.1316: test 42 is still old style
Bram Moolenaar <Bram@vim.org>
parents:
21510
diff
changeset
|
754 |
23308
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
755 func Test_read_write_bin() |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
756 " write file missing EOL |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
757 call writefile(['noeol'], "XNoEolSetEol", 'bS') |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
758 call assert_equal(0z6E6F656F6C, readfile('XNoEolSetEol', 'B')) |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
759 |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
760 " when file is read 'eol' is off |
23314
7d09c9cdaab8
patch 8.2.2202: write file test still fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
23312
diff
changeset
|
761 set nofixeol |
7d09c9cdaab8
patch 8.2.2202: write file test still fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
23312
diff
changeset
|
762 e! ++ff=unix XNoEolSetEol |
23308
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
763 call assert_equal(0, &eol) |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
764 |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
765 " writing with 'eol' set adds the newline |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
766 setlocal eol |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
767 w |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
768 call assert_equal(0z6E6F656F6C0A, readfile('XNoEolSetEol', 'B')) |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
769 |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
770 call delete('XNoEolSetEol') |
24669
d7644bffe128
patch 8.2.2873: not enough tests for writing buffers
Bram Moolenaar <Bram@vim.org>
parents:
24634
diff
changeset
|
771 set ff& fixeol& |
23312
4841385b981a
patch 8.2.2201: write file test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
23308
diff
changeset
|
772 bwipe! XNoEolSetEol |
23308
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
773 endfunc |
4d6c1b17f66a
patch 8.2.2199: first write after setting 'eol' does not have NL added
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
774 |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
775 " Test for the 'backupcopy' option when writing files |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
776 func Test_backupcopy() |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
777 CheckUnix |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
778 set backupskip= |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
779 " With the default 'backupcopy' setting, saving a symbolic link file |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
780 " should not break the link. |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
781 set backupcopy& |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
782 call writefile(['1111'], 'Xbcfile1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
783 silent !ln -s Xbcfile1 Xbcfile2 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
784 new Xbcfile2 |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
785 call setline(1, ['2222']) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
786 write |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
787 close |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
788 call assert_equal(['2222'], readfile('Xbcfile1')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
789 call assert_equal('Xbcfile1', resolve('Xbcfile2')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
790 call assert_equal('link', getftype('Xbcfile2')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
791 call delete('Xbcfile1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
792 call delete('Xbcfile2') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
793 |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
794 " With the 'backupcopy' set to 'breaksymlink', saving a symbolic link file |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
795 " should break the link. |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
796 set backupcopy=yes,breaksymlink |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
797 call writefile(['1111'], 'Xbcfile1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
798 silent !ln -s Xbcfile1 Xbcfile2 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
799 new Xbcfile2 |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
800 call setline(1, ['2222']) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
801 write |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
802 close |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
803 call assert_equal(['1111'], readfile('Xbcfile1')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
804 call assert_equal(['2222'], readfile('Xbcfile2')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
805 call assert_equal('Xbcfile2', resolve('Xbcfile2')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
806 call assert_equal('file', getftype('Xbcfile2')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
807 call delete('Xbcfile1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
808 call delete('Xbcfile2') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
809 set backupcopy& |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
810 |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
811 " With the default 'backupcopy' setting, saving a hard link file |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
812 " should not break the link. |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
813 set backupcopy& |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
814 call writefile(['1111'], 'Xbcfile1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
815 silent !ln Xbcfile1 Xbcfile2 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
816 new Xbcfile2 |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
817 call setline(1, ['2222']) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
818 write |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
819 close |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
820 call assert_equal(['2222'], readfile('Xbcfile1')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
821 call delete('Xbcfile1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
822 call delete('Xbcfile2') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
823 |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
824 " With the 'backupcopy' set to 'breaksymlink', saving a hard link file |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
825 " should break the link. |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
826 set backupcopy=yes,breakhardlink |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
827 call writefile(['1111'], 'Xbcfile1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
828 silent !ln Xbcfile1 Xbcfile2 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
829 new Xbcfile2 |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
830 call setline(1, ['2222']) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
831 write |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
832 call assert_equal(['1111'], readfile('Xbcfile1')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
833 call assert_equal(['2222'], readfile('Xbcfile2')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
834 call delete('Xbcfile1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
835 call delete('Xbcfile2') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
836 |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
837 " If a backup file is already present, then a slightly modified filename |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
838 " should be used as the backup file. Try with 'backupcopy' set to 'yes' and |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
839 " 'no'. |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
840 %bw |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
841 call writefile(['aaaa'], 'Xbcfile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
842 call writefile(['bbbb'], 'Xbcfile.bak') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
843 set backupcopy=yes backupext=.bak |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
844 new Xbcfile |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
845 call setline(1, ['cccc']) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
846 write |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
847 close |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
848 call assert_equal(['cccc'], readfile('Xbcfile')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
849 call assert_equal(['bbbb'], readfile('Xbcfile.bak')) |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
850 set backupcopy=no backupext=.bak |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
851 new Xbcfile |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
852 call setline(1, ['dddd']) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
853 write |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
854 close |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
855 call assert_equal(['dddd'], readfile('Xbcfile')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
856 call assert_equal(['bbbb'], readfile('Xbcfile.bak')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
857 call delete('Xbcfile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
858 call delete('Xbcfile.bak') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
859 |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
860 " Write to a device file (in Unix-like systems) which cannot be backed up. |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
861 if has('unix') |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
862 set writebackup backupcopy=yes nobackup |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
863 new |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
864 call setline(1, ['aaaa']) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
865 let output = execute('write! /dev/null') |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
866 call assert_match('"/dev/null" \[Device]', output) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
867 close |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
868 set writebackup backupcopy=no nobackup |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
869 new |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
870 call setline(1, ['aaaa']) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
871 let output = execute('write! /dev/null') |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
872 call assert_match('"/dev/null" \[Device]', output) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
873 close |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
874 set backup writebackup& backupcopy& |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
875 new |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
876 call setline(1, ['aaaa']) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
877 let output = execute('write! /dev/null') |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
878 call assert_match('"/dev/null" \[Device]', output) |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
879 close |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
880 endif |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
881 |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
882 set backupcopy& backupskip& backupext& backup& |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
883 endfunc |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
884 |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
885 " Test for writing a file with 'encoding' set to 'utf-16' |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
886 func Test_write_utf16() |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
887 new |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
888 call setline(1, ["\U00010001"]) |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
889 write ++enc=utf-16 Xw16file |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
890 bw! |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
891 call assert_equal(0zD800DC01, readfile('Xw16file', 'B')[0:3]) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
892 call delete('Xw16file') |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
893 endfunc |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
894 |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
895 " Test for trying to save a backup file when the backup file is a symbolic |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
896 " link to the original file. The backup file should not be modified. |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
897 func Test_write_backup_symlink() |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
898 CheckUnix |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
25569
diff
changeset
|
899 call mkdir('Xbackup') |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
25569
diff
changeset
|
900 let save_backupdir = &backupdir |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
25569
diff
changeset
|
901 set backupdir=.,./Xbackup |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
902 call writefile(['1111'], 'Xwbsfile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
903 silent !ln -s Xwbsfile Xwbsfile.bak |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
904 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
905 new Xwbsfile |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
906 set backup backupcopy=yes backupext=.bak |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
907 write |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
908 call assert_equal('link', getftype('Xwbsfile.bak')) |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
909 call assert_equal('Xwbsfile', resolve('Xwbsfile.bak')) |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
25569
diff
changeset
|
910 " backup file should be created in the 'backup' directory |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
25569
diff
changeset
|
911 if !has('bsd') |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
25569
diff
changeset
|
912 " This check fails on FreeBSD |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
913 call assert_true(filereadable('./Xbackup/Xwbsfile.bak')) |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
25569
diff
changeset
|
914 endif |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
915 set backup& backupcopy& backupext& |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
25569
diff
changeset
|
916 %bw |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
917 |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
918 call delete('Xwbsfile') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
919 call delete('Xwbsfile.bak') |
28081
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
25569
diff
changeset
|
920 call delete('Xbackup', 'rf') |
b737bfa876c5
patch 8.2.4565: no command line completion for :breakadd and :breakdel
Bram Moolenaar <Bram@vim.org>
parents:
25569
diff
changeset
|
921 let &backupdir = save_backupdir |
24620
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
922 endfunc |
9f48b262539b
patch 8.2.2849: bufwrite not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
24164
diff
changeset
|
923 |
24669
d7644bffe128
patch 8.2.2873: not enough tests for writing buffers
Bram Moolenaar <Bram@vim.org>
parents:
24634
diff
changeset
|
924 " Test for ':write ++bin' and ':write ++nobin' |
d7644bffe128
patch 8.2.2873: not enough tests for writing buffers
Bram Moolenaar <Bram@vim.org>
parents:
24634
diff
changeset
|
925 func Test_write_binary_file() |
d7644bffe128
patch 8.2.2873: not enough tests for writing buffers
Bram Moolenaar <Bram@vim.org>
parents:
24634
diff
changeset
|
926 " create a file without an eol/eof character |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
927 call writefile(0z616161, 'Xwbfile1', 'b') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
928 new Xwbfile1 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
929 write ++bin Xwbfile2 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
930 write ++nobin Xwbfile3 |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
931 call assert_equal(0z616161, readblob('Xwbfile2')) |
24669
d7644bffe128
patch 8.2.2873: not enough tests for writing buffers
Bram Moolenaar <Bram@vim.org>
parents:
24634
diff
changeset
|
932 if has('win32') |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
933 call assert_equal(0z6161610D.0A, readblob('Xwbfile3')) |
24669
d7644bffe128
patch 8.2.2873: not enough tests for writing buffers
Bram Moolenaar <Bram@vim.org>
parents:
24634
diff
changeset
|
934 else |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
935 call assert_equal(0z6161610A, readblob('Xwbfile3')) |
24669
d7644bffe128
patch 8.2.2873: not enough tests for writing buffers
Bram Moolenaar <Bram@vim.org>
parents:
24634
diff
changeset
|
936 endif |
30051
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
937 call delete('Xwbfile1') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
938 call delete('Xwbfile2') |
13b02c1ea0f7
patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents:
29970
diff
changeset
|
939 call delete('Xwbfile3') |
24669
d7644bffe128
patch 8.2.2873: not enough tests for writing buffers
Bram Moolenaar <Bram@vim.org>
parents:
24634
diff
changeset
|
940 endfunc |
d7644bffe128
patch 8.2.2873: not enough tests for writing buffers
Bram Moolenaar <Bram@vim.org>
parents:
24634
diff
changeset
|
941 |
30083
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
942 func DoWriteDefer() |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
943 call writefile(['some text'], 'XdeferDelete', 'D') |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
944 call assert_equal(['some text'], readfile('XdeferDelete')) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
945 endfunc |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
946 |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
947 def DefWriteDefer() |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
948 writefile(['some text'], 'XdefdeferDelete', 'D') |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
949 assert_equal(['some text'], readfile('XdefdeferDelete')) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
950 enddef |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
951 |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
952 func Test_write_with_deferred_delete() |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
953 call DoWriteDefer() |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
954 call assert_equal('', glob('XdeferDelete')) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
955 call DefWriteDefer() |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
956 call assert_equal('', glob('XdefdeferDelete')) |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
957 endfunc |
a542dfb1c1a2
patch 9.0.0379: cleaning up after writefile() is a hassle
Bram Moolenaar <Bram@vim.org>
parents:
30051
diff
changeset
|
958 |
30150
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
959 func DoWriteFile() |
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
960 call writefile(['text'], 'Xthefile', 'D') |
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
961 cd .. |
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
962 endfunc |
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
963 |
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
964 func Test_write_defer_delete_chdir() |
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
965 let dir = getcwd() |
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
966 call DoWriteFile() |
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
967 call assert_notequal(dir, getcwd()) |
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
968 call chdir(dir) |
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
969 call assert_equal('', glob('Xthefile')) |
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
970 endfunc |
0fe61fa4e5d1
patch 9.0.0411: only created files can be cleaned up with one call
Bram Moolenaar <Bram@vim.org>
parents:
30090
diff
changeset
|
971 |
24723
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
972 " Check that buffer is written before triggering QuitPre |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
973 func Test_wq_quitpre_autocommand() |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
974 edit Xsomefile |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
975 call setline(1, 'hello') |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
976 split |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
977 let g:seq = [] |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
978 augroup Testing |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
979 au QuitPre * call add(g:seq, 'QuitPre - ' .. (&modified ? 'modified' : 'not modified')) |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
980 au BufWritePost * call add(g:seq, 'written') |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
981 augroup END |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
982 wq |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
983 call assert_equal(['written', 'QuitPre - not modified'], g:seq) |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
984 |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
985 augroup Testing |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
986 au! |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
987 augroup END |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
988 bwipe! |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
989 unlet g:seq |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
990 call delete('Xsomefile') |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
991 endfunc |
5194fba32954
patch 8.2.2900: QuitPre is triggered before :wq writes the file
Bram Moolenaar <Bram@vim.org>
parents:
24669
diff
changeset
|
992 |
19231
b8fd7364befd
patch 8.2.0174: various commands not completely tested
Bram Moolenaar <Bram@vim.org>
parents:
18386
diff
changeset
|
993 " vim: shiftwidth=2 sts=2 expandtab |