]> granicus.if.org Git - vim/commitdiff
patch 8.1.0044: if a test function exists Vim this may go unnoticed v8.1.0044
authorBram Moolenaar <Bram@vim.org>
Tue, 12 Jun 2018 12:58:39 +0000 (14:58 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 12 Jun 2018 12:58:39 +0000 (14:58 +0200)
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.

src/testdir/runtest.vim
src/testdir/test_assert.vim
src/version.c

index 5b8126d5d1ec25ec0ce520aa589129e1f81cf6d1..4f508a4875b6ca898201f5bc63e45bfe19b89010 100644 (file)
@@ -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()
index 61147286fb7aeb75c6bf44797ed3d9902de77245..28db289b2af54835c6da59c656e03579dd95d22c 100644 (file)
@@ -198,3 +198,9 @@ func Test_user_is_happy()
   smile
   sleep 300m
 endfunc
+
+" Must be last.
+func Test_zz_quit_detected()
+  " Verify that if a test function ends Vim the test script detects this.
+  quit
+endfunc
index 100506b0b1d064c5f1724f352a114412d254f496..dfdc07d59f5749b549aeb6fc676bf6a2f81c3fff 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    44,
 /**/
     43,
 /**/