]> granicus.if.org Git - vim/commitdiff
patch 8.0.1267: Test_swap_group may leave file behind v8.0.1267
authorBram Moolenaar <Bram@vim.org>
Sat, 4 Nov 2017 21:36:53 +0000 (22:36 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 4 Nov 2017 21:36:53 +0000 (22:36 +0100)
Problem:    Test_swap_group may leave file behind.
Solution:   Add a try/finally.

src/testdir/test_swap.vim
src/testdir/test_undo.vim
src/version.c

index ee11a731b1831c04d119662e91a9c2c194e0e8a8..1c4965ea5f75a7bc47a61e3ce033bdd151e2a1e7 100644 (file)
@@ -56,27 +56,29 @@ 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
index bda7a442f1e1d759d298483ee50f33edd7107643..4ea1c9b69d8a39810bd9b324635b5642f0dbe6d9 100644 (file)
@@ -190,6 +190,7 @@ func Test_undojoin_redo()
 endfunc
 
 func Test_undo_write()
+  call delete('Xtest')
   split Xtest
   call feedkeys("ione one one\<Esc>", 'xt')
   w!
index 81f5fc385f2721ac6424335e311b79478fd7bef7..0fb6952d83f36477245d0e9bfaa47efdd3302c1f 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1267,
 /**/
     1266,
 /**/