mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-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 vim/vim#5020)
07282f01da
Skip test_terminal.vim and test_viminfo.vim: N/A
This commit is contained in:
parent
cb863d4e1f
commit
041b2d6f1e
@ -113,6 +113,14 @@ func CheckNotGui()
|
|||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Command to check that test is not running as root
|
||||||
|
command CheckNotRoot call CheckNotRoot()
|
||||||
|
func CheckNotRoot()
|
||||||
|
if IsRoot()
|
||||||
|
throw 'Skipped: cannot run test as root'
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Command to check that the current language is English
|
" Command to check that the current language is English
|
||||||
command CheckEnglish call CheckEnglish()
|
command CheckEnglish call CheckEnglish()
|
||||||
func CheckEnglish()
|
func CheckEnglish()
|
||||||
|
@ -343,6 +343,15 @@ func RunVimPiped(before, after, arguments, pipecmd)
|
|||||||
return 1
|
return 1
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func IsRoot()
|
||||||
|
if !has('unix')
|
||||||
|
return v:false
|
||||||
|
elseif $USER == 'root' || system('id -un') =~ '\<root\>'
|
||||||
|
return v:true
|
||||||
|
endif
|
||||||
|
return v:false
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Get all messages but drop the maintainer entry.
|
" Get all messages but drop the maintainer entry.
|
||||||
func GetMessages()
|
func GetMessages()
|
||||||
redir => result
|
redir => result
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
" Test rename()
|
" Test rename()
|
||||||
|
|
||||||
|
source shared.vim
|
||||||
|
|
||||||
func Test_rename_file_to_file()
|
func Test_rename_file_to_file()
|
||||||
call writefile(['foo'], 'Xrename1')
|
call writefile(['foo'], 'Xrename1')
|
||||||
|
|
||||||
@ -81,7 +83,7 @@ func Test_rename_copy()
|
|||||||
|
|
||||||
call assert_equal(0, rename('Xrenamedir/Xrenamefile', 'Xrenamefile'))
|
call assert_equal(0, rename('Xrenamedir/Xrenamefile', 'Xrenamefile'))
|
||||||
|
|
||||||
if !has('win32')
|
if !has('win32') && !IsRoot()
|
||||||
" On Windows, the source file is removed despite
|
" On Windows, the source file is removed despite
|
||||||
" its directory being made not writable.
|
" its directory being made not writable.
|
||||||
call assert_equal(['foo'], readfile('Xrenamedir/Xrenamefile'))
|
call assert_equal(['foo'], readfile('Xrenamedir/Xrenamefile'))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
" Tests for the swap feature
|
" Tests for the swap feature
|
||||||
|
|
||||||
source check.vim
|
source check.vim
|
||||||
|
source shared.vim
|
||||||
|
|
||||||
func s:swapname()
|
func s:swapname()
|
||||||
return trim(execute('swapname'))
|
return trim(execute('swapname'))
|
||||||
@ -198,14 +199,17 @@ func Test_swapfile_delete()
|
|||||||
quit
|
quit
|
||||||
call assert_equal(fnamemodify(swapfile_name, ':t'), fnamemodify(s:swapname, ':t'))
|
call assert_equal(fnamemodify(swapfile_name, ':t'), fnamemodify(s:swapname, ':t'))
|
||||||
|
|
||||||
" Write the swapfile with a modified PID, now it will be automatically
|
" This test won't work as root because root can successfully run kill(1, 0)
|
||||||
" deleted. Process one should never be Vim.
|
if !IsRoot()
|
||||||
let swapfile_bytes[24:27] = 0z01000000
|
" Write the swapfile with a modified PID, now it will be automatically
|
||||||
call writefile(swapfile_bytes, swapfile_name)
|
" deleted. Process one should never be Vim.
|
||||||
let s:swapname = ''
|
let swapfile_bytes[24:27] = 0z01000000
|
||||||
split XswapfileText
|
call writefile(swapfile_bytes, swapfile_name)
|
||||||
quit
|
let s:swapname = ''
|
||||||
call assert_equal('', s:swapname)
|
split XswapfileText
|
||||||
|
quit
|
||||||
|
call assert_equal('', s:swapname)
|
||||||
|
endif
|
||||||
|
|
||||||
" Now set the modified flag, the swap file will not be deleted
|
" Now set the modified flag, the swap file will not be deleted
|
||||||
let swapfile_bytes[28 + 80 + 899] = 0x55
|
let swapfile_bytes[28 + 80 + 899] = 0x55
|
||||||
|
Loading…
Reference in New Issue
Block a user