changeset 12692:03a6aeea2096 v8.0.1224

patch 8.0.1224: still interference between test functions commit https://github.com/vim/vim/commit/cf1ba35fc2ebd41b9a7738bbd1f026f5311560aa Author: Bram Moolenaar <Bram@vim.org> Date: Fri Oct 27 00:55:04 2017 +0200 patch 8.0.1224: still interference between test functions Problem: Still interference between test functions. Solution: Clear autocommands. Wipe all buffers. Fix tests that depend on a specific start context.
author Christian Brabandt <cb@256bit.org>
date Fri, 27 Oct 2017 01:00:05 +0200
parents ec5a749db3fa
children 78f24b9d1ceb
files src/testdir/runtest.vim src/testdir/test_arglist.vim src/testdir/test_autochdir.vim src/testdir/test_autocmd.vim src/testdir/test_bufwintabinfo.vim src/testdir/test_command_count.vim src/testdir/test_hardcopy.vim src/testdir/test_ins_complete.vim src/testdir/test_packadd.vim src/testdir/test_quickfix.vim src/testdir/test_signs.vim src/version.c
diffstat 12 files changed, 32 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/runtest.vim
+++ b/src/testdir/runtest.vim
@@ -99,6 +99,10 @@ func RunTheTest(test)
   " Clear any overrides.
   call test_override('ALL', 0)
 
+  " Some tests wipe out buffers.  To be consistent, always wipe out all
+  " buffers.
+  %bwipe!
+
   if exists("*SetUp")
     try
       call SetUp()
@@ -133,9 +137,12 @@ func RunTheTest(test)
     endtry
   endif
 
+  " Clear any autocommands
+  au!
+
   " Close any extra tab pages and windows and make the current one not modified.
   while tabpagenr('$') > 1
-    bwipe!
+    quit!
   endwhile
 
   while 1
@@ -150,15 +157,6 @@ func RunTheTest(test)
       break
     endif
   endwhile
-
-  " Wipe out all buffers except the current one, then wipe the current one.
-  for nr in range(1, bufnr('$'))
-    if nr != bufnr('%') && bufexists(nr)
-      exe nr . 'bwipe!'
-    endif
-  endfor
-  set nomodified
-  bwipe
 endfunc
 
 func AfterTheTest()
--- a/src/testdir/test_arglist.vim
+++ b/src/testdir/test_arglist.vim
@@ -253,10 +253,7 @@ func Test_argedit()
   call assert_equal(['a', 'b', 'a'], argv())
   call assert_equal('a', expand('%:t'))
   " When file name case is ignored, an existing buffer with only case
-  " difference is re-used.  Make sure they don't exist so the case is
-  " preserved.
-  bwipe! c
-  bwipe! d
+  " difference is re-used.
   argedit C D
   call assert_equal('C', expand('%:t'))
   call assert_equal(['a', 'b', 'a', 'C', 'D'], argv())
--- a/src/testdir/test_autochdir.vim
+++ b/src/testdir/test_autochdir.vim
@@ -5,6 +5,7 @@ if !exists("+autochdir")
 endif
 
 func Test_set_filename()
+  let cwd = getcwd()
   call test_autochdir()
   set acd
   new
@@ -13,5 +14,6 @@ func Test_set_filename()
   call assert_equal("samples", substitute(getcwd(), '.*/\(\k*\)', '\1', ''))
   bwipe!
   set noacd
+  exe 'cd ' . cwd
   call delete('samples/Xtest')
 endfunc
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -254,16 +254,15 @@ func Test_BufReadCmdHelp()
   au BufReadCmd * e +h
   help
 
-  helpclose
   au! BufReadCmd
 endfunc
 
 func Test_BufReadCmdHelpJump()
   " This used to cause access to free memory
   au BufReadCmd * e +h{
-  help
+  " } to fix highlighting
+  call assert_fails('help', 'E434:')
 
-  helpclose
   au! BufReadCmd
 endfunc
 
--- a/src/testdir/test_bufwintabinfo.vim
+++ b/src/testdir/test_bufwintabinfo.vim
@@ -1,7 +1,6 @@
 " Tests for the getbufinfo(), getwininfo() and gettabinfo() functions
 
 function Test_getbufwintabinfo()
-    1,$bwipeout
     edit Xtestfile1
     edit Xtestfile2
     let buflist = getbufinfo()
--- a/src/testdir/test_command_count.vim
+++ b/src/testdir/test_command_count.vim
@@ -1,6 +1,7 @@
 " Test for user command counts.
 
 func Test_command_count_0()
+  let bufnr = bufnr('%')
   set hidden
   set noswapfile
 
@@ -15,17 +16,17 @@ func Test_command_count_0()
   command! -range=% -addr=buffers RangeBuffersAll :let lines = [<line1>, <line2>]
 
   .,$RangeLoadedBuffers
-  call assert_equal([1, 1], lines)
+  call assert_equal([bufnr, bufnr], lines)
   %RangeLoadedBuffers
-  call assert_equal([1, 1], lines)
+  call assert_equal([bufnr, bufnr], lines)
   RangeLoadedBuffersAll
-  call assert_equal([1, 1], lines)
+  call assert_equal([bufnr, bufnr], lines)
   .,$RangeBuffers
-  call assert_equal([1, lastbuf], lines)
+  call assert_equal([bufnr, lastbuf], lines)
   %RangeBuffers
-  call assert_equal([1, lastbuf], lines)
+  call assert_equal([bufnr, lastbuf], lines)
   RangeBuffersAll
-  call assert_equal([1, lastbuf], lines)
+  call assert_equal([bufnr, lastbuf], lines)
 
   delcommand RangeLoadedBuffers
   delcommand RangeLoadedBuffersAll
@@ -138,6 +139,7 @@ func Test_command_count_2()
 endfunc
 
 func Test_command_count_3()
+  let bufnr = bufnr('%')
   se nohidden
   e aaa
   let buf_aaa = bufnr('%')
@@ -145,7 +147,7 @@ func Test_command_count_3()
   let buf_bbb = bufnr('%')
   e ccc
   let buf_ccc = bufnr('%')
-  buf 1
+  exe bufnr . 'buf'
   call assert_equal([1, 1, 1], [buflisted(buf_aaa), buflisted(buf_bbb), buflisted(buf_ccc)])
   exe buf_bbb . "," . buf_ccc . "bdelete"
   call assert_equal([1, 0, 0], [buflisted(buf_aaa), buflisted(buf_bbb), buflisted(buf_ccc)])
@@ -155,7 +157,7 @@ endfunc
 
 func Test_command_count_4()
   %argd
-  let bufnr = bufnr('$') + 1
+  let bufnr = bufnr('$')
   arga aa bb cc dd ee ff
   3argu
   let args = []
@@ -171,6 +173,8 @@ func Test_command_count_4()
   only!
 
   exe bufnr . 'buf'
+  bnext
+  let bufnr = bufnr('%')
   let buffers = []
   .,$-bufdo call add(buffers, bufnr('%'))
   call assert_equal([bufnr, bufnr + 1, bufnr + 2, bufnr + 3, bufnr + 4], buffers)
--- a/src/testdir/test_hardcopy.vim
+++ b/src/testdir/test_hardcopy.vim
@@ -50,6 +50,7 @@ endfunc
 " We don't check much of the contents.
 func Test_with_syntax()
   if has('postscript')
+    edit test_hardcopy.vim
     set printoptions=syntax:y
     syn on
     hardcopy > Xhardcopy
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -1,6 +1,7 @@
 
 " Test for insert expansion
 func Test_ins_complete()
+  edit test_ins_complete.vim
   set ff=unix
   call writefile(["test11\t36Gepeto\t/Tag/",
 	      \ "asd\ttest11file\t36G",
--- a/src/testdir/test_packadd.vim
+++ b/src/testdir/test_packadd.vim
@@ -2,7 +2,7 @@
 
 
 func SetUp()
-  let s:topdir = expand('%:h') . '/Xdir'
+  let s:topdir = getcwd() . '/Xdir'
   exe 'set packpath=' . s:topdir
   let s:plugdir = s:topdir . '/pack/mine/opt/mytest'
 endfunc
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -151,7 +151,7 @@ endfunc
 func XageTests(cchar)
   call s:setup_commands(a:cchar)
 
-  let list = [{'bufnr': 1, 'lnum': 1}]
+  let list = [{'bufnr': bufnr('%'), 'lnum': 1}]
   call g:Xsetlist(list)
 
   " Jumping to a non existent list should return error
--- a/src/testdir/test_signs.vim
+++ b/src/testdir/test_signs.vim
@@ -182,7 +182,7 @@ func Test_sign_invalid_commands()
   call assert_fails('sign define Sign1 xxx', 'E475:')
   call assert_fails('sign undefine', 'E156:')
   call assert_fails('sign list xxx', 'E155:')
-  call assert_fails('sign place 1 buffer=', 'E158:')
+  call assert_fails('sign place 1 buffer=999', 'E158:')
   call assert_fails('sign define Sign2 text=', 'E239:')
 endfunc
 
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1224,
+/**/
     1223,
 /**/
     1222,