1
0
forked from aniani/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.
This commit is contained in:
Bram Moolenaar
2022-12-05 13:50:55 +00:00
parent 65214053f6
commit c216a7a21a
14 changed files with 104 additions and 71 deletions

View File

@@ -160,6 +160,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
@@ -186,6 +194,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
@@ -339,6 +363,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)