• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisionf08ed0738f7a5e529b282e390aada295ea9cf5ae (tree)
Time2022-09-30 05:15:04
AuthorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 9.0.0625: too many delete() calls in tests

Commit: https://github.com/vim/vim/commit/7dd5a78b88af7734bdbf236fdfafb49f27a0ca2e
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 29 21:01:57 2022 +0100

patch 9.0.0625: too many delete() calls in tests
Problem: Too many delete() calls in tests.
Solution: Use deferred delete where possible.

Change Summary

Incremental Difference

diff -r e298ce7862f7 -r f08ed0738f7a src/testdir/test_iminsert.vim
--- a/src/testdir/test_iminsert.vim Thu Sep 29 21:30:04 2022 +0200
+++ b/src/testdir/test_iminsert.vim Thu Sep 29 22:15:04 2022 +0200
@@ -79,7 +79,7 @@
7979 call setline(1, ['{{{', 'abc', '}}}'])
8080 %foldclose
8181 END
82- call writefile(lines, 'Xscript')
82+ call writefile(lines, 'Xscript', 'D')
8383 let buf = RunVimInTerminal('-S Xscript', {})
8484 call assert_notequal('abc', term_getline(buf, 2))
8585 call term_sendkeys(buf, "/abc\n")
@@ -87,7 +87,6 @@
8787
8888 " clean up
8989 call StopVimInTerminal(buf)
90- call delete('Xscript')
9190 endfunc
9291
9392 " Test for using an lmap in insert mode
diff -r e298ce7862f7 -r f08ed0738f7a src/testdir/test_indent.vim
--- a/src/testdir/test_indent.vim Thu Sep 29 21:30:04 2022 +0200
+++ b/src/testdir/test_indent.vim Thu Sep 29 22:15:04 2022 +0200
@@ -161,7 +161,7 @@
161161 func GetIndent()
162162 return line('.') * 2
163163 endfunc
164- call writefile(['# vim: indentexpr=GetIndent()'], 'Xmlfile.txt')
164+ call writefile(['# vim: indentexpr=GetIndent()'], 'Xmlfile.txt', 'D')
165165 set modelineexpr
166166 new Xmlfile.txt
167167 call assert_equal('GetIndent()', &indentexpr)
@@ -172,7 +172,6 @@
172172 delfunc GetIndent
173173 let &modeline = modeline
174174 close!
175- call delete('Xmlfile.txt')
176175 endfunc
177176
178177 func Test_indent_func_with_gq()
diff -r e298ce7862f7 -r f08ed0738f7a src/testdir/test_ins_complete.vim
--- a/src/testdir/test_ins_complete.vim Thu Sep 29 21:30:04 2022 +0200
+++ b/src/testdir/test_ins_complete.vim Thu Sep 29 22:15:04 2022 +0200
@@ -15,14 +15,14 @@
1515 set ff=unix
1616 call writefile(["test11\t36Gepeto\t/Tag/",
1717 \ "asd\ttest11file\t36G",
18- \ "Makefile\tto\trun"], 'Xtestfile')
18+ \ "Makefile\tto\trun"], 'Xtestfile', 'D')
1919 call writefile(['', 'start of testfile',
2020 \ 'ru',
2121 \ 'run1',
2222 \ 'run2',
2323 \ 'STARTTEST',
2424 \ 'ENDTEST',
25- \ 'end of testfile'], 'Xtestdata')
25+ \ 'end of testfile'], 'Xtestdata', 'D')
2626 set ff&
2727
2828 enew!
@@ -99,10 +99,8 @@
9999 call assert_equal('asd', getline('.'))
100100
101101 %bw!
102- call delete('Xtestfile')
103102 call delete('Xtest11.one')
104103 call delete('Xtest11.two')
105- call delete('Xtestdata')
106104 set cpt& cot& def& tags& tagbsearch& hidden&
107105 cd ..
108106 call delete('Xcpldir', 'rf')
@@ -111,13 +109,11 @@
111109 func Test_ins_complete_invalid_byte()
112110 if has('unix') && executable('base64')
113111 " this weird command was causing an illegal memory access
114- call writefile(['bm9ybTlvMDCAMM4Dbw4OGA4ODg=='], 'Xinvalid64')
112+ call writefile(['bm9ybTlvMDCAMM4Dbw4OGA4ODg=='], 'Xinvalid64', 'D')
115113 call system('base64 -d Xinvalid64 > Xinvalid')
116- call writefile(['qa!'], 'Xexit')
114+ call writefile(['qa!'], 'Xexit', 'D')
117115 call RunVim([], [], " -i NONE -n -X -Z -e -m -s -S Xinvalid -S Xexit")
118- call delete('Xinvalid64')
119116 call delete('Xinvalid')
120- call delete('Xexit')
121117 endif
122118 endfunc
123119
@@ -168,7 +164,7 @@
168164 let save_rtp = &rtp
169165 set rtp=Xruntime/some
170166 let dir = 'Xruntime/some/autoload'
171- call mkdir(dir, 'p')
167+ call mkdir(dir, 'pR')
172168
173169 let lines =<< trim END
174170 vim9script
@@ -190,7 +186,6 @@
190186 call feedkeys("i\<C-X>\<C-O>\<Esc>", 'xt')
191187
192188 bwipe!
193- call delete('Xruntime', 'rf')
194189 set omnifunc=
195190 let &rtp = save_rtp
196191 endfunc
@@ -433,7 +428,7 @@
433428 func Test_ins_completeslash()
434429 CheckMSWindows
435430
436- call mkdir('Xcpldir')
431+ call mkdir('Xcpldir', 'R')
437432 let orig_shellslash = &shellslash
438433 set cpt&
439434 new
@@ -466,7 +461,6 @@
466461 exe "normal oXcp\<C-X>\<C-F>"
467462 call assert_equal('Xcpldir/', getline('.'))
468463 %bw!
469- call delete('Xcpldir', 'rf')
470464
471465 set noshellslash
472466 set completeslash=slash
@@ -487,7 +481,7 @@
487481 endfunc
488482 END
489483
490- call writefile(lines, 'Xpumscript')
484+ call writefile(lines, 'Xpumscript', 'D')
491485 let buf = RunVimInTerminal('-S Xpumscript', #{rows: 12})
492486 call term_sendkeys(buf, ":call StartCompl()\<CR>")
493487 call TermWait(buf, 200)
@@ -495,7 +489,6 @@
495489 call VerifyScreenDump(buf, 'Test_pum_stopped_by_timer', {})
496490
497491 call StopVimInTerminal(buf)
498- call delete('Xpumscript')
499492 endfunc
500493
501494 func Test_complete_stopinsert_startinsert()
@@ -520,7 +513,7 @@
520513 call feedkeys("0fa", 'xt')
521514 END
522515
523- call writefile(lines, 'Xpumscript')
516+ call writefile(lines, 'Xpumscript', 'D')
524517 let buf = RunVimInTerminal('-S Xpumscript', #{rows: 10})
525518 call TermWait(buf, 50)
526519 call term_sendkeys(buf, "a\<C-N>")
@@ -528,7 +521,6 @@
528521
529522 call term_sendkeys(buf, "\<Esc>")
530523 call StopVimInTerminal(buf)
531- call delete('Xpumscript')
532524 endfunc
533525
534526 func Test_pum_with_preview_win()
@@ -545,7 +537,7 @@
545537 set completeopt+=longest
546538 END
547539
548- call writefile(lines, 'Xpreviewscript')
540+ call writefile(lines, 'Xpreviewscript', 'D')
549541 let buf = RunVimInTerminal('-S Xpreviewscript', #{rows: 12})
550542 call term_sendkeys(buf, "Gi\<C-X>\<C-O>")
551543 call TermWait(buf, 200)
@@ -554,7 +546,6 @@
554546
555547 call term_sendkeys(buf, "\<Esc>")
556548 call StopVimInTerminal(buf)
557- call delete('Xpreviewscript')
558549 endfunc
559550
560551 func Test_scrollbar_on_wide_char()
@@ -566,13 +557,12 @@
566557 \ ' 呃呃呃'])
567558 call setline(5, range(10)->map({i, v -> 'aa' .. v .. 'bb'}))
568559 END
569- call writefile(lines, 'Xwidescript')
560+ call writefile(lines, 'Xwidescript', 'D')
570561 let buf = RunVimInTerminal('-S Xwidescript', #{rows: 10})
571562 call term_sendkeys(buf, "A\<C-N>")
572563 call VerifyScreenDump(buf, 'Test_scrollbar_on_wide_char', {})
573564
574565 call StopVimInTerminal(buf)
575- call delete('Xwidescript')
576566 endfunc
577567
578568 " Test for inserting the tag search pattern in insert mode
@@ -582,14 +572,14 @@
582572 \ "first\tXfoo\t/^int first() {}$/",
583573 \ "second\tXfoo\t/^int second() {}$/",
584574 \ "third\tXfoo\t/^int third() {}$/"],
585- \ 'Xtags')
575+ \ 'Xtags', 'D')
586576 set tags=Xtags
587577 let code =<< trim [CODE]
588578 int first() {}
589579 int second() {}
590580 int third() {}
591581 [CODE]
592- call writefile(code, 'Xfoo')
582+ call writefile(code, 'Xfoo', 'D')
593583
594584 enew
595585 set showfulltag
@@ -597,8 +587,6 @@
597587 call assert_equal('int second() {}', getline(1))
598588 set noshowfulltag
599589
600- call delete('Xtags')
601- call delete('Xfoo')
602590 set tags&
603591 %bwipe!
604592 endfunc
@@ -978,8 +966,8 @@
978966
979967 " Test for completing words from unloaded buffers
980968 func Test_complete_from_unloadedbuf()
981- call writefile(['abc'], "Xfile1")
982- call writefile(['def'], "Xfile2")
969+ call writefile(['abc'], "Xfile1", 'D')
970+ call writefile(['def'], "Xfile2", 'D')
983971 edit Xfile1
984972 edit Xfile2
985973 new | close
@@ -991,15 +979,14 @@
991979 call assert_equal('abc', getline(1))
992980 exe "normal! od\<C-P>"
993981 call assert_equal('def', getline(2))
982+
994983 set complete&
995984 %bw!
996- call delete("Xfile1")
997- call delete("Xfile2")
998985 endfunc
999986
1000987 " Test for completing whole lines from unloaded buffers
1001988 func Test_complete_wholeline_unloadedbuf()
1002- call writefile(['a line1', 'a line2', 'a line3'], "Xfile1")
989+ call writefile(['a line1', 'a line2', 'a line3'], "Xfile1", 'D')
1003990 edit Xfile1
1004991 enew
1005992 set complete=u
@@ -1010,15 +997,15 @@
1010997 bdel Xfile1
1011998 exe "normal! ia\<C-X>\<C-L>\<C-P>"
1012999 call assert_equal('a', getline(1))
1000+
10131001 set complete&
10141002 %bw!
1015- call delete("Xfile1")
10161003 endfunc
10171004
10181005 " Test for completing words from unlisted buffers
10191006 func Test_complete_from_unlistedbuf()
1020- call writefile(['abc'], "Xfile1")
1021- call writefile(['def'], "Xfile2")
1007+ call writefile(['abc'], "Xfile1", 'D')
1008+ call writefile(['def'], "Xfile2", 'D')
10221009 edit Xfile1
10231010 edit Xfile2
10241011 new | close
@@ -1029,15 +1016,14 @@
10291016 call assert_equal('abc', getline(1))
10301017 exe "normal! od\<C-P>"
10311018 call assert_equal('def', getline(2))
1019+
10321020 set complete&
10331021 %bw!
1034- call delete("Xfile1")
1035- call delete("Xfile2")
10361022 endfunc
10371023
10381024 " Test for completing whole lines from unlisted buffers
10391025 func Test_complete_wholeline_unlistedbuf()
1040- call writefile(['a line1', 'a line2', 'a line3'], "Xfile1")
1026+ call writefile(['a line1', 'a line2', 'a line3'], "Xfile1", 'D')
10411027 edit Xfile1
10421028 enew
10431029 set complete=U
@@ -1048,9 +1034,9 @@
10481034 bdel Xfile1
10491035 exe "normal! ia\<C-X>\<C-L>\<C-P>"
10501036 call assert_equal('a line2', getline(1))
1037+
10511038 set complete&
10521039 %bw!
1053- call delete("Xfile1")
10541040 endfunc
10551041
10561042 " Test for adding a multibyte character using CTRL-L in completion mode
@@ -1246,14 +1232,14 @@
12461232 CheckUnix
12471233 CheckNotRoot
12481234
1249- call writefile(['about', 'above'], 'Xunrfile')
1235+ call writefile(['about', 'above'], 'Xunrfile', 'D')
12501236 call setfperm('Xunrfile', '---r--r--')
12511237 new
12521238 set complete=sXfile
12531239 exe "normal! ia\<C-P>"
12541240 call assert_equal('a', getline(1))
1241+
12551242 bw!
1256- call delete('Xunrfile')
12571243 set complete&
12581244 endfunc
12591245
diff -r e298ce7862f7 -r f08ed0738f7a src/testdir/test_jumplist.vim
--- a/src/testdir/test_jumplist.vim Thu Sep 29 21:30:04 2022 +0200
+++ b/src/testdir/test_jumplist.vim Thu Sep 29 22:15:04 2022 +0200
@@ -15,7 +15,7 @@
1515 for i in range(1, 100)
1616 call add(lines, "Line " . i)
1717 endfor
18- call writefile(lines, "Xtest")
18+ call writefile(lines, "Xtest", 'D')
1919
2020 " Jump around and create a jump list
2121 edit Xtest
@@ -57,8 +57,6 @@
5757 clearjumps
5858 call test_garbagecollect_now()
5959 call assert_equal(4, l[1])
60-
61- call delete("Xtest")
6260 endfunc
6361
6462 func Test_jumplist_invalid()
diff -r e298ce7862f7 -r f08ed0738f7a src/testdir/test_lambda.vim
--- a/src/testdir/test_lambda.vim Thu Sep 29 21:30:04 2022 +0200
+++ b/src/testdir/test_lambda.vim Thu Sep 29 22:15:04 2022 +0200
@@ -354,7 +354,7 @@
354354 return 1
355355 endfunc
356356 END
357- call writefile(l, 'Xscript')
357+ call writefile(l, 'Xscript', 'D')
358358 let caught_932 = 0
359359 try
360360 source Xscript
@@ -362,7 +362,6 @@
362362 let caught_932 = 1
363363 endtry
364364 call assert_equal(1, caught_932)
365- call delete('Xscript')
366365 endfunc
367366
368367 " vim: shiftwidth=2 sts=2 expandtab
diff -r e298ce7862f7 -r f08ed0738f7a src/testdir/test_let.vim
--- a/src/testdir/test_let.vim Thu Sep 29 21:30:04 2022 +0200
+++ b/src/testdir/test_let.vim Thu Sep 29 22:15:04 2022 +0200
@@ -344,36 +344,31 @@
344344 let v =<< that there
345345 endfunc
346346 END
347- call writefile(text, 'XheredocFail')
347+ call writefile(text, 'XheredocFail', 'D')
348348 call assert_fails('source XheredocFail', 'E1145:')
349- call delete('XheredocFail')
350349
351350 let text =<< trim CodeEnd
352351 func MissingEnd()
353352 let v =<< END
354353 endfunc
355354 CodeEnd
356- call writefile(text, 'XheredocWrong')
355+ call writefile(text, 'XheredocWrong', 'D')
357356 call assert_fails('source XheredocWrong', 'E1145:')
358- call delete('XheredocWrong')
359357
360358 let text =<< trim TEXTend
361359 let v =<< " comment
362360 TEXTend
363- call writefile(text, 'XheredocNoMarker')
361+ call writefile(text, 'XheredocNoMarker', 'D')
364362 call assert_fails('source XheredocNoMarker', 'E172:')
365- call delete('XheredocNoMarker')
366363
367364 let text =<< trim TEXTend
368365 let v =<< text
369366 TEXTend
370- call writefile(text, 'XheredocBadMarker')
367+ call writefile(text, 'XheredocBadMarker', 'D')
371368 call assert_fails('source XheredocBadMarker', 'E221:')
372- call delete('XheredocBadMarker')
373369
374- call writefile(['let v =<< TEXT', 'abc'], 'XheredocMissingMarker')
370+ call writefile(['let v =<< TEXT', 'abc'], 'XheredocMissingMarker', 'D')
375371 call assert_fails('source XheredocMissingMarker', 'E990:')
376- call delete('XheredocMissingMarker')
377372 endfunc
378373
379374 func Test_let_heredoc_trim_no_indent_marker()
diff -r e298ce7862f7 -r f08ed0738f7a src/testdir/test_listchars.vim
--- a/src/testdir/test_listchars.vim Thu Sep 29 21:30:04 2022 +0200
+++ b/src/testdir/test_listchars.vim Thu Sep 29 22:15:04 2022 +0200
@@ -664,7 +664,7 @@
664664 vsplit
665665 windo set signcolumn=yes foldcolumn=1 winminwidth=0 nowrap list listchars=extends:>,precedes:<
666666 END
667- call writefile(lines, 'XTest_listchars')
667+ call writefile(lines, 'XTest_listchars', 'D')
668668
669669 let buf = RunVimInTerminal('-S XTest_listchars', {'rows': 10, 'cols': 60})
670670
@@ -687,7 +687,6 @@
687687
688688 " clean up
689689 call StopVimInTerminal(buf)
690- call delete('XTest_listchars')
691690 endfunc
692691
693692
diff -r e298ce7862f7 -r f08ed0738f7a src/testdir/test_lua.vim
--- a/src/testdir/test_lua.vim Thu Sep 29 21:30:04 2022 +0200
+++ b/src/testdir/test_lua.vim Thu Sep 29 22:15:04 2022 +0200
@@ -817,8 +817,7 @@
817817
818818 " Test :luafile foo.lua
819819 func Test_luafile()
820- call delete('Xlua_file')
821- call writefile(["str = 'hello'", "num = 123" ], 'Xlua_file')
820+ call writefile(["str = 'hello'", "num = 123" ], 'Xlua_file', 'D')
822821 call setfperm('Xlua_file', 'r-xr-xr-x')
823822
824823 luafile Xlua_file
@@ -826,7 +825,6 @@
826825 call assert_equal(123, luaeval('num'))
827826
828827 lua str, num = nil
829- call delete('Xlua_file')
830828 endfunc
831829
832830 " Test :luafile %
@@ -849,12 +847,11 @@
849847 " Test :luafile with syntax error
850848 func Test_luafile_error()
851849 new Xlua_file
852- call writefile(['nil = 0' ], 'Xlua_file')
850+ call writefile(['nil = 0' ], 'Xlua_file', 'D')
853851 call setfperm('Xlua_file', 'r-xr-xr-x')
854852
855853 call assert_fails('luafile Xlua_file', "Xlua_file:1: unexpected symbol near 'nil'")
856854
857- call delete('Xlua_file')
858855 bwipe!
859856 endfunc
860857
diff -r e298ce7862f7 -r f08ed0738f7a src/testdir/test_popup.vim
--- a/src/testdir/test_popup.vim Thu Sep 29 21:30:04 2022 +0200
+++ b/src/testdir/test_popup.vim Thu Sep 29 22:15:04 2022 +0200
@@ -758,7 +758,7 @@
758758 call setline(1, map(repeat(["ab"], 10), "v:val .. v:key"))
759759 exec "norm! G\<C-E>\<C-E>"
760760 END
761- call writefile(lines, 'Xscript')
761+ call writefile(lines, 'Xscript', 'D')
762762 let buf = RunVimInTerminal('-S Xscript', {})
763763
764764 " wait for the script to finish
@@ -772,7 +772,6 @@
772772
773773 call term_sendkeys(buf, "\<Esc>u")
774774 call StopVimInTerminal(buf)
775- call delete('Xscript')
776775 endfunc
777776
778777 func Test_balloon_split()
@@ -829,7 +828,7 @@
829828 123456789_123456789_123456789_b
830829 123
831830 END
832- call writefile(lines, 'Xtest')
831+ call writefile(lines, 'Xtest', 'D')
833832 let buf = RunVimInTerminal('Xtest', {})
834833 call term_sendkeys(buf, ":vsplit\<CR>")
835834
@@ -860,7 +859,6 @@
860859
861860 call term_sendkeys(buf, "\<Esc>u")
862861 call StopVimInTerminal(buf)
863- call delete('Xtest')
864862 endfunc
865863
866864 func Test_popup_command()
@@ -883,14 +881,14 @@
883881 echomsg 'changed'
884882 endfunc
885883 END
886- call writefile(script, 'XtimerScript')
884+ call writefile(script, 'XtimerScript', 'D')
887885
888886 let lines =<< trim END
889887 one two three four five
890888 and one two Xthree four five
891889 one more two three four five
892890 END
893- call writefile(lines, 'Xtest')
891+ call writefile(lines, 'Xtest', 'D')
894892 let buf = RunVimInTerminal('-S XtimerScript Xtest', {})
895893 call term_sendkeys(buf, ":source $VIMRUNTIME/menu.vim\<CR>")
896894 call term_sendkeys(buf, "/X\<CR>:popup PopUp\<CR>")
@@ -917,8 +915,6 @@
917915 call VerifyScreenDump(buf, 'Test_popup_command_05', {})
918916
919917 call StopVimInTerminal(buf)
920- call delete('Xtest')
921- call delete('XtimerScript')
922918 endfunc
923919
924920 func Test_popup_complete_backwards()
@@ -1013,7 +1009,7 @@
10131009 inoremap <buffer><F6> <C-R>=s:complTestEval()<CR>
10141010 call writefile([
10151011 \ 'dummy dummy.txt 1',
1016- \], 'Xdummy.txt')
1012+ \], 'Xdummy.txt', 'D')
10171013 setlocal tags=Xdummy.txt
10181014 setlocal dictionary=Xdummy.txt
10191015 setlocal thesaurus=Xdummy.txt
@@ -1046,7 +1042,7 @@
10461042 call assert_equal(mode_name, getline('.'))
10471043 %d
10481044 endfor
1049- call delete('Xdummy.txt')
1045+
10501046 bwipe!
10511047 endfunc
10521048
@@ -1194,7 +1190,7 @@
11941190 vim
11951191 victory
11961192 END
1197- call writefile(lines, 'Xtest1')
1193+ call writefile(lines, 'Xtest1', 'D')
11981194 let buf = RunVimInTerminal('--cmd "set rightleft" Xtest1', {})
11991195 call term_sendkeys(buf, "Go\<C-P>")
12001196 call VerifyScreenDump(buf, 'Test_pum_rightleft_01', {'rows': 8})
@@ -1209,7 +1205,7 @@
12091205 one three
12101206 four
12111207 END
1212- call writefile(lines, 'Xtest2')
1208+ call writefile(lines, 'Xtest2', 'D')
12131209 call term_sendkeys(buf, "\<Esc>:e! Xtest2\<CR>")
12141210 call TermWait(buf, 30)
12151211 call term_sendkeys(buf, "Goone\<C-X>\<C-L>")
@@ -1222,8 +1218,6 @@
12221218 call WaitForAssert({-> assert_match('\s*eerht eno', Screenline(4))})
12231219
12241220 call StopVimInTerminal(buf)
1225- call delete('Xtest1')
1226- call delete('Xtest2')
12271221 endfunc
12281222
12291223 " Test for a popup menu with a scrollbar
@@ -1234,7 +1228,7 @@
12341228 two
12351229 three
12361230 END
1237- call writefile(lines, 'Xtest1')
1231+ call writefile(lines, 'Xtest1', 'D')
12381232 let buf = RunVimInTerminal('--cmd "set pumheight=2" Xtest1', {})
12391233 call TermWait(buf)
12401234 call term_sendkeys(buf, "Go\<C-P>\<C-P>\<C-P>")
@@ -1250,7 +1244,6 @@
12501244 endif
12511245
12521246 call StopVimInTerminal(buf)
1253- call delete('Xtest1')
12541247 endfunc
12551248
12561249 " vim: shiftwidth=2 sts=2 expandtab
diff -r e298ce7862f7 -r f08ed0738f7a src/version.c
--- a/src/version.c Thu Sep 29 21:30:04 2022 +0200
+++ b/src/version.c Thu Sep 29 22:15:04 2022 +0200
@@ -700,6 +700,8 @@
700700 static int included_patches[] =
701701 { /* Add new patch number below this line */
702702 /**/
703+ 625,
704+/**/
703705 624,
704706 /**/
705707 623,
Show on old repository browser