1
0
forked from aniani/vim

patch 9.0.0300: 'cpoptions' tests are flaky

Problem:    'cpoptions' tests are flaky.
Solution:   Use a different file name for each test.
This commit is contained in:
Bram Moolenaar 2022-08-28 17:44:20 +01:00
parent 25f1e55562
commit a85e4db978
2 changed files with 40 additions and 38 deletions

View File

@ -8,19 +8,19 @@ source view_util.vim
" file name. " file name.
func Test_cpo_a() func Test_cpo_a()
let save_cpo = &cpo let save_cpo = &cpo
call writefile(['one'], 'Xfile') call writefile(['one'], 'XfileCpoA')
" Wipe out all the buffers, so that the alternate file is empty " Wipe out all the buffers, so that the alternate file is empty
edit Xfoo | %bw edit Xfoo | %bw
set cpo-=a set cpo-=a
new new
read Xfile read XfileCpoA
call assert_equal('', @#) call assert_equal('', @#)
%d %d
set cpo+=a set cpo+=a
read Xfile read XfileCpoA
call assert_equal('Xfile', @#) call assert_equal('XfileCpoA', @#)
close! close!
call delete('Xfile') call delete('XfileCpoA')
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc
@ -99,31 +99,31 @@ endfunc
" Test for the 'C' flag in 'cpo' (line continuation) " Test for the 'C' flag in 'cpo' (line continuation)
func Test_cpo_C() func Test_cpo_C()
let save_cpo = &cpo let save_cpo = &cpo
call writefile(['let l = [', '\ 1,', '\ 2]'], 'Xfile') call writefile(['let l = [', '\ 1,', '\ 2]'], 'XfileCpoC')
set cpo-=C set cpo-=C
source Xfile source XfileCpoC
call assert_equal([1, 2], g:l) call assert_equal([1, 2], g:l)
set cpo+=C set cpo+=C
call assert_fails('source Xfile', ['E697:', 'E10:']) call assert_fails('source XfileCpoC', ['E697:', 'E10:'])
call delete('Xfile') call delete('XfileCpoC')
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc
" Test for the 'd' flag in 'cpo' (tags relative to the current file) " Test for the 'd' flag in 'cpo' (tags relative to the current file)
func Test_cpo_d() func Test_cpo_d()
let save_cpo = &cpo let save_cpo = &cpo
call mkdir('Xdir') call mkdir('XdirCpoD')
call writefile(["one\tXfile1\t/^one$/"], 'tags') call writefile(["one\tXfile1\t/^one$/"], 'tags')
call writefile(["two\tXfile2\t/^two$/"], 'Xdir/tags') call writefile(["two\tXfile2\t/^two$/"], 'XdirCpoD/tags')
set tags=./tags set tags=./tags
set cpo-=d set cpo-=d
edit Xdir/Xfile edit XdirCpoD/Xfile
call assert_equal('two', taglist('.*')[0].name) call assert_equal('two', taglist('.*')[0].name)
set cpo+=d set cpo+=d
call assert_equal('one', taglist('.*')[0].name) call assert_equal('one', taglist('.*')[0].name)
%bw! %bw!
call delete('tags') call delete('tags')
call delete('Xdir', 'rf') call delete('XdirCpoD', 'rf')
set tags& set tags&
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc
@ -204,14 +204,14 @@ func Test_cpo_F()
let save_cpo = &cpo let save_cpo = &cpo
new new
set cpo-=F set cpo-=F
write Xfile write XfileCpoF
call assert_equal('', @%) call assert_equal('', @%)
call delete('Xfile') call delete('XfileCpoF')
set cpo+=F set cpo+=F
write Xfile write XfileCpoF
call assert_equal('Xfile', @%) call assert_equal('XfileCpoF', @%)
close! close!
call delete('Xfile') call delete('XfileCpoF')
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc
@ -413,16 +413,16 @@ endfunc
" Test for the 'O' flag in 'cpo' (overwriting an existing file) " Test for the 'O' flag in 'cpo' (overwriting an existing file)
func Test_cpo_O() func Test_cpo_O()
let save_cpo = &cpo let save_cpo = &cpo
new Xfile new XfileCpoO
call setline(1, 'one') call setline(1, 'one')
call writefile(['two'], 'Xfile') call writefile(['two'], 'XfileCpoO')
set cpo-=O set cpo-=O
call assert_fails('write', 'E13:') call assert_fails('write', 'E13:')
set cpo+=O set cpo+=O
write write
call assert_equal(['one'], readfile('Xfile')) call assert_equal(['one'], readfile('XfileCpoO'))
close! close!
call delete('Xfile') call delete('XfileCpoO')
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc
@ -432,18 +432,18 @@ endfunc
" name) " name)
func Test_cpo_P() func Test_cpo_P()
let save_cpo = &cpo let save_cpo = &cpo
call writefile([], 'Xfile') call writefile([], 'XfileCpoP')
new new
call setline(1, 'one') call setline(1, 'one')
set cpo+=F set cpo+=F
set cpo-=P set cpo-=P
write >> Xfile write >> XfileCpoP
call assert_equal('', @%) call assert_equal('', @%)
set cpo+=P set cpo+=P
write >> Xfile write >> XfileCpoP
call assert_equal('Xfile', @%) call assert_equal('XfileCpoP', @%)
close! close!
call delete('Xfile') call delete('XfileCpoP')
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc
@ -635,8 +635,8 @@ endfunc
" Test for the 'Z' flag in 'cpo' (write! resets 'readonly') " Test for the 'Z' flag in 'cpo' (write! resets 'readonly')
func Test_cpo_Z() func Test_cpo_Z()
let save_cpo = &cpo let save_cpo = &cpo
call writefile([], 'Xfile') call writefile([], 'XfileCpoZ')
new Xfile new XfileCpoZ
setlocal readonly setlocal readonly
set cpo-=Z set cpo-=Z
write! write!
@ -646,7 +646,7 @@ func Test_cpo_Z()
write! write!
call assert_equal(1, &readonly) call assert_equal(1, &readonly)
close! close!
call delete('Xfile') call delete('XfileCpoZ')
let &cpo = save_cpo let &cpo = save_cpo
endfunc endfunc
@ -723,8 +723,8 @@ endfunc
" flag) " flag)
func Test_cpo_plus() func Test_cpo_plus()
let save_cpo = &cpo let save_cpo = &cpo
call writefile([], 'Xfile') call writefile([], 'XfileCpoPlus')
new Xfile new XfileCpoPlus
call setline(1, 'foo') call setline(1, 'foo')
write X1 write X1
call assert_equal(1, &modified) call assert_equal(1, &modified)
@ -732,7 +732,7 @@ func Test_cpo_plus()
write X2 write X2
call assert_equal(0, &modified) call assert_equal(0, &modified)
close! close!
call delete('Xfile') call delete('XfileCpoPlus')
call delete('X1') call delete('X1')
call delete('X2') call delete('X2')
let &cpo = save_cpo let &cpo = save_cpo
@ -835,17 +835,17 @@ endfunc
" Test for the '&' flag in 'cpo'. The swap file is kept when a buffer is still " Test for the '&' flag in 'cpo'. The swap file is kept when a buffer is still
" loaded and ':preserve' is used. " loaded and ':preserve' is used.
func Test_cpo_ampersand() func Test_cpo_ampersand()
call writefile(['one'], 'Xfile') call writefile(['one'], 'XfileCpoAmp')
let after =<< trim [CODE] let after =<< trim [CODE]
set cpo+=& set cpo+=&
preserve preserve
qall qall
[CODE] [CODE]
if RunVim([], after, 'Xfile') if RunVim([], after, 'XfileCpoAmp')
call assert_equal(1, filereadable('.Xfile.swp')) call assert_equal(1, filereadable('.XfileCpoAmp.swp'))
call delete('.Xfile.swp') call delete('.XfileCpoAmp.swp')
endif endif
call delete('Xfile') call delete('XfileCpoAmp')
endfunc endfunc
" Test for the '\' flag in 'cpo' (backslash in a [] range in a search pattern) " Test for the '\' flag in 'cpo' (backslash in a [] range in a search pattern)

View File

@ -707,6 +707,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
300,
/**/ /**/
299, 299,
/**/ /**/