0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.2623: some tests fail when run as root

Problem:    Some tests fail when run as root.
Solution:   Use CheckNotRoot.
This commit is contained in:
Bram Moolenaar 2021-03-19 14:38:12 +01:00
parent a555e6fcb6
commit 17709e280a
5 changed files with 49 additions and 31 deletions

View File

@ -1704,9 +1704,10 @@ func Test_edit_charconvert()
endfunc endfunc
" Test for editing a file without read permission " Test for editing a file without read permission
" NOTE: if you run tests as root this will fail. Don't run tests as root!
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

View File

@ -350,13 +350,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
@ -369,6 +362,17 @@ func Test_redir_cmd()
call assert_equal('blue sky', color) call assert_equal('blue sky', color)
endfunc endfunc
func Test_redir_cmd_readonly()
CheckNotRoot
CheckNotBSD
" 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:')

View File

@ -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=
@ -88,8 +90,19 @@ 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')
" 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')
endfunc
func Test_helptag_cmd_readonly()
CheckUnix
CheckNotRoot
" The following tests fail on FreeBSD for some reason " The following tests fail on FreeBSD for some reason
if has('unix') && !has('bsd') CheckNotBSD
" 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')
@ -105,17 +118,12 @@ 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
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@ -410,6 +410,9 @@ endfunc
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--')

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2623,
/**/ /**/
2622, 2622,
/**/ /**/