Skip to content

Commit 5842a74

Browse files
committed
patch 8.0.1267: Test_swap_group may leave file behind
Problem: Test_swap_group may leave file behind. Solution: Add a try/finally.
1 parent ffe010f commit 5842a74

3 files changed

Lines changed: 25 additions & 20 deletions

File tree

src/testdir/test_swap.vim

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,29 @@ func Test_swap_group()
5656
throw 'Skipped: need at least two groups, got ' . string(groups)
5757
endif
5858

59-
call delete('Xtest')
60-
split Xtest
61-
call setline(1, 'just some text')
62-
wq
63-
if system('ls -l Xtest') !~ ' ' . groups[0] . ' \d'
64-
throw 'Skipped: test file does not have the first group'
65-
else
66-
silent !chmod 640 Xtest
67-
call system('chgrp ' . groups[1] . ' Xtest')
68-
if system('ls -l Xtest') !~ ' ' . groups[1] . ' \d'
69-
throw 'Skipped: cannot set second group on test file'
59+
try
60+
call delete('Xtest')
61+
split Xtest
62+
call setline(1, 'just some text')
63+
wq
64+
if system('ls -l Xtest') !~ ' ' . groups[0] . ' \d'
65+
throw 'Skipped: test file does not have the first group'
7066
else
71-
split Xtest
72-
let swapname = substitute(execute('swapname'), '[[:space:]]', '', 'g')
73-
call assert_match('Xtest', swapname)
74-
" Group of swapfile must now match original file.
75-
call assert_match(' ' . groups[1] . ' \d', system('ls -l ' . swapname))
67+
silent !chmod 640 Xtest
68+
call system('chgrp ' . groups[1] . ' Xtest')
69+
if system('ls -l Xtest') !~ ' ' . groups[1] . ' \d'
70+
throw 'Skipped: cannot set second group on test file'
71+
else
72+
split Xtest
73+
let swapname = substitute(execute('swapname'), '[[:space:]]', '', 'g')
74+
call assert_match('Xtest', swapname)
75+
" Group of swapfile must now match original file.
76+
call assert_match(' ' . groups[1] . ' \d', system('ls -l ' . swapname))
7677

77-
bwipe!
78+
bwipe!
79+
endif
7880
endif
79-
endif
80-
81-
call delete('Xtest')
81+
finally
82+
call delete('Xtest')
83+
endtry
8284
endfunc

src/testdir/test_undo.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ func Test_undojoin_redo()
190190
endfunc
191191

192192
func Test_undo_write()
193+
call delete('Xtest')
193194
split Xtest
194195
call feedkeys("ione one one\<Esc>", 'xt')
195196
w!

src/version.c

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

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1267,
764766
/**/
765767
1266,
766768
/**/

0 commit comments

Comments
 (0)