]> granicus.if.org Git - vim/commitdiff
patch 8.2.2031: some tests fail when run under valgrind v8.2.2031
authorBram Moolenaar <Bram@vim.org>
Sun, 22 Nov 2020 13:24:00 +0000 (14:24 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 22 Nov 2020 13:24:00 +0000 (14:24 +0100)
Problem:    Some tests fail when run under valgrind.
Solution:   Avoid timing problems.

src/testdir/test_channel.vim
src/testdir/test_clientserver.vim
src/testdir/test_debugger.vim
src/testdir/test_quotestar.vim
src/testdir/test_vim9_func.vim
src/version.c

index 6fa7e3bfdbe8ba98496c9074fce9bedbd9d0de69..90d828bdb3740af1a84904b22c482c2e99f7e561 100644 (file)
@@ -2181,18 +2181,21 @@ func Test_issue_5150()
   else
     let cmd = 'grep foo'
   endif
+
   let g:job = job_start(cmd, {})
+  sleep 50m  " give the job time to start
   call job_stop(g:job)
-  sleep 50m
-  call assert_equal(-1, job_info(g:job).exitval)
+  call WaitForAssert({-> assert_equal(-1, job_info(g:job).exitval)})
+
   let g:job = job_start(cmd, {})
-  call job_stop(g:job, 'term')
   sleep 50m
-  call assert_equal(-1, job_info(g:job).exitval)
+  call job_stop(g:job, 'term')
+  call WaitForAssert({-> assert_equal(-1, job_info(g:job).exitval)})
+
   let g:job = job_start(cmd, {})
-  call job_stop(g:job, 'kill')
   sleep 50m
-  call assert_equal(-1, job_info(g:job).exitval)
+  call job_stop(g:job, 'kill')
+  call WaitForAssert({-> assert_equal(-1, job_info(g:job).exitval)})
 endfunc
 
 func Test_issue_5485()
index 7a750556ab6638011cc9ec0bc8970096f95deae5..6043184211289cdd2b01e010efc0d33fdaa75fb0 100644 (file)
@@ -63,8 +63,9 @@ func Test_client_server()
       call remote_send(name, ":gui -f\<CR>")
     endif
     " Wait for the server to be up and answering requests.
-    sleep 100m
-    call WaitForAssert({-> assert_true(name->remote_expr("v:version", "", 1) != "")})
+    " When using valgrind this can be very, very slow.
+    sleep 1
+    call WaitForAssert({-> assert_match('\d', name->remote_expr("v:version", "", 1))}, 10000)
 
     call remote_send(name, ":let testvar = 'maybe'\<CR>")
     call WaitForAssert({-> assert_equal('maybe', remote_expr(name, "testvar", "", 2))})
index 3b02241205b14d6c92604ac4387c8fd52ed90d45..b3636408d8488bc9ac4578ec232989724b59e839 100644 (file)
@@ -17,14 +17,18 @@ func CheckCWD()
 endfunc
 command! -nargs=0 -bar CheckCWD call CheckCWD()
 
+" "options" argument can contain:
+" 'msec' - time to wait for a match
+" 'match' - "pattern" to use "lines" as pattern instead of text
 func CheckDbgOutput(buf, lines, options = {})
   " Verify the expected output
   let lnum = 20 - len(a:lines)
+  let msec = get(a:options, 'msec', 1000)
   for l in a:lines
     if get(a:options, 'match', 'equal') ==# 'pattern'
-      call WaitForAssert({-> assert_match(l, term_getline(a:buf, lnum))}, 200)
+      call WaitForAssert({-> assert_match(l, term_getline(a:buf, lnum))}, msec)
     else
-      call WaitForAssert({-> assert_equal(l, term_getline(a:buf, lnum))}, 200)
+      call WaitForAssert({-> assert_equal(l, term_getline(a:buf, lnum))}, msec)
     endif
     let lnum += 1
   endfor
@@ -198,7 +202,7 @@ func Test_Debugger()
 
   " Start a debug session, so that reading the last line from the terminal
   " works properly.
-  call RunDbgCmd(buf, ':debug echo Foo()')
+  call RunDbgCmd(buf, ':debug echo Foo()', ['cmd: echo Foo()'])
 
   " No breakpoints
   call RunDbgCmd(buf, 'breakl', ['No breakpoints defined'])
@@ -809,9 +813,10 @@ func Test_Backtrace_CmdLine()
         \ '-S Xtest1.vim -c "debug call GlobalFunction()"',
         \ {'wait_for_ruler': 0})
 
-  " Need to wait for the vim-in-terminal to be ready
+  " Need to wait for the vim-in-terminal to be ready.
+  " With valgrind this can take quite long.
   call CheckDbgOutput(buf, ['command line',
-                            \ 'cmd: call GlobalFunction()'])
+                            \ 'cmd: call GlobalFunction()'], #{msec: 5000})
 
   " At this point the ontly thing in the stack is the cmdline
   call RunDbgCmd(buf, 'backtrace', [
@@ -960,14 +965,14 @@ func Test_debug_backtrace_level()
   " set a breakpoint and source file1.vim
   let buf = RunVimInTerminal(
         \ '-c "breakadd file 1 Xtest1.vim" -S Xtest1.vim',
-        \ #{ wait_for_ruler: 0 } )
+        \ #{wait_for_ruler: 0})
 
   call CheckDbgOutput(buf, [
         \ 'Breakpoint in "' .. file1 .. '" line 1',
         \ 'Entering Debug mode.  Type "cont" to continue.',
         \ 'command line..script ' .. file1,
         \ 'line 1: let s:file1_var = ''file1'''
-        \ ])
+        \ ], #{msec: 5000})
 
   " step throught the initial declarations
   call RunDbgCmd(buf, 'step', [ 'line 2: let g:global_var = ''global''' ] )
index 9e04e1965499b5e33596eca78be4518b2c488dac..6b8aebfff7fcaadcbbb73aba67193c528a2bf893 100644 (file)
@@ -98,8 +98,6 @@ func Do_test_quotestar_for_x11()
 
     " Running in a terminal and the GUI is available: Tell the server to open
     " the GUI and check that the remote command still works.
-    " Need to wait for the GUI to start up, otherwise the send hangs in trying
-    " to send to the terminal window.
     if has('gui_athena') || has('gui_motif')
       " For those GUIs, ignore the 'failed to create input context' error.
       call remote_send(name, ":call test_ignore_error('E285') | gui -f\<CR>")
@@ -107,7 +105,10 @@ func Do_test_quotestar_for_x11()
       call remote_send(name, ":gui -f\<CR>")
     endif
     " Wait for the server in the GUI to be up and answering requests.
+    " First need to wait for the GUI to start up, otherwise the send hangs in
+    " trying to send to the terminal window.
     " On some systems and with valgrind this can be very slow.
+    sleep 1
     call WaitForAssert({-> assert_match("1", remote_expr(name, "has('gui_running')", "", 1))}, 10000)
 
     call remote_send(name, ":let @* = 'maybe'\<CR>")
index 7b5d3e9d7ea8621df37467db08041c34e4efb1fe..dd2f576ddced684d57d711e7b02d149f1812faba 100644 (file)
@@ -37,7 +37,7 @@ def TestCompilingError()
     for i in range(1, 9)
       text ..= term_getline(buf, i)
     endfor
-    if text =~ 'Error detected'
+    if text =~ 'Variable not found: nothing'
       break
     endif
     sleep 20m
index f2a3ba85c390f0c2e16f2a9c8726ada12649f9f3..14eb31380c7404b6319edad46bcae77c0bc3d8e0 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2031,
 /**/
     2030,
 /**/