mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
Merge pull request #20968 from zeertzjq/vim-8.2.2570
vim-patch:8.2.{2570,2623,2627,4495}: tests fail when run as root
This commit is contained in:
@@ -90,15 +90,6 @@ func CheckUnix()
|
|||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Command to check for not running on a BSD system.
|
|
||||||
" TODO: using this checks should not be needed
|
|
||||||
command CheckNotBSD call CheckNotBSD()
|
|
||||||
func CheckNotBSD()
|
|
||||||
if has('bsd')
|
|
||||||
throw 'Skipped: does not work on BSD'
|
|
||||||
endif
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
" Command to check that making screendumps is supported.
|
" Command to check that making screendumps is supported.
|
||||||
" Caller must source screendump.vim
|
" Caller must source screendump.vim
|
||||||
command CheckScreendump call CheckScreendump()
|
command CheckScreendump call CheckScreendump()
|
||||||
|
@@ -1836,6 +1836,8 @@ endfunc
|
|||||||
" Test for editing a file without read permission
|
" Test for editing a file without read permission
|
||||||
func Test_edit_file_no_read_perm()
|
func Test_edit_file_no_read_perm()
|
||||||
CheckUnix
|
CheckUnix
|
||||||
|
CheckNotRoot
|
||||||
|
|
||||||
call writefile(['one', 'two'], 'Xfile')
|
call writefile(['one', 'two'], 'Xfile')
|
||||||
call setfperm('Xfile', '-w-------')
|
call setfperm('Xfile', '-w-------')
|
||||||
new
|
new
|
||||||
|
@@ -476,6 +476,7 @@ func Test_winsize_cmd()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for the :redir command
|
" Test for the :redir command
|
||||||
|
" NOTE: if you run tests as root this will fail. Don't run tests as root!
|
||||||
func Test_redir_cmd()
|
func Test_redir_cmd()
|
||||||
call assert_fails('redir @@', 'E475:')
|
call assert_fails('redir @@', 'E475:')
|
||||||
call assert_fails('redir abc', 'E475:')
|
call assert_fails('redir abc', 'E475:')
|
||||||
@@ -492,13 +493,6 @@ func Test_redir_cmd()
|
|||||||
call assert_fails('redir > Xdir', 'E17:')
|
call assert_fails('redir > Xdir', 'E17:')
|
||||||
call delete('Xdir', 'd')
|
call delete('Xdir', 'd')
|
||||||
endif
|
endif
|
||||||
if !has('bsd')
|
|
||||||
" Redirecting to a read-only file
|
|
||||||
call writefile([], 'Xfile')
|
|
||||||
call setfperm('Xfile', 'r--r--r--')
|
|
||||||
call assert_fails('redir! > Xfile', 'E190:')
|
|
||||||
call delete('Xfile')
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Test for redirecting to a register
|
" Test for redirecting to a register
|
||||||
redir @q> | echon 'clean ' | redir END
|
redir @q> | echon 'clean ' | redir END
|
||||||
@@ -511,6 +505,16 @@ func Test_redir_cmd()
|
|||||||
call assert_equal('blue sky', color)
|
call assert_equal('blue sky', color)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_redir_cmd_readonly()
|
||||||
|
CheckNotRoot
|
||||||
|
|
||||||
|
" Redirecting to a read-only file
|
||||||
|
call writefile([], 'Xfile')
|
||||||
|
call setfperm('Xfile', 'r--r--r--')
|
||||||
|
call assert_fails('redir! > Xfile', 'E190:')
|
||||||
|
call delete('Xfile')
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for the :filetype command
|
" Test for the :filetype command
|
||||||
func Test_filetype_cmd()
|
func Test_filetype_cmd()
|
||||||
call assert_fails('filetype abc', 'E475:')
|
call assert_fails('filetype abc', 'E475:')
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
" Tests for :help
|
" Tests for :help
|
||||||
|
|
||||||
|
source check.vim
|
||||||
|
|
||||||
func Test_help_restore_snapshot()
|
func Test_help_restore_snapshot()
|
||||||
help
|
help
|
||||||
set buftype=
|
set buftype=
|
||||||
@@ -98,6 +100,7 @@ func Test_help_completion()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for the :helptags command
|
" Test for the :helptags command
|
||||||
|
" NOTE: if you run tests as root this will fail. Don't run tests as root!
|
||||||
func Test_helptag_cmd()
|
func Test_helptag_cmd()
|
||||||
call mkdir('Xdir/a/doc', 'p')
|
call mkdir('Xdir/a/doc', 'p')
|
||||||
|
|
||||||
@@ -111,8 +114,17 @@ func Test_helptag_cmd()
|
|||||||
call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags'))
|
call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags'))
|
||||||
call delete('Xdir/tags')
|
call delete('Xdir/tags')
|
||||||
|
|
||||||
" The following tests fail on FreeBSD for some reason
|
" Duplicate tags in the help file
|
||||||
if has('unix') && !has('bsd')
|
call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt')
|
||||||
|
call assert_fails('helptags Xdir', 'E154:')
|
||||||
|
|
||||||
|
call delete('Xdir', 'rf')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_helptag_cmd_readonly()
|
||||||
|
CheckUnix
|
||||||
|
CheckNotRoot
|
||||||
|
|
||||||
" Read-only tags file
|
" Read-only tags file
|
||||||
call mkdir('Xdir/doc', 'p')
|
call mkdir('Xdir/doc', 'p')
|
||||||
call writefile([''], 'Xdir/doc/tags')
|
call writefile([''], 'Xdir/doc/tags')
|
||||||
@@ -128,22 +140,16 @@ func Test_helptag_cmd()
|
|||||||
call delete('Xdir/doc/tags')
|
call delete('Xdir/doc/tags')
|
||||||
|
|
||||||
" No permission to read the help file
|
" No permission to read the help file
|
||||||
call setfperm('Xdir/a/doc/sample.txt', '-w-------')
|
call mkdir('Xdir/b/doc', 'p')
|
||||||
call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/a/doc/sample.txt'))
|
call writefile([], 'Xdir/b/doc/sample.txt')
|
||||||
call delete('Xdir/a/doc/sample.txt')
|
call setfperm('Xdir/b/doc/sample.txt', '-w-------')
|
||||||
call delete('Xdir/tags')
|
call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/b/doc/sample.txt'))
|
||||||
endif
|
|
||||||
|
|
||||||
" Duplicate tags in the help file
|
|
||||||
call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt')
|
|
||||||
call assert_fails('helptags Xdir', 'E154:')
|
|
||||||
|
|
||||||
call delete('Xdir', 'rf')
|
call delete('Xdir', 'rf')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for setting the 'helpheight' option in the help window
|
" Test for setting the 'helpheight' option in the help window
|
||||||
func Test_help_window_height()
|
func Test_help_window_height()
|
||||||
let &cmdheight = &lines - 24
|
let &cmdheight = &lines - 23
|
||||||
set helpheight=10
|
set helpheight=10
|
||||||
help
|
help
|
||||||
set helpheight=14
|
set helpheight=14
|
||||||
|
@@ -419,9 +419,13 @@ func Test_patchmode()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for writing to a file in a readonly directory
|
" Test for writing to a file in a readonly directory
|
||||||
|
" NOTE: if you run tests as root this will fail. Don't run tests as root!
|
||||||
func Test_write_readonly_dir()
|
func Test_write_readonly_dir()
|
||||||
" On MS-Windows, modifying files in a read-only directory is allowed.
|
" On MS-Windows, modifying files in a read-only directory is allowed.
|
||||||
CheckUnix
|
CheckUnix
|
||||||
|
" Root can do it too.
|
||||||
|
CheckNotRoot
|
||||||
|
|
||||||
call mkdir('Xdir')
|
call mkdir('Xdir')
|
||||||
call writefile(['one'], 'Xdir/Xfile1')
|
call writefile(['one'], 'Xdir/Xfile1')
|
||||||
call setfperm('Xdir', 'r-xr--r--')
|
call setfperm('Xdir', 'r-xr--r--')
|
||||||
|
Reference in New Issue
Block a user