changeset 8168:454a30a7590e v7.4.1377

commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 21 13:01:53 2016 +0100 patch 7.4.1377 Problem: Test_connect_waittime() is flaky. Solution: Ignore the "Connection reset by peer" error.
author Christian Brabandt <cb@256bit.org>
date Sun, 21 Feb 2016 13:15:04 +0100
parents 9ca3885edfed
children bf0ad2820b48
files src/testdir/test_channel.vim src/version.c
diffstat 2 files changed, 21 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -304,16 +304,26 @@ func Test_connect_waittime()
     call assert_true(reltimefloat(elapsed) < 1.0)
   endif
 
+  " We intend to use a socket that doesn't exist and wait for half a second
+  " before giving up.  If the socket does exist it can fail in various ways.
+  " Check for "Connection reset by peer" to avoid flakyness.
   let start = reltime()
-  let handle = ch_open('localhost:9867', {'waittime': 500})
-  if ch_status(handle) != "fail"
-    " Oops, port does exists.
-    call ch_close(handle)
-  else
-    " Failed connection should wait about 500 msec.
-    let elapsed = reltime(start)
-    call assert_true(reltimefloat(elapsed) < 1.0)
-  endif
+  try
+    let handle = ch_open('localhost:9867', {'waittime': 500})
+    if ch_status(handle) != "fail"
+      " Oops, port does exists.
+      call ch_close(handle)
+    else
+      " Failed connection should wait about 500 msec.
+      let elapsed = reltime(start)
+      call assert_true(reltimefloat(elapsed) > 0.3)
+      call assert_true(reltimefloat(elapsed) < 1.0)
+    endif
+  catch
+    if v:exception !~ 'Connection reset by peer'
+      call assert_false(1, "Caught exception: " . v:exception)
+    endif
+  endtry
 endfunc
 
 func Test_raw_pipe()
--- a/src/version.c
+++ b/src/version.c
@@ -748,6 +748,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1377,
+/**/
     1376,
 /**/
     1375,