vim-patch:partial:9.0.0418: manually deleting temp test files

Problem:    Manually deleting temp test files.
Solution:   Use the 'D' flag of writefile() and mkdir().

45bbaef038

This only includes test_cpoptions.vim changes.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq 2024-07-15 05:57:35 +08:00
parent 79130c0fd3
commit 7214fd8f55

View File

@ -8,7 +8,7 @@ source view_util.vim
" file name.
func Test_cpo_a()
let save_cpo = &cpo
call writefile(['one'], 'XfileCpoA')
call writefile(['one'], 'XfileCpoA', 'D')
" Wipe out all the buffers, so that the alternate file is empty
edit Xfoo | %bw
set cpo-=a
@ -20,7 +20,6 @@ func Test_cpo_a()
read XfileCpoA
call assert_equal('XfileCpoA', @#)
close!
call delete('XfileCpoA')
let &cpo = save_cpo
endfunc
@ -104,21 +103,20 @@ endfunc
" Test for the 'C' flag in 'cpo' (line continuation)
func Test_cpo_C()
let save_cpo = &cpo
call writefile(['let l = [', '\ 1,', '\ 2]'], 'XfileCpoC')
call writefile(['let l = [', '\ 1,', '\ 2]'], 'XfileCpoC', 'D')
set cpo-=C
source XfileCpoC
call assert_equal([1, 2], g:l)
set cpo+=C
call assert_fails('source XfileCpoC', ['E697:', 'E10:'])
call delete('XfileCpoC')
let &cpo = save_cpo
endfunc
" Test for the 'd' flag in 'cpo' (tags relative to the current file)
func Test_cpo_d()
let save_cpo = &cpo
call mkdir('XdirCpoD')
call writefile(["one\tXfile1\t/^one$/"], 'tags')
call mkdir('XdirCpoD', 'R')
call writefile(["one\tXfile1\t/^one$/"], 'tags', 'D')
call writefile(["two\tXfile2\t/^two$/"], 'XdirCpoD/tags')
set tags=./tags
set cpo-=d
@ -126,9 +124,8 @@ func Test_cpo_d()
call assert_equal('two', taglist('.*')[0].name)
set cpo+=d
call assert_equal('one', taglist('.*')[0].name)
%bw!
call delete('tags')
call delete('XdirCpoD', 'rf')
set tags&
let &cpo = save_cpo
endfunc
@ -423,14 +420,13 @@ func Test_cpo_O()
let save_cpo = &cpo
new XfileCpoO
call setline(1, 'one')
call writefile(['two'], 'XfileCpoO')
call writefile(['two'], 'XfileCpoO', 'D')
set cpo-=O
call assert_fails('write', 'E13:')
set cpo+=O
write
call assert_equal(['one'], readfile('XfileCpoO'))
close!
call delete('XfileCpoO')
let &cpo = save_cpo
endfunc
@ -440,7 +436,7 @@ endfunc
" name)
func Test_cpo_P()
let save_cpo = &cpo
call writefile([], 'XfileCpoP')
call writefile([], 'XfileCpoP', 'D')
new
call setline(1, 'one')
set cpo+=F
@ -452,7 +448,6 @@ func Test_cpo_P()
call assert_equal('XfileCpoP', @%)
bwipe!
call delete('XfileCpoP')
let &cpo = save_cpo
endfunc
@ -645,7 +640,7 @@ endfunc
" Test for the 'Z' flag in 'cpo' (write! resets 'readonly')
func Test_cpo_Z()
let save_cpo = &cpo
call writefile([], 'XfileCpoZ')
call writefile([], 'XfileCpoZ', 'D')
new XfileCpoZ
setlocal readonly
set cpo-=Z
@ -656,7 +651,6 @@ func Test_cpo_Z()
write!
call assert_equal(1, &readonly)
close!
call delete('XfileCpoZ')
let &cpo = save_cpo
endfunc
@ -735,7 +729,7 @@ endfunc
" flag)
func Test_cpo_plus()
let save_cpo = &cpo
call writefile([], 'XfileCpoPlus')
call writefile([], 'XfileCpoPlus', 'D')
new XfileCpoPlus
call setline(1, 'foo')
write X1
@ -744,7 +738,6 @@ func Test_cpo_plus()
write X2
call assert_equal(0, &modified)
close!
call delete('XfileCpoPlus')
call delete('X1')
call delete('X2')
let &cpo = save_cpo
@ -850,7 +843,7 @@ endfunc
" loaded and ':preserve' is used.
func Test_cpo_ampersand()
throw 'Skipped: Nvim does not support cpoptions flag "&"'
call writefile(['one'], 'XfileCpoAmp')
call writefile(['one'], 'XfileCpoAmp', 'D')
let after =<< trim [CODE]
set cpo+=&
preserve
@ -860,7 +853,6 @@ func Test_cpo_ampersand()
call assert_equal(1, filereadable('.XfileCpoAmp.swp'))
call delete('.XfileCpoAmp.swp')
endif
call delete('XfileCpoAmp')
endfunc
" Test for the '\' flag in 'cpo' (backslash in a [] range in a search pattern)