Mercurial > vim
annotate src/testdir/test_stat.vim @ 11273:96d83cd2904a v8.0.0522
patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
commit https://github.com/vim/vim/commit/3fcfa35f82b9d1ef5e95051b3a45578e10c14ec3
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Mar 29 19:20:41 2017 +0200
patch 8.0.0522: Win32: when 'clipboard' is "unnamed" yyp does not work
Problem: MS-Windows: when 'clipboard' is "unnamed" yyp does not work in a
:global command.
Solution: When setting the clipboard was postponed, do not clear the
register.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 29 Mar 2017 19:30:06 +0200 |
parents | 750779134e67 |
children | 709b898e2119 |
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 |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 func Test_existent_file() |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
4 let fname = 'Xtest.tmp' |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
6 let ts = localtime() |
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
7 let fl = ['Hello World!'] |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 call writefile(fl, fname) |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
9 let tf = getftime(fname) |
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
10 let te = localtime() |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 call assert_true(ts <= tf && tf <= te) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 call assert_equal(strlen(fl[0] . "\n"), getfsize(fname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call assert_equal('file', getftype(fname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 call assert_equal('rw-', getfperm(fname)[0:2]) |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
16 |
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
17 call delete(fname) |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 endfunc |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 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
|
21 let dname = '.' |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 call assert_equal(0, getfsize(dname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 call assert_equal('dir', getftype(dname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 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
|
26 endfunc |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 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
|
29 let fname = 'Xtest.tmp' |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
31 let fl = ['Hello World!'] |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 call writefile(fl, fname) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 set autoread |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 exec 'e' fname |
10805
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
35 " FAT has a granularity of 2 seconds, otherwise it's usually 1 second |
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
36 if has('win32') |
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
37 sleep 2 |
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
38 else |
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
39 sleep 1 |
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
40 endif |
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
41 let fl = readfile(fname) |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 let fl[0] .= ' - checktime' |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 call writefile(fl, fname) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 checktime |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 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
|
46 |
750779134e67
patch 8.0.0292: the stat test is a bit slow
Christian Brabandt <cb@256bit.org>
parents:
9387
diff
changeset
|
47 call delete(fname) |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 endfunc |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 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
|
51 let fname = 'Xtest.tmp' |
9387
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 call delete(fname) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 call assert_equal(-1, getftime(fname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 call assert_equal(-1, getfsize(fname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 call assert_equal('', getftype(fname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 call assert_equal('', getfperm(fname)) |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 endfunc |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 func Test_win32_symlink_dir() |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 " 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
|
62 " 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
|
63 if has('win32') |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 " 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
|
65 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
|
66 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
|
67 " Get the filetype of the symlink. |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 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
|
69 endif |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 endif |
f094d4085014
commit https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 endfunc |