Skip to content

Commit e1f3ab7

Browse files
committed
patch 9.0.0380: deleting files in tests is a hassle
Problem: Deleting files in tests is a hassle. Solution: Use the new 'D' flag of writefile().
1 parent 8f7116c commit e1f3ab7

4 files changed

Lines changed: 46 additions & 81 deletions

File tree

src/testdir/test_arglist.vim

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ endfunc
9797
func Test_argadd_empty_curbuf()
9898
new
9999
let curbuf = bufnr('%')
100-
call writefile(['test', 'Xargadd'], 'Xargadd')
100+
call writefile(['test', 'Xargadd'], 'Xargadd', 'D')
101101
" must not re-use the current buffer.
102102
argadd Xargadd
103103
call assert_equal(curbuf, bufnr('%'))
@@ -108,7 +108,6 @@ func Test_argadd_empty_curbuf()
108108
call assert_equal('Xargadd', '%'->bufname())
109109
call assert_equal(2, line('$'))
110110

111-
call delete('Xargadd')
112111
%argd
113112
bwipe!
114113
endfunc
@@ -506,9 +505,9 @@ endfunc
506505
" Test for autocommand that redefines the argument list, when doing ":all".
507506
func Test_arglist_autocmd()
508507
autocmd BufReadPost Xxx2 next Xxx2 Xxx1
509-
call writefile(['test file Xxx1'], 'Xxx1')
510-
call writefile(['test file Xxx2'], 'Xxx2')
511-
call writefile(['test file Xxx3'], 'Xxx3')
508+
call writefile(['test file Xxx1'], 'Xxx1', 'D')
509+
call writefile(['test file Xxx2'], 'Xxx2', 'D')
510+
call writefile(['test file Xxx3'], 'Xxx3', 'D')
512511

513512
new
514513
" redefine arglist; go to Xxx1
@@ -524,18 +523,14 @@ func Test_arglist_autocmd()
524523

525524
autocmd! BufReadPost Xxx2
526525
enew! | only
527-
call delete('Xxx1')
528-
call delete('Xxx2')
529-
call delete('Xxx3')
530526
argdelete Xxx*
531527
bwipe! Xxx1 Xxx2 Xxx3
532528
endfunc
533529

534530
func Test_arg_all_expand()
535-
call writefile(['test file Xxx1'], 'Xx x')
531+
call writefile(['test file Xxx1'], 'Xx x', 'D')
536532
next notexist Xx\ x runtest.vim
537533
call assert_equal('notexist Xx\ x runtest.vim', expand('##'))
538-
call delete('Xx x')
539534
endfunc
540535

541536
func Test_large_arg()

src/testdir/test_assert.vim

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ func Test_assert_equalfile()
8989
call remove(v:errors, 0)
9090

9191
let goodtext = ["one", "two", "three"]
92-
call writefile(goodtext, 'Xone')
92+
call writefile(goodtext, 'Xone', 'D')
9393
call assert_equal(1, 'Xone'->assert_equalfile('xyzxyz'))
9494
call assert_match("E485: Can't read file xyzxyz", v:errors[0])
9595
call remove(v:errors, 0)
9696

97-
call writefile(goodtext, 'Xtwo')
97+
call writefile(goodtext, 'Xtwo', 'D')
9898
call assert_equal(0, assert_equalfile('Xone', 'Xtwo'))
9999

100100
call writefile([goodtext[0]], 'Xone')
@@ -124,9 +124,6 @@ func Test_assert_equalfile()
124124
call assert_equal(1, assert_equalfile('Xone', 'Xtwo', 'a message'))
125125
call assert_match("a message: difference at byte 234, line 1 after", v:errors[0])
126126
call remove(v:errors, 0)
127-
128-
call delete('Xone')
129-
call delete('Xtwo')
130127
endfunc
131128

132129
func Test_assert_notequal()

0 commit comments

Comments
 (0)