0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 7.4.1286

Problem:    ch_open() with a timeout doesn't work correctly.
Solution:   Change how select() is used.  Don't give an error on timeout.
            Add a test for ch_open() failing.
This commit is contained in:
Bram Moolenaar
2016-02-07 21:29:00 +01:00
parent cb00f03933
commit 7a84dbe6be
3 changed files with 34 additions and 9 deletions

View File

@@ -177,3 +177,27 @@ func Test_server_crash()
sleep 10m
call s:kill_server()
endfunc
" Test that trying to connect to a non-existing port fails quickly.
func Test_connect_waittime()
let start = reltime()
let handle = ch_open('localhost:9876')
if handle >= 0
" Oops, port does exists.
call ch_close(handle)
else
let elapsed = reltime(start)
call assert_true(elapsed < 1.0)
endif
let start = reltime()
let handle = ch_open('localhost:9867', {'waittime': 2000})
if handle >= 0
" Oops, port does exists.
call ch_close(handle)
else
" Failed connection doesn't wait the full time.
let elapsed = reltime(start)
call assert_true(elapsed < 1.0)
endif
endfunc