diff 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
line wrap: on
line diff
--- a/src/testdir/test_swap.vim
+++ b/src/testdir/test_swap.vim
@@ -1,5 +1,7 @@
 " Tests for the swap feature
 
+source shared.vim
+
 func s:swapname()
   return trim(execute('swapname'))
 endfunc
@@ -196,14 +198,17 @@ func Test_swapfile_delete()
   quit
   call assert_equal(fnamemodify(swapfile_name, ':t'), fnamemodify(s:swapname, ':t'))
 
-  " Write the swapfile with a modified PID, now it will be automatically
-  " deleted. Process one should never be Vim.
-  let swapfile_bytes[24:27] = 0z01000000
-  call writefile(swapfile_bytes, swapfile_name)
-  let s:swapname = ''
-  split XswapfileText
-  quit
-  call assert_equal('', s:swapname)
+  " This test won't work as root because root can successfully run kill(1, 0)
+  if !IsRoot()
+    " Write the swapfile with a modified PID, now it will be automatically
+    " deleted. Process one should never be Vim.
+    let swapfile_bytes[24:27] = 0z01000000
+    call writefile(swapfile_bytes, swapfile_name)
+    let s:swapname = ''
+    split XswapfileText
+    quit
+    call assert_equal('', s:swapname)
+  endif
 
   " Now set the modified flag, the swap file will not be deleted
   let swapfile_bytes[28 + 80 + 899] = 0x55