vim-patch:9.0.2045: tests: checking for swap files takes time

Problem:  tests: checking for swap files takes time
Solution: don't check for swap files  when test has been skipped

Check for swap files takes a considerable about of time, so don't do
that for skipped tests to avoid wasting time.

closes: vim/vim#13371

a0e1f06f04
This commit is contained in:
zeertzjq
2023-10-18 18:29:51 +08:00
parent 9e3640a779
commit 09fb243bdd

View File

@@ -231,6 +231,8 @@ func RunTheTest(test)
endtry endtry
endif endif
let skipped = v:false
au VimLeavePre * call EarlyExit(g:testfunc) au VimLeavePre * call EarlyExit(g:testfunc)
if a:test =~ 'Test_nocatch_' if a:test =~ 'Test_nocatch_'
" Function handles errors itself. This avoids skipping commands after the " Function handles errors itself. This avoids skipping commands after the
@@ -240,6 +242,7 @@ func RunTheTest(test)
if g:skipped_reason != '' if g:skipped_reason != ''
call add(s:messages, ' Skipped') call add(s:messages, ' Skipped')
call add(s:skipped, 'SKIPPED ' . a:test . ': ' . g:skipped_reason) call add(s:skipped, 'SKIPPED ' . a:test . ': ' . g:skipped_reason)
let skipped = v:true
endif endif
else else
try try
@@ -247,6 +250,7 @@ func RunTheTest(test)
catch /^\cskipped/ catch /^\cskipped/
call add(s:messages, ' Skipped') call add(s:messages, ' Skipped')
call add(s:skipped, 'SKIPPED ' . a:test . ': ' . substitute(v:exception, '^\S*\s\+', '', '')) call add(s:skipped, 'SKIPPED ' . a:test . ': ' . substitute(v:exception, '^\S*\s\+', '', ''))
let skipped = v:true
catch catch
call add(v:errors, 'Caught exception in ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint) call add(v:errors, 'Caught exception in ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint)
endtry endtry
@@ -342,14 +346,16 @@ func RunTheTest(test)
endif endif
endwhile endwhile
" Check if the test has left any swap files behind. Delete them before if !skipped
" running tests again, they might interfere. " Check if the test has left any swap files behind. Delete them before
let swapfiles = s:GetSwapFileList() " running tests again, they might interfere.
if len(swapfiles) > 0 let swapfiles = s:GetSwapFileList()
call add(s:messages, "Found swap files: " .. string(swapfiles)) if len(swapfiles) > 0
for name in swapfiles call add(s:messages, "Found swap files: " .. string(swapfiles))
call delete(name) for name in swapfiles
endfor call delete(name)
endfor
endif
endif endif
endfunc endfunc