From df71537a12e454075e02824bb8f570e1e838ee64 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Nov 2022 22:15:33 +0800 Subject: [PATCH 1/4] vim-patch:8.2.2570: tests fail when run as root Problem: Tests fail when run as root. Solution: Add a comment mentioning the expected failure. (issue vim/vim#7919) https://github.com/vim/vim/commit/f9a65505d1d93f3e67e5b8646bde3bbc44c70f7d Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_edit.vim | 1 + src/nvim/testdir/test_excmd.vim | 1 + src/nvim/testdir/test_help.vim | 1 + src/nvim/testdir/test_writefile.vim | 1 + 4 files changed, 4 insertions(+) diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index 4994e7af8f..bd7b5609a5 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1834,6 +1834,7 @@ func Test_edit_charconvert() endfunc " 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() CheckUnix call writefile(['one', 'two'], 'Xfile') diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim index 582dcaac2c..91fdb23a63 100644 --- a/src/nvim/testdir/test_excmd.vim +++ b/src/nvim/testdir/test_excmd.vim @@ -476,6 +476,7 @@ func Test_winsize_cmd() endfunc " 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() call assert_fails('redir @@', 'E475:') call assert_fails('redir abc', 'E475:') diff --git a/src/nvim/testdir/test_help.vim b/src/nvim/testdir/test_help.vim index 19c0fcd820..5779cc6d11 100644 --- a/src/nvim/testdir/test_help.vim +++ b/src/nvim/testdir/test_help.vim @@ -98,6 +98,7 @@ func Test_help_completion() endfunc " 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() call mkdir('Xdir/a/doc', 'p') diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim index e4950de658..738e66ea27 100644 --- a/src/nvim/testdir/test_writefile.vim +++ b/src/nvim/testdir/test_writefile.vim @@ -419,6 +419,7 @@ func Test_patchmode() endfunc " 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() " On MS-Windows, modifying files in a read-only directory is allowed. CheckUnix From fbe2761b20afaf25a02c06decaf543d211e997f0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Nov 2022 22:15:59 +0800 Subject: [PATCH 2/4] vim-patch:8.2.2623: some tests fail when run as root Problem: Some tests fail when run as root. Solution: Use CheckNotRoot. https://github.com/vim/vim/commit/17709e280ac5ba234b04641cde88d38e3522cedf Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_edit.vim | 3 +- src/nvim/testdir/test_excmd.vim | 18 ++++++---- src/nvim/testdir/test_help.vim | 53 ++++++++++++++++------------- src/nvim/testdir/test_writefile.vim | 3 ++ 4 files changed, 46 insertions(+), 31 deletions(-) diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index bd7b5609a5..dc850515b0 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1834,9 +1834,10 @@ func Test_edit_charconvert() endfunc " 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() CheckUnix + CheckNotRoot + call writefile(['one', 'two'], 'Xfile') call setfperm('Xfile', '-w-------') new diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim index 91fdb23a63..0e8af08b4b 100644 --- a/src/nvim/testdir/test_excmd.vim +++ b/src/nvim/testdir/test_excmd.vim @@ -493,13 +493,6 @@ func Test_redir_cmd() call assert_fails('redir > Xdir', 'E17:') call delete('Xdir', 'd') 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 redir @q> | echon 'clean ' | redir END @@ -512,6 +505,17 @@ func Test_redir_cmd() call assert_equal('blue sky', color) 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 func Test_filetype_cmd() call assert_fails('filetype abc', 'E475:') diff --git a/src/nvim/testdir/test_help.vim b/src/nvim/testdir/test_help.vim index 5779cc6d11..787f673991 100644 --- a/src/nvim/testdir/test_help.vim +++ b/src/nvim/testdir/test_help.vim @@ -1,5 +1,7 @@ " Tests for :help +source check.vim + func Test_help_restore_snapshot() help set buftype= @@ -112,29 +114,6 @@ func Test_helptag_cmd() call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags')) call delete('Xdir/tags') - " The following tests fail on FreeBSD for some reason - if has('unix') && !has('bsd') - " Read-only tags file - call mkdir('Xdir/doc', 'p') - call writefile([''], 'Xdir/doc/tags') - call writefile([], 'Xdir/doc/sample.txt') - call setfperm('Xdir/doc/tags', 'r-xr--r--') - call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags')) - - let rtp = &rtp - let &rtp = 'Xdir' - helptags ALL - let &rtp = rtp - - call delete('Xdir/doc/tags') - - " No permission to read the help file - call setfperm('Xdir/a/doc/sample.txt', '-w-------') - call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/a/doc/sample.txt')) - call delete('Xdir/a/doc/sample.txt') - call delete('Xdir/tags') - endif - " Duplicate tags in the help file call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt') call assert_fails('helptags Xdir', 'E154:') @@ -142,6 +121,34 @@ func Test_helptag_cmd() call delete('Xdir', 'rf') endfunc +func Test_helptag_cmd_readonly() + CheckUnix + CheckNotRoot + " The following tests fail on FreeBSD for some reason + CheckNotBSD + + " Read-only tags file + call mkdir('Xdir/doc', 'p') + call writefile([''], 'Xdir/doc/tags') + call writefile([], 'Xdir/doc/sample.txt') + call setfperm('Xdir/doc/tags', 'r-xr--r--') + call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags')) + + let rtp = &rtp + let &rtp = 'Xdir' + helptags ALL + let &rtp = rtp + + call delete('Xdir/doc/tags') + + " No permission to read the help file + call mkdir('Xdir/b/doc', 'p') + call writefile([], 'Xdir/b/doc/sample.txt') + call setfperm('Xdir/b/doc/sample.txt', '-w-------') + call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/b/doc/sample.txt')) + call delete('Xdir', 'rf') +endfunc + " Test for setting the 'helpheight' option in the help window func Test_help_window_height() let &cmdheight = &lines - 24 diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim index 738e66ea27..a7ebe8cde6 100644 --- a/src/nvim/testdir/test_writefile.vim +++ b/src/nvim/testdir/test_writefile.vim @@ -423,6 +423,9 @@ endfunc func Test_write_readonly_dir() " On MS-Windows, modifying files in a read-only directory is allowed. CheckUnix + " Root can do it too. + CheckNotRoot + call mkdir('Xdir') call writefile(['one'], 'Xdir/Xfile1') call setfperm('Xdir', 'r-xr--r--') From bfa0be49ed07d1e576c6452bb7e82956df7b19d5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Nov 2022 22:28:39 +0800 Subject: [PATCH 3/4] vim-patch:8.2.2627: no need to check for BSD after checking for not root Problem: No need to check for BSD after checking for not root. Solution: Remove CheckNotBSD. (Ozaki Kiichi, closes vim/vim#7989) https://github.com/vim/vim/commit/4355894869355c185e7810e67d52802453576e81 --- src/nvim/testdir/check.vim | 9 --------- src/nvim/testdir/test_excmd.vim | 1 - src/nvim/testdir/test_help.vim | 2 -- 3 files changed, 12 deletions(-) diff --git a/src/nvim/testdir/check.vim b/src/nvim/testdir/check.vim index 1459b70243..8a1080a2f3 100644 --- a/src/nvim/testdir/check.vim +++ b/src/nvim/testdir/check.vim @@ -90,15 +90,6 @@ func CheckUnix() endif 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. " Caller must source screendump.vim command CheckScreendump call CheckScreendump() diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim index 0e8af08b4b..42b1f8ca48 100644 --- a/src/nvim/testdir/test_excmd.vim +++ b/src/nvim/testdir/test_excmd.vim @@ -507,7 +507,6 @@ endfunc func Test_redir_cmd_readonly() CheckNotRoot - CheckNotBSD " Redirecting to a read-only file call writefile([], 'Xfile') diff --git a/src/nvim/testdir/test_help.vim b/src/nvim/testdir/test_help.vim index 787f673991..6478ae5dbf 100644 --- a/src/nvim/testdir/test_help.vim +++ b/src/nvim/testdir/test_help.vim @@ -124,8 +124,6 @@ endfunc func Test_helptag_cmd_readonly() CheckUnix CheckNotRoot - " The following tests fail on FreeBSD for some reason - CheckNotBSD " Read-only tags file call mkdir('Xdir/doc', 'p') From 8c454776f8a1d030b326347e1dd2d4e1fd6d7f7f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Nov 2022 22:32:47 +0800 Subject: [PATCH 4/4] vim-patch:8.2.4495: help test fails in 24 line terminal Problem: Help test fails in 24 line terminal. Solution: Use up to 23 lines for text. https://github.com/vim/vim/commit/e4e1a1e1c8a2bc6efd806e379b5fc80998318830 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_help.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/testdir/test_help.vim b/src/nvim/testdir/test_help.vim index 6478ae5dbf..e30d305703 100644 --- a/src/nvim/testdir/test_help.vim +++ b/src/nvim/testdir/test_help.vim @@ -149,7 +149,7 @@ endfunc " Test for setting the 'helpheight' option in the help window func Test_help_window_height() - let &cmdheight = &lines - 24 + let &cmdheight = &lines - 23 set helpheight=10 help set helpheight=14