]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0820: tests: Mac OS tests are too flaky v9.1.0820
authorMilly <milly.ca@gmail.com>
Mon, 28 Oct 2024 20:56:14 +0000 (21:56 +0100)
committerChristian Brabandt <cb@256bit.org>
Mon, 28 Oct 2024 20:56:50 +0000 (21:56 +0100)
Problem:  tests: Mac OS tests are too flaky
Solution: Increase max test timeout to 25 minutes,
          allow up to 10 retries on Mac OS runners,
          refactor runtest.vim (Milly).

closes: #15940

Co-authored-by: K.Takata <kentkt@csc.jp>
Signed-off-by: Milly <milly.ca@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
.github/workflows/ci.yml
src/testdir/runtest.vim
src/testdir/screendump.vim
src/testdir/test_channel.vim
src/version.c

index c1cca40563ca5f64d27b3838240197d8d7c89556..6b3b3d0fb43fc94ba767f71fae309d38ad1a1d03 100644 (file)
@@ -389,7 +389,7 @@ jobs:
           brew install diffutils
 
       - name: Test
-        timeout-minutes: 20
+        timeout-minutes: 25
         run: |
           make ${TEST}
 
index 7ac48455e8e79dc45696672f5ff3b22f4b9a5298..ded31975b80ba7a76a0a25bb898d3260cf87384c 100644 (file)
@@ -190,10 +190,6 @@ function GetAllocId(name)
   return lnum - top - 1
 endfunc
 
-if has('reltime')
-  let g:func_start = reltime()
-endif
-
 " Get the list of swap files in the current directory.
 func s:GetSwapFileList()
   let save_dir = &directory
@@ -603,6 +599,16 @@ for g:testfunc in sort(s:tests)
   " A test can set g:test_is_flaky to retry running the test.
   let g:test_is_flaky = 0
 
+  " A test can set g:max_run_nr to change the max retry count.
+  let g:max_run_nr = 5
+  if has('mac')
+    let g:max_run_nr = 10
+  endif
+
+  " By default, give up if the same error occurs.  A test can set
+  " g:giveup_same_error to 0 to not give up on the same error and keep trying.
+  let g:giveup_same_error = 1
+
   let starttime = strftime("%H:%M:%S")
   call RunTheTest(g:testfunc)
 
@@ -618,10 +624,15 @@ for g:testfunc in sort(s:tests)
       call extend(s:messages, v:errors)
 
       let endtime = strftime("%H:%M:%S")
-      call add(total_errors, $'Run {g:run_nr}, {starttime} - {endtime}:')
+      if has('reltime')
+        let suffix = $' in{reltimestr(reltime(g:func_start))} seconds'
+      else
+        let suffix = ''
+      endif
+      call add(total_errors, $'Run {g:run_nr}, {starttime} - {endtime}{suffix}:')
       call extend(total_errors, v:errors)
 
-      if g:run_nr >= 5 || prev_error == v:errors[0]
+      if g:run_nr >= g:max_run_nr || g:giveup_same_error && prev_error == v:errors[0]
         call add(total_errors, 'Flaky test failed too often, giving up')
         let v:errors = total_errors
         break
@@ -632,7 +643,8 @@ for g:testfunc in sort(s:tests)
       " Flakiness is often caused by the system being very busy.  Sleep a
       " couple of seconds to have a higher chance of succeeding the second
       " time.
-      sleep 2
+      let delay = g:run_nr * 2
+      exe 'sleep' delay
 
       let prev_error = v:errors[0]
       let v:errors = []
index e7cda2ef47ac2aeef11114b3eb51eda020974322..84b4864416fef56770308057d6ddd7af12989bac 100644 (file)
@@ -56,6 +56,7 @@ func VerifyScreenDump(buf, filename, options, ...)
 
   " Starting a terminal to make a screendump is always considered flaky.
   let g:test_is_flaky = 1
+  let g:giveup_same_error = 0
 
   " wait for the pending updates to be handled.
   call TermWait(a:buf)
@@ -83,41 +84,55 @@ func VerifyScreenDump(buf, filename, options, ...)
     sleep 50m
     call delete(testfile)
     call term_dumpwrite(a:buf, testfile, a:options)
+
+    if refdump->empty()
+      let msg = 'See new dump file: call term_dumpload("testdir/' .. testfile .. '")'
+      call assert_report(msg)
+      " no point in retrying
+      let g:run_nr = 10
+      return 1
+    endif
+
     let testdump = ReadAndFilter(testfile, filter)
     if refdump == testdump
       call delete(testfile)
       if did_mkdir
        call delete('failed', 'd')
       endif
+      if i > 0
+       call remove(v:errors, -1)
+      endif
       break
     endif
-    if i == max_loops
-      " Leave the failed dump around for inspection.
-      if filereadable(reference)
-       let msg = 'See dump file difference: call term_dumpdiff("testdir/' .. testfile .. '", "testdir/' .. reference .. '")'
-       if a:0 == 1
-         let msg = a:1 . ': ' . msg
-       endif
-       if len(testdump) != len(refdump)
-         let msg = msg . '; line count is ' . len(testdump) . ' instead of ' . len(refdump)
-       endif
-      else
-       let msg = 'See new dump file: call term_dumpload("testdir/' .. testfile .. '")'
-       " no point in retrying
-       let g:run_nr = 10
+
+    " Leave the failed dump around for inspection.
+    let msg = 'See dump file difference: call term_dumpdiff("testdir/' .. testfile .. '", "testdir/' .. reference .. '")'
+    if a:0 == 1
+      let msg = a:1 . ': ' . msg
+    endif
+    if len(testdump) != len(refdump)
+      let msg = msg . '; line count is ' . len(testdump) . ' instead of ' . len(refdump)
+    endif
+    for j in range(len(refdump))
+      if j >= len(testdump)
+       break
       endif
-      for i in range(len(refdump))
-       if i >= len(testdump)
-         break
-       endif
-       if testdump[i] != refdump[i]
-         let msg = msg . '; difference in line ' . (i + 1) . ': "' . testdump[i] . '"'
-       endif
-      endfor
-      call assert_report(msg)
-      return 1
+      if testdump[j] != refdump[j]
+       let msg = msg . '; difference in line ' . (j + 1) . ': "' . testdump[j] . '"'
+      endif
+    endfor
+
+    " Always add the last error so that it is displayed on timeout.
+    " See TestTimeout() in runtest.vim.
+    if i > 0
+      call remove(v:errors, -1)
     endif
+    call assert_report(msg)
+
     let i += 1
+    if i >= max_loops
+      return 1
+    endif
   endwhile
   return 0
 endfunc
index 78c834d70dcea742b0b7a621f47fdd15ae930883..2d40eff12f02749b692a5aa6d0728fd16a959750 100644 (file)
@@ -2762,6 +2762,8 @@ func LspTests(port)
 endfunc
 
 func Test_channel_lsp_mode()
+  " The channel lsp mode test is flaky and gives the same error.
+  let g:giveup_same_error = 0
   call RunServer('test_channel_lsp.py', 'LspTests', [])
 endfunc
 
index 838f25acda06a17d18d9622ee926d55d1e0bd352..e04296567813e6af70045103b4587e81f2f4c14f 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    820,
 /**/
     819,
 /**/