Skip to content

Commit cf1ba35

Browse files
committed
patch 8.0.1224: still interference between test functions
Problem: Still interference between test functions. Solution: Clear autocommands. Wipe all buffers. Fix tests that depend on a specific start context.
1 parent 9ad89c6 commit cf1ba35

12 files changed

Lines changed: 32 additions & 29 deletions

src/testdir/runtest.vim

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ func RunTheTest(test)
9999
" Clear any overrides.
100100
call test_override('ALL', 0)
101101

102+
" Some tests wipe out buffers. To be consistent, always wipe out all
103+
" buffers.
104+
%bwipe!
105+
102106
if exists("*SetUp")
103107
try
104108
call SetUp()
@@ -133,9 +137,12 @@ func RunTheTest(test)
133137
endtry
134138
endif
135139

140+
" Clear any autocommands
141+
au!
142+
136143
" Close any extra tab pages and windows and make the current one not modified.
137144
while tabpagenr('$') > 1
138-
bwipe!
145+
quit!
139146
endwhile
140147

141148
while 1
@@ -150,15 +157,6 @@ func RunTheTest(test)
150157
break
151158
endif
152159
endwhile
153-
154-
" Wipe out all buffers except the current one, then wipe the current one.
155-
for nr in range(1, bufnr('$'))
156-
if nr != bufnr('%') && bufexists(nr)
157-
exe nr . 'bwipe!'
158-
endif
159-
endfor
160-
set nomodified
161-
bwipe
162160
endfunc
163161

164162
func AfterTheTest()

src/testdir/test_arglist.vim

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,7 @@ func Test_argedit()
253253
call assert_equal(['a', 'b', 'a'], argv())
254254
call assert_equal('a', expand('%:t'))
255255
" When file name case is ignored, an existing buffer with only case
256-
" difference is re-used. Make sure they don't exist so the case is
257-
" preserved.
258-
bwipe! c
259-
bwipe! d
256+
" difference is re-used.
260257
argedit C D
261258
call assert_equal('C', expand('%:t'))
262259
call assert_equal(['a', 'b', 'a', 'C', 'D'], argv())

src/testdir/test_autochdir.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ if !exists("+autochdir")
55
endif
66

77
func Test_set_filename()
8+
let cwd = getcwd()
89
call test_autochdir()
910
set acd
1011
new
@@ -13,5 +14,6 @@ func Test_set_filename()
1314
call assert_equal("samples", substitute(getcwd(), '.*/\(\k*\)', '\1', ''))
1415
bwipe!
1516
set noacd
17+
exe 'cd ' . cwd
1618
call delete('samples/Xtest')
1719
endfunc

src/testdir/test_autocmd.vim

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,15 @@ func Test_BufReadCmdHelp()
254254
au BufReadCmd * e +h
255255
help
256256

257-
helpclose
258257
au! BufReadCmd
259258
endfunc
260259

261260
func Test_BufReadCmdHelpJump()
262261
" This used to cause access to free memory
263262
au BufReadCmd * e +h{
264-
help
263+
" } to fix highlighting
264+
call assert_fails('help', 'E434:')
265265

266-
helpclose
267266
au! BufReadCmd
268267
endfunc
269268

src/testdir/test_bufwintabinfo.vim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
" Tests for the getbufinfo(), getwininfo() and gettabinfo() functions
22

33
function Test_getbufwintabinfo()
4-
1,$bwipeout
54
edit Xtestfile1
65
edit Xtestfile2
76
let buflist = getbufinfo()

src/testdir/test_command_count.vim

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
" Test for user command counts.
22

33
func Test_command_count_0()
4+
let bufnr = bufnr('%')
45
set hidden
56
set noswapfile
67

@@ -15,17 +16,17 @@ func Test_command_count_0()
1516
command! -range=% -addr=buffers RangeBuffersAll :let lines = [<line1>, <line2>]
1617

1718
.,$RangeLoadedBuffers
18-
call assert_equal([1, 1], lines)
19+
call assert_equal([bufnr, bufnr], lines)
1920
%RangeLoadedBuffers
20-
call assert_equal([1, 1], lines)
21+
call assert_equal([bufnr, bufnr], lines)
2122
RangeLoadedBuffersAll
22-
call assert_equal([1, 1], lines)
23+
call assert_equal([bufnr, bufnr], lines)
2324
.,$RangeBuffers
24-
call assert_equal([1, lastbuf], lines)
25+
call assert_equal([bufnr, lastbuf], lines)
2526
%RangeBuffers
26-
call assert_equal([1, lastbuf], lines)
27+
call assert_equal([bufnr, lastbuf], lines)
2728
RangeBuffersAll
28-
call assert_equal([1, lastbuf], lines)
29+
call assert_equal([bufnr, lastbuf], lines)
2930

3031
delcommand RangeLoadedBuffers
3132
delcommand RangeLoadedBuffersAll
@@ -138,14 +139,15 @@ func Test_command_count_2()
138139
endfunc
139140

140141
func Test_command_count_3()
142+
let bufnr = bufnr('%')
141143
se nohidden
142144
e aaa
143145
let buf_aaa = bufnr('%')
144146
e bbb
145147
let buf_bbb = bufnr('%')
146148
e ccc
147149
let buf_ccc = bufnr('%')
148-
buf 1
150+
exe bufnr . 'buf'
149151
call assert_equal([1, 1, 1], [buflisted(buf_aaa), buflisted(buf_bbb), buflisted(buf_ccc)])
150152
exe buf_bbb . "," . buf_ccc . "bdelete"
151153
call assert_equal([1, 0, 0], [buflisted(buf_aaa), buflisted(buf_bbb), buflisted(buf_ccc)])
@@ -155,7 +157,7 @@ endfunc
155157

156158
func Test_command_count_4()
157159
%argd
158-
let bufnr = bufnr('$') + 1
160+
let bufnr = bufnr('$')
159161
arga aa bb cc dd ee ff
160162
3argu
161163
let args = []
@@ -171,6 +173,8 @@ func Test_command_count_4()
171173
only!
172174

173175
exe bufnr . 'buf'
176+
bnext
177+
let bufnr = bufnr('%')
174178
let buffers = []
175179
.,$-bufdo call add(buffers, bufnr('%'))
176180
call assert_equal([bufnr, bufnr + 1, bufnr + 2, bufnr + 3, bufnr + 4], buffers)

src/testdir/test_hardcopy.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ endfunc
5050
" We don't check much of the contents.
5151
func Test_with_syntax()
5252
if has('postscript')
53+
edit test_hardcopy.vim
5354
set printoptions=syntax:y
5455
syn on
5556
hardcopy > Xhardcopy

src/testdir/test_ins_complete.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
" Test for insert expansion
33
func Test_ins_complete()
4+
edit test_ins_complete.vim
45
set ff=unix
56
call writefile(["test11\t36Gepeto\t/Tag/",
67
\ "asd\ttest11file\t36G",

src/testdir/test_packadd.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
func SetUp()
5-
let s:topdir = expand('%:h') . '/Xdir'
5+
let s:topdir = getcwd() . '/Xdir'
66
exe 'set packpath=' . s:topdir
77
let s:plugdir = s:topdir . '/pack/mine/opt/mytest'
88
endfunc

src/testdir/test_quickfix.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ endfunc
151151
func XageTests(cchar)
152152
call s:setup_commands(a:cchar)
153153

154-
let list = [{'bufnr': 1, 'lnum': 1}]
154+
let list = [{'bufnr': bufnr('%'), 'lnum': 1}]
155155
call g:Xsetlist(list)
156156

157157
" Jumping to a non existent list should return error

0 commit comments

Comments
 (0)