diff src/testdir/runtest.vim @ 14053:d6866c54a311 v8.1.0044

patch 8.1.0044: if a test function exists Vim this may go unnoticed commit https://github.com/vim/vim/commit/8903676d3d4c3fcb37d2a55c67370f30806b1626 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 12 14:58:39 2018 +0200 patch 8.1.0044: if a test function exists Vim this may go unnoticed Problem: If a test function exists Vim this may go unnoticed. Solution: Check for a test funtion quitting Vim. Fix tests that did exit Vim.
author Christian Brabandt <cb@256bit.org>
date Tue, 12 Jun 2018 15:00:08 +0200
parents 2678e38e1de6
children 720b857c45ca
line wrap: on
line diff
--- a/src/testdir/runtest.vim
+++ b/src/testdir/runtest.vim
@@ -124,7 +124,10 @@ func RunTheTest(test)
     exe 'call ' . a:test
   else
     try
+      let s:test = a:test
+      au VimLeavePre * call EarlyExit(s:test)
       exe 'call ' . a:test
+      au! VimLeavePre
     catch /^\cskipped/
       call add(s:messages, '    Skipped')
       call add(s:skipped, 'SKIPPED ' . a:test . ': ' . substitute(v:exception, '^\S*\s\+', '',  ''))
@@ -174,6 +177,15 @@ func AfterTheTest()
   endif
 endfunc
 
+func EarlyExit(test)
+  " It's OK for the test we use to test the quit detection.
+  if a:test != 'Test_zz_quit_detected()'
+    call add(v:errors, 'Test caused Vim to exit: ' . a:test)
+  endif
+
+  call FinishTesting()
+endfunc
+
 " This function can be called by a test if it wants to abort testing.
 func FinishTesting()
   call AfterTheTest()