Mercurial > vim
annotate src/testdir/test_stat.vim @ 15796:481452f6687c v8.1.0905
patch 8.1.0905: complicated regexp causes a crash
commit https://github.com/vim/vim/commit/5567ad48b66dff13670af52a48509059acc34dfe
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 12 23:05:46 2019 +0100
patch 8.1.0905: complicated regexp causes a crash
Problem: Complicated regexp causes a crash. (Kuang-che Wu)
Solution: Limit the recursiveness of addstate(). (closes https://github.com/vim/vim/issues/3941)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 12 Feb 2019 23:15:06 +0100 |
parents | c7628d6bc0dc |
children | 4935244c1128 |
rev | line source |
---|---|
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for stat functions and checktime |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
12150
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
3 func CheckFileTime(doSleep) |
15050
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
4 let fnames = ['Xtest1.tmp', 'Xtest2.tmp', 'Xtest3.tmp'] |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
5 let times = [] |
12150
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
6 let result = 0 |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
15050
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
8 " Use three files istead of localtim(), with a network filesystem the file |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
9 " times may differ at bit |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
10 let fl = ['Hello World!'] |
15050
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
11 for fname in fnames |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
12 call writefile(fl, fname) |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
13 call add(times, getftime(fname)) |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
14 if a:doSleep |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
15 sleep 1 |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
16 endif |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
17 endfor |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 |
15050
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
19 let time_correct = (times[0] <= times[1] && times[1] <= times[2]) |
12150
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
20 if a:doSleep || time_correct |
15050
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
21 call assert_true(time_correct, printf('Expected %s <= %s <= %s', times[0], times[1], times[2])) |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
22 call assert_equal(strlen(fl[0] . "\n"), getfsize(fnames[0])) |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
23 call assert_equal('file', getftype(fnames[0])) |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
24 call assert_equal('rw-', getfperm(fnames[0])[0:2]) |
12150
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
25 let result = 1 |
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
26 endif |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
27 |
15050
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
28 for fname in fnames |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
29 call delete(fname) |
c7628d6bc0dc
patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents:
14609
diff
changeset
|
30 endfor |
12150
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
31 return result |
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
32 endfunc |
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
33 |
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
34 func Test_existent_file() |
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
35 " On some systems the file timestamp is rounded to a multiple of 2 seconds. |
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
36 " We need to sleep to handle that, but that makes the test slow. First try |
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
37 " without the sleep, and if it fails try again with the sleep. |
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
38 if CheckFileTime(0) == 0 |
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
39 call CheckFileTime(1) |
709b898e2119
patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents:
10805
diff
changeset
|
40 endif |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 endfunc |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 func Test_existent_directory() |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
44 let dname = '.' |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 call assert_equal(0, getfsize(dname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 call assert_equal('dir', getftype(dname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 call assert_equal('rwx', getfperm(dname)[0:2]) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 endfunc |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 |
14290
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
51 func SleepForTimestamp() |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
52 " FAT has a granularity of 2 seconds, otherwise it's usually 1 second |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
53 if has('win32') |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
54 sleep 2 |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
55 else |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
56 sleep 1 |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
57 endif |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
58 endfunc |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
59 |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 func Test_checktime() |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
61 let fname = 'Xtest.tmp' |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
63 let fl = ['Hello World!'] |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 call writefile(fl, fname) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 set autoread |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 exec 'e' fname |
14290
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
67 call SleepForTimestamp() |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
68 let fl = readfile(fname) |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 let fl[0] .= ' - checktime' |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 call writefile(fl, fname) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 checktime |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 call assert_equal(fl[0], getline(1)) |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
73 |
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
74 call delete(fname) |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 endfunc |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 |
14290
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
77 func Test_autoread_file_deleted() |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
78 new Xautoread |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
79 set autoread |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
80 call setline(1, 'original') |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
81 w! |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
82 |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
83 call SleepForTimestamp() |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
84 if has('win32') |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
85 silent !echo changed > Xautoread |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
86 else |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
87 silent !echo 'changed' > Xautoread |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
88 endif |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
89 checktime |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
90 call assert_equal('changed', trim(getline(1))) |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
91 |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
92 call SleepForTimestamp() |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
93 messages clear |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
94 if has('win32') |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
95 silent !del Xautoread |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
96 else |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
97 silent !rm Xautoread |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
98 endif |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
99 checktime |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
100 call assert_match('E211:', execute('messages')) |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
101 call assert_equal('changed', trim(getline(1))) |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
102 |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
103 call SleepForTimestamp() |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
104 if has('win32') |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
105 silent !echo recreated > Xautoread |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
106 else |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
107 silent !echo 'recreated' > Xautoread |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
108 endif |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
109 checktime |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
110 call assert_equal('recreated', trim(getline(1))) |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
111 |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
112 call delete('Xautoread') |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
113 bwipe! |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
114 endfunc |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
115 |
977cab3d5474
patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents:
12150
diff
changeset
|
116 |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
117 func Test_nonexistent_file() |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
118 let fname = 'Xtest.tmp' |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
119 |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
120 call delete(fname) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
121 call assert_equal(-1, getftime(fname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
122 call assert_equal(-1, getfsize(fname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
123 call assert_equal('', getftype(fname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
124 call assert_equal('', getfperm(fname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 endfunc |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 |
14497
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
127 func Test_getftype() |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
128 call assert_equal('file', getftype(v:progpath)) |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
129 call assert_equal('dir', getftype('.')) |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
130 |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
131 if !has('unix') |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
132 return |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
133 endif |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
134 |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
135 silent !ln -s Xfile Xlink |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
136 call assert_equal('link', getftype('Xlink')) |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
137 call delete('Xlink') |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
138 |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
139 if executable('mkfifo') |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
140 silent !mkfifo Xfifo |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
141 call assert_equal('fifo', getftype('Xfifo')) |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
142 call delete('Xfifo') |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
143 endif |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
144 |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
145 for cdevfile in systemlist('find /dev -type c -maxdepth 2 2>/dev/null') |
14609
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
146 let type = getftype(cdevfile) |
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
147 " ignore empty result, can happen if the file disappeared |
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
148 if type != '' |
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
149 call assert_equal('cdev', type) |
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
150 endif |
14497
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
151 endfor |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
152 |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
153 for bdevfile in systemlist('find /dev -type b -maxdepth 2 2>/dev/null') |
14609
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
154 let type = getftype(bdevfile) |
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
155 " ignore empty result, can happen if the file disappeared |
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
156 if type != '' |
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
157 call assert_equal('bdev', type) |
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
158 endif |
14497
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
159 endfor |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
160 |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
161 " The /run/ directory typically contains socket files. |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
162 " If it does not, test won't fail but will not test socket files. |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
163 for socketfile in systemlist('find /run -type s -maxdepth 2 2>/dev/null') |
14609
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
164 let type = getftype(socketfile) |
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
165 " ignore empty result, can happen if the file disappeared |
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
166 if type != '' |
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
167 call assert_equal('socket', type) |
40b10f98eb13
patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents:
14497
diff
changeset
|
168 endif |
14497
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
169 endfor |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
170 |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
171 " TODO: file type 'other' is not tested. How can we test it? |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
172 endfunc |
a7b2dc5f1306
patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents:
14290
diff
changeset
|
173 |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
174 func Test_win32_symlink_dir() |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
175 " On Windows, non-admin users cannot create symlinks. |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
176 " So we use an existing symlink for this test. |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
177 if has('win32') |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
178 " Check if 'C:\Users\All Users' is a symlink to a directory. |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
179 let res = system('dir C:\Users /a') |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 if match(res, '\C<SYMLINKD> *All Users') >= 0 |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 " Get the filetype of the symlink. |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
182 call assert_equal('dir', getftype('C:\Users\All Users')) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
183 endif |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
184 endif |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
185 endfunc |