Patch 8.2.0454
Problem:    Some tests fail when the system is slow.
Solution:   Make the run number global, use in the test to increase the
            waiting time. (closes #5841)
Files:      src/testdir/runtest.vim, src/testdir/test_functions.vim


*** ../vim-8.2.0453/src/testdir/runtest.vim     2020-03-21 15:17:16.820725431 
+0100
--- src/testdir/runtest.vim     2020-03-26 16:45:31.294317187 +0100
***************
*** 406,412 ****
    set belloff=all
    let prev_error = ''
    let total_errors = []
!   let run_nr = 1
  
    " A test can set test_is_flaky to retry running the test.
    let test_is_flaky = 0
--- 406,412 ----
    set belloff=all
    let prev_error = ''
    let total_errors = []
!   let g:run_nr = 1
  
    " A test can set test_is_flaky to retry running the test.
    let test_is_flaky = 0
***************
*** 423,432 ****
        call add(s:messages, 'Found errors in ' . s:test . ':')
        call extend(s:messages, v:errors)
  
!       call add(total_errors, 'Run ' . run_nr . ':')
        call extend(total_errors, v:errors)
  
!       if run_nr == 5 || prev_error == v:errors[0]
          call add(total_errors, 'Flaky test failed too often, giving up')
          let v:errors = total_errors
          break
--- 423,432 ----
        call add(s:messages, 'Found errors in ' . s:test . ':')
        call extend(s:messages, v:errors)
  
!       call add(total_errors, 'Run ' . g:run_nr . ':')
        call extend(total_errors, v:errors)
  
!       if g:run_nr == 5 || prev_error == v:errors[0]
          call add(total_errors, 'Flaky test failed too often, giving up')
          let v:errors = total_errors
          break
***************
*** 441,447 ****
  
        let prev_error = v:errors[0]
        let v:errors = []
!       let run_nr += 1
  
        call RunTheTest(s:test)
  
--- 441,447 ----
  
        let prev_error = v:errors[0]
        let v:errors = []
!       let g:run_nr += 1
  
        call RunTheTest(s:test)
  
*** ../vim-8.2.0453/src/testdir/test_functions.vim      2020-03-25 
22:23:41.898363595 +0100
--- src/testdir/test_functions.vim      2020-03-26 16:49:11.733512391 +0100
***************
*** 1832,1837 ****
--- 1832,1848 ----
  func Test_state()
    CheckRunVimInTerminal
  
+   " In the first run try a short wait time.  If the test fails retry with a
+   " longer wait time.
+   if g:run_nr == 1
+     let wait_time = 50
+   elseif g:run_nr == 2
+     let wait_time = 200
+   else
+     let wait_time = 500
+   endif
+   let getstate = ":echo 'state: ' .. g:state .. '; mode: ' .. g:mode\<CR>"
+ 
    let lines =<< trim END
        call setline(1, ['one', 'two', 'three'])
        map ;; gg
***************
*** 1851,1878 ****
  
    " Using a timer callback
    call term_sendkeys(buf, ":call RunTimer()\<CR>")
!   call term_wait(buf, 50)
!   let getstate = ":echo 'state: ' .. g:state .. '; mode: ' .. g:mode\<CR>"
    call term_sendkeys(buf, getstate)
    call WaitForAssert({-> assert_match('state: c; mode: n', term_getline(buf, 
6))}, 1000)
  
    " Halfway a mapping
    call term_sendkeys(buf, ":call RunTimer()\<CR>;")
!   call term_wait(buf, 50)
    call term_sendkeys(buf, ";")
    call term_sendkeys(buf, getstate)
    call WaitForAssert({-> assert_match('state: mSc; mode: n', 
term_getline(buf, 6))}, 1000)
  
    " Insert mode completion (bit slower on Mac)
    call term_sendkeys(buf, ":call RunTimer()\<CR>Got\<C-N>")
!   call term_wait(buf, 200)
    call term_sendkeys(buf, "\<Esc>")
    call term_sendkeys(buf, getstate)
    call WaitForAssert({-> assert_match('state: aSc; mode: i', 
term_getline(buf, 6))}, 1000)
  
    " Autocommand executing
    call term_sendkeys(buf, ":set filetype=foobar\<CR>")
!   call term_wait(buf, 50)
    call term_sendkeys(buf, getstate)
    call WaitForAssert({-> assert_match('state: xS; mode: n', term_getline(buf, 
6))}, 1000)
  
--- 1862,1888 ----
  
    " Using a timer callback
    call term_sendkeys(buf, ":call RunTimer()\<CR>")
!   call term_wait(buf, wait_time)
    call term_sendkeys(buf, getstate)
    call WaitForAssert({-> assert_match('state: c; mode: n', term_getline(buf, 
6))}, 1000)
  
    " Halfway a mapping
    call term_sendkeys(buf, ":call RunTimer()\<CR>;")
!   call term_wait(buf, wait_time)
    call term_sendkeys(buf, ";")
    call term_sendkeys(buf, getstate)
    call WaitForAssert({-> assert_match('state: mSc; mode: n', 
term_getline(buf, 6))}, 1000)
  
    " Insert mode completion (bit slower on Mac)
    call term_sendkeys(buf, ":call RunTimer()\<CR>Got\<C-N>")
!   call term_wait(buf, wait_time)
    call term_sendkeys(buf, "\<Esc>")
    call term_sendkeys(buf, getstate)
    call WaitForAssert({-> assert_match('state: aSc; mode: i', 
term_getline(buf, 6))}, 1000)
  
    " Autocommand executing
    call term_sendkeys(buf, ":set filetype=foobar\<CR>")
!   call term_wait(buf, wait_time)
    call term_sendkeys(buf, getstate)
    call WaitForAssert({-> assert_match('state: xS; mode: n', term_getline(buf, 
6))}, 1000)
  
***************
*** 1880,1886 ****
  
    " messages scrolled
    call term_sendkeys(buf, ":call RunTimer()\<CR>:echo 
\"one\\ntwo\\nthree\"\<CR>")
!   call term_wait(buf, 50)
    call term_sendkeys(buf, "\<CR>")
    call term_sendkeys(buf, getstate)
    call WaitForAssert({-> assert_match('state: Scs; mode: r', 
term_getline(buf, 6))}, 1000)
--- 1890,1896 ----
  
    " messages scrolled
    call term_sendkeys(buf, ":call RunTimer()\<CR>:echo 
\"one\\ntwo\\nthree\"\<CR>")
!   call term_wait(buf, wait_time)
    call term_sendkeys(buf, "\<CR>")
    call term_sendkeys(buf, getstate)
    call WaitForAssert({-> assert_match('state: Scs; mode: r', 
term_getline(buf, 6))}, 1000)
*** ../vim-8.2.0453/src/version.c       2020-03-26 16:27:34.942445362 +0100
--- src/version.c       2020-03-26 16:46:44.622046573 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     454,
  /**/

-- 
Q:   How many hardware engineers does it take to change a lightbulb?
A:   None.  We'll fix it in software.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202003261551.02QFpSV2017902%40masaka.moolenaar.net.

Raspunde prin e-mail lui