comparison src/testdir/test_swap.vim @ 18277:f6dcf7eabd26 v8.1.2133

patch 8.1.2133: some tests fail when run as root Commit: https://github.com/vim/vim/commit/07282f01da06c158bab4787adc89ec15d7eeb202 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 10 16:46:17 2019 +0200 patch 8.1.2133: some tests fail when run as root Problem: Some tests fail when run as root. Solution: Add CheckNotRoot and use it. (James McCoy, closes https://github.com/vim/vim/issues/5020)
author Bram Moolenaar <Bram@vim.org>
date Thu, 10 Oct 2019 17:00:03 +0200
parents 988e5a868b60
children 8f8a5a15d00a
comparison
equal deleted inserted replaced
18276:79b045ead26e 18277:f6dcf7eabd26
1 " Tests for the swap feature 1 " Tests for the swap feature
2
3 source shared.vim
2 4
3 func s:swapname() 5 func s:swapname()
4 return trim(execute('swapname')) 6 return trim(execute('swapname'))
5 endfunc 7 endfunc
6 8
194 let s:swapname = '' 196 let s:swapname = ''
195 split XswapfileText 197 split XswapfileText
196 quit 198 quit
197 call assert_equal(fnamemodify(swapfile_name, ':t'), fnamemodify(s:swapname, ':t')) 199 call assert_equal(fnamemodify(swapfile_name, ':t'), fnamemodify(s:swapname, ':t'))
198 200
199 " Write the swapfile with a modified PID, now it will be automatically 201 " This test won't work as root because root can successfully run kill(1, 0)
200 " deleted. Process one should never be Vim. 202 if !IsRoot()
201 let swapfile_bytes[24:27] = 0z01000000 203 " Write the swapfile with a modified PID, now it will be automatically
202 call writefile(swapfile_bytes, swapfile_name) 204 " deleted. Process one should never be Vim.
203 let s:swapname = '' 205 let swapfile_bytes[24:27] = 0z01000000
204 split XswapfileText 206 call writefile(swapfile_bytes, swapfile_name)
205 quit 207 let s:swapname = ''
206 call assert_equal('', s:swapname) 208 split XswapfileText
209 quit
210 call assert_equal('', s:swapname)
211 endif
207 212
208 " Now set the modified flag, the swap file will not be deleted 213 " Now set the modified flag, the swap file will not be deleted
209 let swapfile_bytes[28 + 80 + 899] = 0x55 214 let swapfile_bytes[28 + 80 + 899] = 0x55
210 call writefile(swapfile_bytes, swapfile_name) 215 call writefile(swapfile_bytes, swapfile_name)
211 let s:swapname = '' 216 let s:swapname = ''