patch 9.1.1051: tests: no support for env variables when running Vim in terminal

Problem:  tests: no support for env variables when running Vim in
          terminal
Solution: support the "env" argument in RunVimInTerminal(),
          close swapfiles properly in test_termcodes,
          use CheckFeature in test_termencoding

Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim
index 2b44b15..25034ed 100644
--- a/src/testdir/test_termcodes.vim
+++ b/src/testdir/test_termcodes.vim
@@ -301,7 +301,7 @@
   let &ttymouse = save_ttymouse
   let &term = save_term
   let &mouse = save_mouse
-  close!
+  bw!
 endfunc
 
 func Test_term_mouse_middle_click_insert_mode()
@@ -370,7 +370,7 @@
   let &term = save_term
   let &ttymouse = save_ttymouse
   call test_override('no_query_mouse', 0)
-  close!
+  bw!
 endfunc
 
 " Test for using the mouse to increase the height of the cmdline window
@@ -1051,7 +1051,7 @@
   let &ttymouse = save_ttymouse
   set mousetime& mousemodel&
   call test_override('no_query_mouse', 0)
-  close!
+  bw!
 endfunc
 
 func Test_xterm_mouse_click_in_fold_columns()
@@ -1276,7 +1276,7 @@
   let &term = save_term
   let &ttymouse = save_ttymouse
   call test_override('no_query_mouse', 0)
-  close!
+  bw!
 endfunc
 
 " Test for displaying the popup menu using the right mouse click
@@ -1311,7 +1311,7 @@
   let &ttymouse = save_ttymouse
   let &mousemodel = save_mousemodel
   call test_override('no_query_mouse', 0)
-  close!
+  bw!
 endfunc
 
 " Test for 'mousemodel' set to popup_setpos to move the cursor where the popup
@@ -1437,7 +1437,7 @@
   let &ttymouse = save_ttymouse
   let &mousemodel = save_mousemodel
   call test_override('no_query_mouse', 0)
-  close!
+  bw!
 endfunc
 
 " Test for searching for the word under the cursor using Shift-Right or
@@ -1476,7 +1476,7 @@
   let &term = save_term
   let &ttymouse = save_ttymouse
   call test_override('no_query_mouse', 0)
-  close!
+  bw!
 endfunc
 
 " Test for selecting an entry in the quickfix/location list window using the
@@ -2739,5 +2739,4 @@
   call assert_notequal(-1, index(output, 'builtin_dumb'))
 endfunc
 
-
 " vim: shiftwidth=2 sts=2 expandtab