annotate src/testdir/test_stat.vim @ 26595:1d0cf6a2efe6

Added tag v8.2.3826 for changeset b12d8a5af20e7c9170cc527a390766bf320b4ab6
author Bram Moolenaar <Bram@vim.org>
date Thu, 16 Dec 2021 17:00:05 +0100
parents c45e990847e5
children 13b02c1ea0f7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3 source check.vim
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
4
12150
709b898e2119 patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents: 10805
diff changeset
5 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
6 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
7 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
8 let result = 0
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
19195
2ef19eed524a patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents: 17889
diff changeset
10 " Use three files instead of localtim(), with a network filesystem the file
15050
c7628d6bc0dc patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents: 14609
diff changeset
11 " 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
12 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
13 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
14 call writefile(fl, fname)
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 15050
diff changeset
15 call add(times, fname->getftime())
15050
c7628d6bc0dc patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents: 14609
diff changeset
16 if a:doSleep
c7628d6bc0dc patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents: 14609
diff changeset
17 sleep 1
c7628d6bc0dc patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents: 14609
diff changeset
18 endif
c7628d6bc0dc patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents: 14609
diff changeset
19 endfor
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20
15050
c7628d6bc0dc patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents: 14609
diff changeset
21 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
22 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
23 call assert_true(time_correct, printf('Expected %s <= %s <= %s', times[0], times[1], times[2]))
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 15050
diff changeset
24 call assert_equal(strlen(fl[0] . "\n"), fnames[0]->getfsize())
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 15050
diff changeset
25 call assert_equal('file', fnames[0]->getftype())
15050
c7628d6bc0dc patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents: 14609
diff changeset
26 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
27 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
28 endif
10805
750779134e67 patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 9387
diff changeset
29
15050
c7628d6bc0dc patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents: 14609
diff changeset
30 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
31 call delete(fname)
c7628d6bc0dc patch 8.1.0536: file time test fails when using NFS
Bram Moolenaar <Bram@vim.org>
parents: 14609
diff changeset
32 endfor
12150
709b898e2119 patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents: 10805
diff changeset
33 return result
709b898e2119 patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents: 10805
diff changeset
34 endfunc
709b898e2119 patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents: 10805
diff changeset
35
709b898e2119 patch 8.0.0955: Test_existent_file() fails on some file systems
Christian Brabandt <cb@256bit.org>
parents: 10805
diff changeset
36 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
37 " 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
38 " 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
39 " 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
40 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
41 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
42 endif
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 endfunc
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 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
46 let dname = '.'
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 call assert_equal(0, getfsize(dname))
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 call assert_equal('dir', getftype(dname))
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 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
51 endfunc
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52
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
53 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
54 " 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
55 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
56 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
57 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
58 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
59 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
60 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
61
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 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
63 let fname = 'Xtest.tmp'
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64
10805
750779134e67 patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 9387
diff changeset
65 let fl = ['Hello World!']
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 call writefile(fl, fname)
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 set autoread
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 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
69 call SleepForTimestamp()
10805
750779134e67 patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 9387
diff changeset
70 let fl = readfile(fname)
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 let fl[0] .= ' - checktime'
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 call writefile(fl, fname)
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 checktime
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 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
75
750779134e67 patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents: 9387
diff changeset
76 call delete(fname)
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 endfunc
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78
25953
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
79 func Test_checktime_fast()
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
80 CheckFeature nanotime
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
81
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
82 let fname = 'Xtest.tmp'
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
83
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
84 let fl = ['Hello World!']
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
85 call writefile(fl, fname)
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
86 set autoread
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
87 exec 'e' fname
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
88 let fl = readfile(fname)
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
89 let fl[0] .= ' - checktime'
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
90 call writefile(fl, fname)
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
91 checktime
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
92 call assert_equal(fl[0], getline(1))
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
93
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
94 call delete(fname)
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
95 endfunc
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
96
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
97 func Test_autoread_fast()
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
98 CheckFeature nanotime
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
99
25961
a21a47c83e0c patch 8.2.3514: autoread test with nano second time sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 25957
diff changeset
100 " this is timing sensitive
a21a47c83e0c patch 8.2.3514: autoread test with nano second time sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 25957
diff changeset
101 let g:test_is_flaky = 1
a21a47c83e0c patch 8.2.3514: autoread test with nano second time sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 25957
diff changeset
102
25953
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
103 new Xautoread
25961
a21a47c83e0c patch 8.2.3514: autoread test with nano second time sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 25957
diff changeset
104 setlocal autoread
25953
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
105 call setline(1, 'foo')
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
106 w!
26002
c45e990847e5 patch 8.2.3534: autoread test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 25961
diff changeset
107 sleep 10m
c45e990847e5 patch 8.2.3534: autoread test is a bit flaky
Bram Moolenaar <Bram@vim.org>
parents: 25961
diff changeset
108 call writefile(['bar'], 'Xautoread')
25957
08f63df32e8e patch 8.2.3512: timestamp test fails on some systems
Bram Moolenaar <Bram@vim.org>
parents: 25953
diff changeset
109 sleep 10m
25953
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
110 checktime
25961
a21a47c83e0c patch 8.2.3514: autoread test with nano second time sometimes fails
Bram Moolenaar <Bram@vim.org>
parents: 25957
diff changeset
111 call assert_equal('bar', trim(getline(1)))
25953
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
112
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
113 call delete('Xautoread')
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
114 endfunc
d7e1cf30728c patch 8.2.3510: changes are only detected with one second accuracy
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
115
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
116 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
117 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
118 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
119 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
120 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
121
977cab3d5474 patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents: 12150
diff changeset
122 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
123 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
124 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
125 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
126 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
127 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
128 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
129 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
130
977cab3d5474 patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents: 12150
diff changeset
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141
977cab3d5474 patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents: 12150
diff changeset
142 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
143 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
144 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
145 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
146 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
147 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
148 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
149 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
150
977cab3d5474 patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents: 12150
diff changeset
151 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
152 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
153 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
154
977cab3d5474 patch 8.1.0161: buffer not updated with 'autoread' set if file was deleted
Christian Brabandt <cb@256bit.org>
parents: 12150
diff changeset
155
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 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
157 let fname = 'Xtest.tmp'
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 call delete(fname)
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 call assert_equal(-1, getftime(fname))
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 call assert_equal(-1, getfsize(fname))
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 call assert_equal('', getftype(fname))
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 call assert_equal('', getfperm(fname))
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 endfunc
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165
14497
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
166 func Test_getftype()
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
167 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
168 call assert_equal('dir', getftype('.'))
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
169
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
170 if !has('unix')
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
171 return
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
172 endif
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
173
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
174 silent !ln -s Xfile Xlink
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
175 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
176 call delete('Xlink')
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
177
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
178 if executable('mkfifo')
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
179 silent !mkfifo Xfifo
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
180 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
181 call delete('Xfifo')
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
182 endif
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
183
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
184 for cdevfile in systemlist('find /dev -type c -maxdepth 2 2>/dev/null')
17889
0d64e74be8b2 patch 8.1.1941: getftype() test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
185 " On Mac /def/fd/2 is found but the type is "fifo"
0d64e74be8b2 patch 8.1.1941: getftype() test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
186 if cdevfile !~ '/dev/fd/'
0d64e74be8b2 patch 8.1.1941: getftype() test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
187 let type = getftype(cdevfile)
0d64e74be8b2 patch 8.1.1941: getftype() test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
188 " ignore empty result, can happen if the file disappeared
0d64e74be8b2 patch 8.1.1941: getftype() test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
189 if type != ''
0d64e74be8b2 patch 8.1.1941: getftype() test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
190 call assert_equal('cdev', type, 'for ' .. cdevfile)
0d64e74be8b2 patch 8.1.1941: getftype() test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
191 endif
14609
40b10f98eb13 patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents: 14497
diff changeset
192 endif
14497
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
193 endfor
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
194
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
195 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
196 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
197 " 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
198 if type != ''
17889
0d64e74be8b2 patch 8.1.1941: getftype() test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
199 call assert_equal('bdev', type, 'for ' .. bdevfile)
14609
40b10f98eb13 patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents: 14497
diff changeset
200 endif
14497
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
201 endfor
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
202
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
203 " 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
204 " 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
205 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
206 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
207 " 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
208 if type != ''
17889
0d64e74be8b2 patch 8.1.1941: getftype() test fails on Mac
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
209 call assert_equal('socket', type, 'for ' .. socketfile)
14609
40b10f98eb13 patch 8.1.0318: the getftype() test may fail for char devices
Christian Brabandt <cb@256bit.org>
parents: 14497
diff changeset
210 endif
14497
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
211 endfor
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
212
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
213 " 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
214 endfunc
a7b2dc5f1306 patch 8.1.0262: not enough testing for getftype()
Christian Brabandt <cb@256bit.org>
parents: 14290
diff changeset
215
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 func Test_win32_symlink_dir()
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 " 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
218 " So we use an existing symlink for this test.
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
219 CheckMSWindows
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
220 " Check if 'C:\Users\All Users' is a symlink to a directory.
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
221 let res = system('dir C:\Users /a')
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
222 if match(res, '\C<SYMLINKD> *All Users') >= 0
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
223 " Get the filetype of the symlink.
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
224 call assert_equal('dir', getftype('C:\Users\All Users'))
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
225 else
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
226 throw 'Skipped: cannot find an existing symlink'
9387
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227 endif
f094d4085014 commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
229
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
230 " vim: shiftwidth=2 sts=2 expandtab