aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-19 10:06:34 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-04-19 11:29:35 +0800
commit85c61d67160133ba53762bc1e5e7bbd7a0c582c0 (patch)
tree5931d3222fcac7d05fc53481e63dae5422b8fdd4 /test
parentd82a6ca72aca57d89cfb8954abf2ae3980f85c04 (diff)
downloadrneovim-85c61d67160133ba53762bc1e5e7bbd7a0c582c0.tar.gz
rneovim-85c61d67160133ba53762bc1e5e7bbd7a0c582c0.tar.bz2
rneovim-85c61d67160133ba53762bc1e5e7bbd7a0c582c0.zip
vim-patch:9.0.1007: there is no way to get a list of swap file names
Problem: There is no way to get a list of swap file names. Solution: Add the swapfilelist() function. Use it in the test script to clean up. Remove deleting individual swap files. https://github.com/vim/vim/commit/c216a7a21a25a701b84b79abc1ba6ab0baa3a311 vim-patch:9.0.1005: a failed test may leave a swap file behind Problem: A failed test may leave a swap file behind. Solution: Delete the swap file to avoid another test to fail. Use another file name. https://github.com/vim/vim/commit/d0f8d39d20f8d42f7451f781f7be0bcd20e06741 Cherry-pick test_window_cmd.vim changes from patch 8.2.1593. Remove FUNC_ATTR_UNUSED from eval functions as fptr is always unused. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/runtest.vim34
-rw-r--r--test/old/testdir/test_swap.vim9
-rw-r--r--test/old/testdir/test_syntax.vim2
-rw-r--r--test/old/testdir/test_window_cmd.vim10
4 files changed, 48 insertions, 7 deletions
diff --git a/test/old/testdir/runtest.vim b/test/old/testdir/runtest.vim
index 114a3229d4..6d8213d27c 100644
--- a/test/old/testdir/runtest.vim
+++ b/test/old/testdir/runtest.vim
@@ -130,6 +130,14 @@ if has('mac')
let $BASH_SILENCE_DEPRECATION_WARNING = 1
endif
+
+" A previous (failed) test run may have left swap files behind. Delete them
+" before running tests again, they might interfere.
+for name in s:GetSwapFileList()
+ call delete(name)
+endfor
+
+
" Prepare for calling test_garbagecollect_now().
let v:testing = 1
@@ -152,6 +160,22 @@ if has('reltime')
let g:func_start = reltime()
endif
+" Get the list of swap files in the current directory.
+func s:GetSwapFileList()
+ let save_dir = &directory
+ let &directory = '.'
+ let files = swapfilelist()
+ let &directory = save_dir
+
+ " remove a match with runtest.vim
+ let idx = indexof(files, 'v:val =~ "runtest.vim."')
+ if idx >= 0
+ call remove(files, idx)
+ endif
+
+ return files
+endfunc
+
" Invoked when a test takes too much time.
func TestTimeout(id)
split test.log
@@ -294,6 +318,16 @@ func RunTheTest(test)
endif
call add(s:messages, message)
let s:done += 1
+
+ " Check if the test has left any swap files behind. Delete them before
+ " running tests again, they might interfere.
+ let swapfiles = s:GetSwapFileList()
+ if len(swapfiles) > 0
+ call add(s:messages, "Found swap files: " .. string(swapfiles))
+ for name in swapfiles
+ call delete(name)
+ endfor
+ endif
endfunc
func AfterTheTest(func_name)
diff --git a/test/old/testdir/test_swap.vim b/test/old/testdir/test_swap.vim
index 4241f4fd69..2786807e2e 100644
--- a/test/old/testdir/test_swap.vim
+++ b/test/old/testdir/test_swap.vim
@@ -115,6 +115,15 @@ func Test_swapinfo()
w
let fname = s:swapname()
call assert_match('Xswapinfo', fname)
+
+ let nr = 0
+ for name in swapfilelist()
+ if name =~ '[\\/]' .. fname .. '$'
+ let nr += 1
+ endif
+ endfor
+ call assert_equal(1, nr)
+
let info = fname->swapinfo()
let ver = printf('VIM %d.%d', v:version / 100, v:version % 100)
diff --git a/test/old/testdir/test_syntax.vim b/test/old/testdir/test_syntax.vim
index 886c23efa7..c9ad4bb857 100644
--- a/test/old/testdir/test_syntax.vim
+++ b/test/old/testdir/test_syntax.vim
@@ -460,7 +460,7 @@ func Test_invalid_name()
endfunc
func Test_ownsyntax()
- new Xfoo
+ new XfooOwnSyntax
call setline(1, '#define FOO')
syntax on
set filetype=c
diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim
index 34614832a9..88135199fe 100644
--- a/test/old/testdir/test_window_cmd.vim
+++ b/test/old/testdir/test_window_cmd.vim
@@ -119,10 +119,9 @@ endfunc
" Test the ":wincmd ^" and "<C-W>^" commands.
func Test_window_split_edit_alternate()
-
" Test for failure when the alternate buffer/file no longer exists.
edit Xfoo | %bw
- call assert_fails(':wincmd ^', 'E23')
+ call assert_fails(':wincmd ^', 'E23:')
" Test for the expected behavior when we have two named buffers.
edit Xfoo | edit Xbar
@@ -152,12 +151,11 @@ endfunc
" Test the ":[count]wincmd ^" and "[count]<C-W>^" commands.
func Test_window_split_edit_bufnr()
-
%bwipeout
let l:nr = bufnr('%') + 1
- call assert_fails(':execute "normal! ' . l:nr . '\<C-W>\<C-^>"', 'E92')
- call assert_fails(':' . l:nr . 'wincmd ^', 'E16')
- call assert_fails(':0wincmd ^', 'E16')
+ call assert_fails(':execute "normal! ' . l:nr . '\<C-W>\<C-^>"', 'E92:')
+ call assert_fails(':' . l:nr . 'wincmd ^', 'E16:')
+ call assert_fails(':0wincmd ^', 'E16:')
edit Xfoo | edit Xbar | edit Xbaz
let l:foo_nr = bufnr('Xfoo')