vim-patch:8.0.1267: Test_swap_group may leave file behind

Problem:    Test_swap_group may leave file behind.
Solution:   Add a try/finally.
5842a748be
This commit is contained in:
Jan Edmund Lazo
2019-04-29 20:59:43 -04:00
parent 3a8ebda10a
commit c3edbf813a
2 changed files with 23 additions and 20 deletions

View File

@@ -60,29 +60,31 @@ func Test_swap_group()
throw 'Skipped: need at least two groups, got ' . string(groups)
endif
call delete('Xtest')
split Xtest
call setline(1, 'just some text')
wq
if system('ls -l Xtest') !~ ' ' . groups[0] . ' \d'
throw 'Skipped: test file does not have the first group'
else
silent !chmod 640 Xtest
call system('chgrp ' . groups[1] . ' Xtest')
if system('ls -l Xtest') !~ ' ' . groups[1] . ' \d'
throw 'Skipped: cannot set second group on test file'
try
call delete('Xtest')
split Xtest
call setline(1, 'just some text')
wq
if system('ls -l Xtest') !~ ' ' . groups[0] . ' \d'
throw 'Skipped: test file does not have the first group'
else
split Xtest
let swapname = substitute(execute('swapname'), '[[:space:]]', '', 'g')
call assert_match('Xtest', swapname)
" Group of swapfile must now match original file.
call assert_match(' ' . groups[1] . ' \d', system('ls -l ' . swapname))
silent !chmod 640 Xtest
call system('chgrp ' . groups[1] . ' Xtest')
if system('ls -l Xtest') !~ ' ' . groups[1] . ' \d'
throw 'Skipped: cannot set second group on test file'
else
split Xtest
let swapname = substitute(execute('swapname'), '[[:space:]]', '', 'g')
call assert_match('Xtest', swapname)
" Group of swapfile must now match original file.
call assert_match(' ' . groups[1] . ' \d', system('ls -l ' . swapname))
bwipe!
bwipe!
endif
endif
endif
call delete('Xtest')
finally
call delete('Xtest')
endtry
endfunc
func Test_missing_dir()

View File

@@ -242,6 +242,7 @@ func Test_undojoin()
endfunc
func Test_undo_write()
call delete('Xtest')
split Xtest
call feedkeys("ione one one\<Esc>", 'xt')
w!