vim-patch:8.0.1222: test functions interfere with each other

Problem:    Test functions interfere with each other.
Solution:   Cleanup tab pages, windows and buffers.  Reset option.

ce11de87e2
This commit is contained in:
Justin M. Keyes 2018-02-03 12:09:37 +01:00
parent 48af5991b9
commit 348193f49c
3 changed files with 16 additions and 3 deletions

View File

@ -110,7 +110,11 @@ func RunTheTest(test)
endtry endtry
endif endif
" Close any extra windows and make the current one not modified. " Close any extra tab pages and windows and make the current one not modified.
while tabpagenr('$') > 1
bwipe!
endwhile
while 1 while 1
let wincount = winnr('$') let wincount = winnr('$')
if wincount == 1 if wincount == 1
@ -123,7 +127,15 @@ func RunTheTest(test)
break break
endif endif
endwhile endwhile
" Wipe out all buffers except the current one, then wipe the current one.
for nr in range(1, bufnr('$'))
if nr != bufnr('%') && bufexists(nr)
exe nr . 'bwipe!'
endif
endfor
set nomodified set nomodified
bwipe
endfunc endfunc
func AfterTheTest() func AfterTheTest()

View File

@ -547,7 +547,7 @@ func Test_script_detection()
for file in files for file in files
call writefile(file, 'Xtest') call writefile(file, 'Xtest')
split Xtest split Xtest
call assert_equal(ft, &filetype) call assert_equal(ft, &filetype, 'for text: ' . string(file))
bwipe! bwipe!
endfor endfor
endfor endfor

View File

@ -475,6 +475,7 @@ endfunc
func Test_close_on_quitpre() func Test_close_on_quitpre()
" This once caused a crash " This once caused a crash
edit Xtest
new new
only only
set bufhidden=delete set bufhidden=delete
@ -489,7 +490,7 @@ func Test_close_on_quitpre()
while tabpagenr('$') > 1 while tabpagenr('$') > 1
bwipe! bwipe!
endwhile endwhile
1b buf Xtest
endfunc endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab