]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0561: when a test gets stuck it just hangs forever v9.0.0561
authorBram Moolenaar <Bram@vim.org>
Fri, 23 Sep 2022 19:25:55 +0000 (20:25 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 23 Sep 2022 19:25:55 +0000 (20:25 +0100)
Problem:    When a test gets stuck it just hangs forever.
Solution:   Set a timeout of 30 seconds.

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

index 5e1d6418f3de7fcabe0b1494e95411096926c355..e1d999912cc0ea873327247d00a20544c8561105 100644 (file)
@@ -186,6 +186,17 @@ if has('reltime')
   let g:func_start = reltime()
 endif
 
+" Invoked when a test takes too much time.
+func TestTimeout(id)
+  split test.log
+  call append(line('$'), '')
+  call append(line('$'), 'Test timed out: ' .. g:testfunc)
+  write
+  call add(v:errors, 'Test timed out: ' . g:testfunc)
+
+  cquit! 42
+endfunc
+
 func RunTheTest(test)
   let prefix = ''
   if has('reltime')
@@ -194,6 +205,12 @@ func RunTheTest(test)
   endif
   echoconsole prefix .. 'Executing ' .. a:test
 
+  if has('timers')
+    " No test should take longer than 30 seconds.  If it takes longer we
+    " assume we are stuck and need to break out.
+    let test_timeout_timer = timer_start(30000, 'TestTimeout')
+  endif
+
   " Avoid stopping at the "hit enter" prompt
   set nomore
 
@@ -259,6 +276,10 @@ func RunTheTest(test)
     endtry
   endif
 
+  if has('timers')
+    call timer_stop(test_timeout_timer)
+  endif
+
   " Clear any autocommands and put back the catch-all for SwapExists.
   au!
   au SwapExists * call HandleSwapExists()
index fb34719ebf3c887d80e3c760dc008a4b6a2dd311..20ed2d76410d1ee55754ea617e04a463c749f9f1 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    561,
 /**/
     560,
 /**/