annotate src/testdir/test_swap.vim @ 14778:20653d6f3d95 v8.1.0401

patch 8.1.0401: can't get swap name of another buffer commit https://github.com/vim/vim/commit/110bd60985c31e8978e9b071e2179f4233ef8557 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 16 18:46:59 2018 +0200 patch 8.1.0401: can't get swap name of another buffer Problem: Can't get swap name of another buffer. Solution: Add swapname(). (Ozaki Kiichi, closes https://github.com/vim/vim/issues/3441)
author Christian Brabandt <cb@256bit.org>
date Sun, 16 Sep 2018 19:00:06 +0200
parents 0c47880f3d95
children f315ab10d579
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for the swap feature
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
14778
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
3 func s:swapname()
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
4 return trim(execute('swapname'))
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
5 endfunc
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
6
12777
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
7 " Tests for 'directory' option.
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
8 func Test_swap_directory()
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
9 if !has("unix")
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
10 return
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
11 endif
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
12 let content = ['start of testfile',
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
13 \ 'line 2 Abcdefghij',
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
14 \ 'line 3 Abcdefghij',
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
15 \ 'end of testfile']
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
16 call writefile(content, 'Xtest1')
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
17
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
18 " '.', swap file in the same directory as file
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
19 set dir=.,~
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
20
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
21 " Verify that the swap file doesn't exist in the current directory
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
22 call assert_equal([], glob(".Xtest1*.swp", 1, 1, 1))
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
23 edit Xtest1
14778
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
24 let swfname = s:swapname()
12777
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
25 call assert_equal([swfname], glob(swfname, 1, 1, 1))
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
26
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
27 " './dir', swap file in a directory relative to the file
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
28 set dir=./Xtest2,.,~
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
29
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
30 call mkdir("Xtest2")
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
31 edit Xtest1
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
32 call assert_equal([], glob(swfname, 1, 1, 1))
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
33 let swfname = "Xtest2/Xtest1.swp"
14778
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
34 call assert_equal(swfname, s:swapname())
12777
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
35 call assert_equal([swfname], glob("Xtest2/*", 1, 1, 1))
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
36
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
37 " 'dir', swap file in directory relative to the current dir
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
38 set dir=Xtest.je,~
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
39
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
40 call mkdir("Xtest.je")
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
41 call writefile(content, 'Xtest2/Xtest3')
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
42 edit Xtest2/Xtest3
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
43 call assert_equal(["Xtest2/Xtest3"], glob("Xtest2/*", 1, 1, 1))
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
44 let swfname = "Xtest.je/Xtest3.swp"
14778
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
45 call assert_equal(swfname, s:swapname())
12777
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
46 call assert_equal([swfname], glob("Xtest.je/*", 1, 1, 1))
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
47
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
48 set dir&
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
49 call delete("Xtest1")
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
50 call delete("Xtest2", "rf")
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
51 call delete("Xtest.je", "rf")
3272e1cde1eb patch 8.0.1266: Test_swap_directory was commented out
Christian Brabandt <cb@256bit.org>
parents: 12775
diff changeset
52 endfunc
12771
8984342ab09e patch 8.0.1263: others can read the swap file if a user is careless
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
53
8984342ab09e patch 8.0.1263: others can read the swap file if a user is careless
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
54 func Test_swap_group()
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 if !has("unix")
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 return
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 endif
12771
8984342ab09e patch 8.0.1263: others can read the swap file if a user is careless
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
58 let groups = split(system('groups'))
8984342ab09e patch 8.0.1263: others can read the swap file if a user is careless
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
59 if len(groups) <= 1
12775
bda267b9fc68 patch 8.0.1265: swap test not skipped when there is one group
Christian Brabandt <cb@256bit.org>
parents: 12771
diff changeset
60 throw 'Skipped: need at least two groups, got ' . string(groups)
12771
8984342ab09e patch 8.0.1263: others can read the swap file if a user is careless
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
61 endif
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62
12779
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
63 try
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
64 call delete('Xtest')
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
65 split Xtest
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
66 call setline(1, 'just some text')
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
67 wq
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
68 if system('ls -l Xtest') !~ ' ' . groups[0] . ' \d'
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
69 throw 'Skipped: test file does not have the first group'
12771
8984342ab09e patch 8.0.1263: others can read the swap file if a user is careless
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
70 else
12779
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
71 silent !chmod 640 Xtest
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
72 call system('chgrp ' . groups[1] . ' Xtest')
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
73 if system('ls -l Xtest') !~ ' ' . groups[1] . ' \d'
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
74 throw 'Skipped: cannot set second group on test file'
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
75 else
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
76 split Xtest
14778
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
77 let swapname = s:swapname()
12779
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
78 call assert_match('Xtest', swapname)
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
79 " Group of swapfile must now match original file.
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
80 call assert_match(' ' . groups[1] . ' \d', system('ls -l ' . swapname))
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81
12779
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
82 bwipe!
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
83 endif
12771
8984342ab09e patch 8.0.1263: others can read the swap file if a user is careless
Christian Brabandt <cb@256bit.org>
parents: 12750
diff changeset
84 endif
12779
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
85 finally
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
86 call delete('Xtest')
73eb8a2d7f04 patch 8.0.1267: Test_swap_group may leave file behind
Christian Brabandt <cb@256bit.org>
parents: 12777
diff changeset
87 endtry
12750
0b6c09957b43 patch 8.0.1253: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 endfunc
13896
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
89
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
90 func Test_missing_dir()
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
91 call mkdir('Xswapdir')
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
92 exe 'set directory=' . getcwd() . '/Xswapdir'
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
93
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
94 call assert_equal('', glob('foo'))
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
95 call assert_equal('', glob('bar'))
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
96 edit foo/x.txt
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
97 " This should not give a warning for an existing swap file.
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
98 split bar/x.txt
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
99 only
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
100
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
101 set directory&
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
102 call delete('Xswapdir', 'rf')
4d5a1ada407e patch 8.0.1819: swap file warning for file with non-existing directory
Christian Brabandt <cb@256bit.org>
parents: 12779
diff changeset
103 endfunc
14599
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
104
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
105 func Test_swapinfo()
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
106 new Xswapinfo
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
107 call setline(1, ['one', 'two', 'three'])
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
108 w
14778
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
109 let fname = s:swapname()
14599
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
110 call assert_match('Xswapinfo', fname)
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
111 let info = swapinfo(fname)
14605
0c47880f3d95 patch 8.1.0316: swapinfo() test fails on Travis
Christian Brabandt <cb@256bit.org>
parents: 14601
diff changeset
112
0c47880f3d95 patch 8.1.0316: swapinfo() test fails on Travis
Christian Brabandt <cb@256bit.org>
parents: 14601
diff changeset
113 let ver = printf('VIM %d.%d', v:version / 100, v:version % 100)
0c47880f3d95 patch 8.1.0316: swapinfo() test fails on Travis
Christian Brabandt <cb@256bit.org>
parents: 14601
diff changeset
114 call assert_equal(ver, info.version)
0c47880f3d95 patch 8.1.0316: swapinfo() test fails on Travis
Christian Brabandt <cb@256bit.org>
parents: 14601
diff changeset
115
14599
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
116 call assert_match('\w', info.user)
14605
0c47880f3d95 patch 8.1.0316: swapinfo() test fails on Travis
Christian Brabandt <cb@256bit.org>
parents: 14601
diff changeset
117 " host name is truncated to 39 bytes in the swap file
0c47880f3d95 patch 8.1.0316: swapinfo() test fails on Travis
Christian Brabandt <cb@256bit.org>
parents: 14601
diff changeset
118 call assert_equal(hostname()[:38], info.host)
14599
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
119 call assert_match('Xswapinfo', info.fname)
14601
d0ff19a55579 patch 8.1.0314: build failure without the +eval feature
Christian Brabandt <cb@256bit.org>
parents: 14599
diff changeset
120 call assert_match(0, info.dirty)
14599
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
121 call assert_equal(getpid(), info.pid)
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
122 call assert_match('^\d*$', info.mtime)
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
123 if has_key(info, 'inode')
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
124 call assert_match('\d', info.inode)
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
125 endif
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
126 bwipe!
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
127 call delete(fname)
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
128 call delete('Xswapinfo')
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
129
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
130 let info = swapinfo('doesnotexist')
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
131 call assert_equal('Cannot open file', info.error)
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
132
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
133 call writefile(['burp'], 'Xnotaswapfile')
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
134 let info = swapinfo('Xnotaswapfile')
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
135 call assert_equal('Cannot read file', info.error)
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
136 call delete('Xnotaswapfile')
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
137
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
138 call writefile([repeat('x', 10000)], 'Xnotaswapfile')
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
139 let info = swapinfo('Xnotaswapfile')
14601
d0ff19a55579 patch 8.1.0314: build failure without the +eval feature
Christian Brabandt <cb@256bit.org>
parents: 14599
diff changeset
140 call assert_equal('Not a swap file', info.error)
14599
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
141 call delete('Xnotaswapfile')
72d6f6f7ead7 patch 8.1.0313: information about a swap file is unavailable
Christian Brabandt <cb@256bit.org>
parents: 13896
diff changeset
142 endfunc
14778
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
143
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
144 func Test_swapname()
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
145 edit Xtest1
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
146 let expected = s:swapname()
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
147 call assert_equal(expected, swapname('%'))
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
148
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
149 new Xtest2
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
150 let buf = bufnr('%')
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
151 let expected = s:swapname()
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
152 wincmd p
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
153 call assert_equal(expected, swapname(buf))
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
154
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
155 new Xtest3
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
156 setlocal noswapfile
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
157 call assert_equal('', swapname('%'))
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
158
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
159 bwipe!
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
160 call delete('Xtest1')
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
161 call delete('Xtest2')
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
162 call delete('Xtest3')
20653d6f3d95 patch 8.1.0401: can't get swap name of another buffer
Christian Brabandt <cb@256bit.org>
parents: 14605
diff changeset
163 endfunc