Mercurial > vim
diff src/testdir/test_channel.vim @ 7982:5c30ba57aaea v7.4.1286
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 7 21:29:00 2016 +0100
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.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 07 Feb 2016 21:30:05 +0100 |
parents | 646d5148fee2 |
children | c166ff6797cb |
line wrap: on
line diff
--- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -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