Mercurial > vim
comparison src/testdir/test_swap.vim @ 14599:72d6f6f7ead7 v8.1.0313
patch 8.1.0313: information about a swap file is unavailable
commit https://github.com/vim/vim/commit/00f123a56585363cd13f062fd3bb123efcfaa664
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 21 20:28:54 2018 +0200
patch 8.1.0313: information about a swap file is unavailable
Problem: Information about a swap file is unavailable.
Solution: Add swapinfo(). (Enzo Ferber)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 21 Aug 2018 20:30:05 +0200 |
parents | 4d5a1ada407e |
children | d0ff19a55579 |
comparison
equal
deleted
inserted
replaced
14598:f480648bd376 | 14599:72d6f6f7ead7 |
---|---|
95 only | 95 only |
96 | 96 |
97 set directory& | 97 set directory& |
98 call delete('Xswapdir', 'rf') | 98 call delete('Xswapdir', 'rf') |
99 endfunc | 99 endfunc |
100 | |
101 func Test_swapinfo() | |
102 new Xswapinfo | |
103 call setline(1, ['one', 'two', 'three']) | |
104 w | |
105 let fname = trim(execute('swapname')) | |
106 call assert_match('Xswapinfo', fname) | |
107 let info = swapinfo(fname) | |
108 call assert_match('8\.', info.version) | |
109 call assert_match('\w', info.user) | |
110 call assert_equal(hostname(), info.host) | |
111 call assert_match('Xswapinfo', info.fname) | |
112 call assert_equal(getpid(), info.pid) | |
113 call assert_match('^\d*$', info.mtime) | |
114 if has_key(info, 'inode') | |
115 call assert_match('\d', info.inode) | |
116 endif | |
117 bwipe! | |
118 call delete(fname) | |
119 call delete('Xswapinfo') | |
120 | |
121 let info = swapinfo('doesnotexist') | |
122 call assert_equal('Cannot open file', info.error) | |
123 | |
124 call writefile(['burp'], 'Xnotaswapfile') | |
125 let info = swapinfo('Xnotaswapfile') | |
126 call assert_equal('Cannot read file', info.error) | |
127 call delete('Xnotaswapfile') | |
128 | |
129 call writefile([repeat('x', 10000)], 'Xnotaswapfile') | |
130 let info = swapinfo('Xnotaswapfile') | |
131 call assert_equal('magic number mismatch', info.error) | |
132 call delete('Xnotaswapfile') | |
133 endfunc |