Skip to content

Commit d0f8d39

Browse files
committed
patch 9.0.1005: a failed test may leave a swap file behind
Problem: A failed test may leave a swap file behind. Solution: Delete the swap file to avoid another test to fail. Use another file name.
1 parent a0a6f3a commit d0f8d39

7 files changed

Lines changed: 57 additions & 1 deletion

File tree

src/testdir/test_suspend.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ func Test_suspend()
2424

2525
call WaitForResponses()
2626

27+
" in case a previous failure left a swap file behind
28+
call delete('.Xfoo.swp')
29+
2730
let buf = term_start('/bin/sh')
2831
" Wait for shell prompt.
2932
call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))})
@@ -62,6 +65,7 @@ func Test_suspend()
6265

6366
exe buf . 'bwipe!'
6467
call delete('Xfoo')
68+
call delete('.Xfoo.swp')
6569
endfunc
6670

6771
func Test_suspend_autocmd()
@@ -70,6 +74,9 @@ func Test_suspend_autocmd()
7074

7175
call WaitForResponses()
7276

77+
" in case a previous failure left a swap file behind
78+
call delete('.Xfoo.swp')
79+
7380
let buf = term_start('/bin/sh', #{term_rows: 6})
7481
" Wait for shell prompt.
7582
call WaitForAssert({-> assert_match('[$#] $', term_getline(buf, '.'))})
@@ -108,6 +115,7 @@ func Test_suspend_autocmd()
108115

109116
exe buf . 'bwipe!'
110117
call delete('Xfoo')
118+
call delete('.Xfoo.swp')
111119
endfunc
112120

113121
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_syntax.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ func Test_invalid_name()
455455
endfunc
456456

457457
func Test_ownsyntax()
458-
new Xfoo
458+
new XfooOwnSyntax
459459
call setline(1, '#define FOO')
460460
syntax on
461461
set filetype=c

src/testdir/test_tagjump.vim

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,9 @@ endfunc
733733

734734
" Tests for guessing the tag location
735735
func Test_tag_guess()
736+
" in case a previous failure left a swap file behind
737+
call delete('.Xfoo.swp')
738+
736739
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
737740
\ "func1\tXfoo\t/^int func1(int x)/",
738741
\ "func2\tXfoo\t/^int func2(int y)/",
@@ -769,6 +772,9 @@ endfunc
769772

770773
" Test for an unsorted tags file
771774
func Test_tag_sort()
775+
" in case a previous failure left a swap file behind
776+
call delete('.Xfoo.swp')
777+
772778
let l = [
773779
\ "first\tXfoo\t1",
774780
\ "ten\tXfoo\t3",
@@ -796,6 +802,9 @@ endfunc
796802

797803
" Test for an unsorted tags file
798804
func Test_tag_fold()
805+
" in case a previous failure left a swap file behind
806+
call delete('.Xfoo.swp')
807+
799808
call writefile([
800809
\ "!_TAG_FILE_ENCODING\tutf-8\t//",
801810
\ "!_TAG_FILE_SORTED\t2\t/0=unsorted, 1=sorted, 2=foldcase/",
@@ -822,6 +831,9 @@ endfunc
822831

823832
" Test for the :ltag command
824833
func Test_ltag()
834+
" in case a previous failure left a swap file behind
835+
call delete('.Xfoo.swp')
836+
825837
call writefile([
826838
\ "!_TAG_FILE_ENCODING\tutf-8\t//",
827839
\ "first\tXfoo\t1",
@@ -859,6 +871,9 @@ endfunc
859871
" Test for setting the last search pattern to the tag search pattern
860872
" when cpoptions has 't'
861873
func Test_tag_last_search_pat()
874+
" in case a previous failure left a swap file behind
875+
call delete('.Xfoo.swp')
876+
862877
call writefile([
863878
\ "!_TAG_FILE_ENCODING\tutf-8\t//",
864879
\ "first\tXfoo\t/^int first() {}/",
@@ -887,6 +902,9 @@ endfunc
887902

888903
" Tag stack tests
889904
func Test_tag_stack()
905+
" in case a previous failure left a swap file behind
906+
call delete('.Xfoo.swp')
907+
890908
let l = []
891909
for i in range(10, 31)
892910
let l += ["var" .. i .. "\tXfoo\t/^int var" .. i .. ";$/"]
@@ -949,6 +967,9 @@ endfunc
949967

950968
" Test for browsing multiple matching tags
951969
func Test_tag_multimatch()
970+
" in case a previous failure left a swap file behind
971+
call delete('.Xfoo.swp')
972+
952973
call writefile([
953974
\ "!_TAG_FILE_ENCODING\tutf-8\t//",
954975
\ "first\tXfoo\t1",
@@ -994,6 +1015,9 @@ endfunc
9941015

9951016
" Test for previewing multiple matching tags
9961017
func Test_preview_tag_multimatch()
1018+
" in case a previous failure left a swap file behind
1019+
call delete('.Xfoo.swp')
1020+
9971021
call writefile([
9981022
\ "!_TAG_FILE_ENCODING\tutf-8\t//",
9991023
\ "first\tXfoo\t1",
@@ -1042,6 +1066,9 @@ endfunc
10421066

10431067
" Test for jumping to multiple matching tags across multiple :tags commands
10441068
func Test_tnext_multimatch()
1069+
" in case a previous failure left a swap file behind
1070+
call delete('.Xfoo.swp')
1071+
10451072
call writefile([
10461073
\ "!_TAG_FILE_ENCODING\tutf-8\t//",
10471074
\ "first\tXfoo1\t1",
@@ -1069,6 +1096,9 @@ endfunc
10691096

10701097
" Test for jumping to multiple matching tags in non-existing files
10711098
func Test_multimatch_non_existing_files()
1099+
" in case a previous failure left a swap file behind
1100+
call delete('.Xfoo.swp')
1101+
10721102
call writefile([
10731103
\ "!_TAG_FILE_ENCODING\tutf-8\t//",
10741104
\ "first\tXfoo1\t1",
@@ -1086,6 +1116,9 @@ func Test_multimatch_non_existing_files()
10861116
endfunc
10871117

10881118
func Test_tselect_listing()
1119+
" in case a previous failure left a swap file behind
1120+
call delete('.Xfoo.swp')
1121+
10891122
call writefile([
10901123
\ "!_TAG_FILE_ENCODING\tutf-8\t//",
10911124
\ "first\tXfoo\t1" .. ';"' .. "\tv\ttyperef:typename:int\tfile:",
@@ -1467,6 +1500,9 @@ endfunc
14671500

14681501
" Test for 'tagbsearch' (binary search)
14691502
func Test_tagbsearch()
1503+
" in case a previous failure left a swap file behind
1504+
call delete('.Xfoo.swp')
1505+
14701506
" If a tags file header says the tags are sorted, but the tags are actually
14711507
" unsorted, then binary search should fail and linear search should work.
14721508
call writefile([

src/testdir/test_tcl.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,9 @@ endfunc
638638

639639
" Test $buf delcmd {cmd} (command executed when buffer is deleted)
640640
func Test_buffer_delcmd()
641+
" in case a previous failure left a swap file behind
642+
call delete('.Xfoo.swp')
643+
641644
new Xfoo
642645
split
643646
tcl $::vim::current(buffer) delcmd [list set msg "buffer deleted"]

src/testdir/test_termcodes.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,9 @@ func Test_term_mouse_click_tab()
665665
set mouse=a term=xterm
666666
call WaitForResponses()
667667

668+
" in case a previous failure left a swap file behind
669+
call delete('.Xfoo.swp')
670+
668671
let row = 1
669672

670673
for ttymouse_val in g:Ttymouse_values + g:Ttymouse_dec + g:Ttymouse_netterm

src/testdir/test_window_cmd.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ endfunc
137137

138138
" Test the ":wincmd ^" and "<C-W>^" commands.
139139
func Test_window_split_edit_alternate()
140+
" in case a previous failure left a swap file behind
141+
call delete('.Xfoo.swp')
140142

141143
" Test for failure when the alternate buffer/file no longer exists.
142144
edit Xfoo | %bw
@@ -170,6 +172,8 @@ endfunc
170172

171173
" Test the ":[count]wincmd ^" and "[count]<C-W>^" commands.
172174
func Test_window_split_edit_bufnr()
175+
" in case a previous failure left a swap file behind
176+
call delete('.Xfoo.swp')
173177

174178
%bwipeout
175179
let l:nr = bufnr('%') + 1

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1005,
698700
/**/
699701
1004,
700702
/**/

0 commit comments

Comments
 (0)