Skip to content

Commit 17709e2

Browse files
committed
patch 8.2.2623: some tests fail when run as root
Problem: Some tests fail when run as root. Solution: Use CheckNotRoot.
1 parent a555e6f commit 17709e2

5 files changed

Lines changed: 49 additions & 31 deletions

File tree

src/testdir/test_edit.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,9 +1704,10 @@ func Test_edit_charconvert()
17041704
endfunc
17051705

17061706
" Test for editing a file without read permission
1707-
" NOTE: if you run tests as root this will fail. Don't run tests as root!
17081707
func Test_edit_file_no_read_perm()
17091708
CheckUnix
1709+
CheckNotRoot
1710+
17101711
call writefile(['one', 'two'], 'Xfile')
17111712
call setfperm('Xfile', '-w-------')
17121713
new

src/testdir/test_excmd.vim

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,6 @@ func Test_redir_cmd()
350350
call assert_fails('redir > Xdir', 'E17:')
351351
call delete('Xdir', 'd')
352352
endif
353-
if !has('bsd')
354-
" Redirecting to a read-only file
355-
call writefile([], 'Xfile')
356-
call setfperm('Xfile', 'r--r--r--')
357-
call assert_fails('redir! > Xfile', 'E190:')
358-
call delete('Xfile')
359-
endif
360353

361354
" Test for redirecting to a register
362355
redir @q> | echon 'clean ' | redir END
@@ -369,6 +362,17 @@ func Test_redir_cmd()
369362
call assert_equal('blue sky', color)
370363
endfunc
371364

365+
func Test_redir_cmd_readonly()
366+
CheckNotRoot
367+
CheckNotBSD
368+
369+
" Redirecting to a read-only file
370+
call writefile([], 'Xfile')
371+
call setfperm('Xfile', 'r--r--r--')
372+
call assert_fails('redir! > Xfile', 'E190:')
373+
call delete('Xfile')
374+
endfunc
375+
372376
" Test for the :filetype command
373377
func Test_filetype_cmd()
374378
call assert_fails('filetype abc', 'E475:')

src/testdir/test_help.vim

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
" Tests for :help
22

3+
source check.vim
4+
35
func Test_help_restore_snapshot()
46
help
57
set buftype=
@@ -88,34 +90,40 @@ func Test_helptag_cmd()
8890
call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags'))
8991
call delete('Xdir/tags')
9092

91-
" The following tests fail on FreeBSD for some reason
92-
if has('unix') && !has('bsd')
93-
" Read-only tags file
94-
call mkdir('Xdir/doc', 'p')
95-
call writefile([''], 'Xdir/doc/tags')
96-
call writefile([], 'Xdir/doc/sample.txt')
97-
call setfperm('Xdir/doc/tags', 'r-xr--r--')
98-
call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags'))
99-
100-
let rtp = &rtp
101-
let &rtp = 'Xdir'
102-
helptags ALL
103-
let &rtp = rtp
104-
105-
call delete('Xdir/doc/tags')
106-
107-
" No permission to read the help file
108-
call setfperm('Xdir/a/doc/sample.txt', '-w-------')
109-
call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/a/doc/sample.txt'))
110-
call delete('Xdir/a/doc/sample.txt')
111-
call delete('Xdir/tags')
112-
endif
113-
11493
" Duplicate tags in the help file
11594
call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt')
11695
call assert_fails('helptags Xdir', 'E154:')
11796

11897
call delete('Xdir', 'rf')
11998
endfunc
12099

100+
func Test_helptag_cmd_readonly()
101+
CheckUnix
102+
CheckNotRoot
103+
" The following tests fail on FreeBSD for some reason
104+
CheckNotBSD
105+
106+
" Read-only tags file
107+
call mkdir('Xdir/doc', 'p')
108+
call writefile([''], 'Xdir/doc/tags')
109+
call writefile([], 'Xdir/doc/sample.txt')
110+
call setfperm('Xdir/doc/tags', 'r-xr--r--')
111+
call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags'))
112+
113+
let rtp = &rtp
114+
let &rtp = 'Xdir'
115+
helptags ALL
116+
let &rtp = rtp
117+
118+
call delete('Xdir/doc/tags')
119+
120+
" No permission to read the help file
121+
call mkdir('Xdir/b/doc', 'p')
122+
call writefile([], 'Xdir/b/doc/sample.txt')
123+
call setfperm('Xdir/b/doc/sample.txt', '-w-------')
124+
call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/b/doc/sample.txt'))
125+
call delete('Xdir', 'rf')
126+
endfunc
127+
128+
121129
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_writefile.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ endfunc
410410
func Test_write_readonly_dir()
411411
" On MS-Windows, modifying files in a read-only directory is allowed.
412412
CheckUnix
413+
" Root can do it too.
414+
CheckNotRoot
415+
413416
call mkdir('Xdir')
414417
call writefile(['one'], 'Xdir/Xfile1')
415418
call setfperm('Xdir', 'r-xr--r--')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2623,
753755
/**/
754756
2622,
755757
/**/

0 commit comments

Comments
 (0)