patch 8.0.1222: test functions interfere with each other

Problem:    Test functions interfere with each other.
Solution:   Cleanup tab pages, windows and buffers.  Reset option.
diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim
index ae45a3e..d159382 100644
--- a/src/testdir/runtest.vim
+++ b/src/testdir/runtest.vim
@@ -133,7 +133,11 @@
     endtry
   endif
 
-  " Close any extra windows and make the current one not modified.
+  " Close any extra tab pages and windows and make the current one not modified.
+  while tabpagenr('$') > 1
+    bwipe!
+  endwhile
+
   while 1
     let wincount = winnr('$')
     if wincount == 1
@@ -146,7 +150,15 @@
       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()