patch 8.1.0696: when test_edit fails 'insertmode' may not be reset

Problem:    When test_edit fails 'insertmode' may not be reset and the next
            test may get stuck. (James McCoy)
Solution:   Always reset 'insertmode' after executing a test.  Avoid that an
            InsertCharPre autocommand or a 'complete' function can change the
            state. (closes #3768)
diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim
index 89c1e3a..a8b43aa 100644
--- a/src/testdir/runtest.vim
+++ b/src/testdir/runtest.vim
@@ -26,7 +26,7 @@
 " It will be called after each Test_ function.
 "
 " When debugging a test it can be useful to add messages to v:errors:
-" 	call add(v:errors, "this happened")
+"	call add(v:errors, "this happened")
 
 
 " Without the +eval feature we can't run these tests, bail out.
@@ -149,6 +149,10 @@
     endtry
   endif
 
+  " In case 'insertmode' was set and something went wrong, make sure it is
+  " reset to avoid trouble with anything else.
+  set noinsertmode
+
   if exists("*TearDown")
     try
       call TearDown()