summaryrefslogtreecommitdiff
path: root/src/testdir
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-03-03 19:35:02 +0100
committerBram Moolenaar <Bram@vim.org>2016-03-03 19:35:02 +0100
commitd6547fc6471d9084f942bdc4ae3aedb39361751d (patch)
treea78b5d8d63a35c19fa7fda1524b282fa8e6217ae /src/testdir
parentda94fdf2588b3910d38e477a755748ce2c6d2e66 (diff)
downloadvim-git-d6547fc6471d9084f942bdc4ae3aedb39361751d.tar.gz
patch 7.4.1483v7.4.1483
Problem: A one-time callback is not used for a raw channel. Solution: Use a one-time callback when it exists.
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/test_channel.py3
-rw-r--r--src/testdir/test_channel.vim59
2 files changed, 62 insertions, 0 deletions
diff --git a/src/testdir/test_channel.py b/src/testdir/test_channel.py
index 9a3c9213a..02e6ba3ec 100644
--- a/src/testdir/test_channel.py
+++ b/src/testdir/test_channel.py
@@ -62,6 +62,9 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
if decoded[1] == 'hello!':
# simply send back a string
response = "got it"
+ elif decoded[1].startswith("echo "):
+ # send back the argument
+ response = decoded[1][5:]
elif decoded[1] == 'make change':
# Send two ex commands at the same time, before
# replying to the request.
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index 2b46566b7..bc43b446e 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -257,6 +257,8 @@ func Test_server_crash()
call s:run_server('s:server_crash')
endfunc
+"""""""""
+
let s:reply = ""
func s:Handler(chan, msg)
unlet s:reply
@@ -290,6 +292,61 @@ func Test_channel_handler()
unlet s:chopt.callback
endfunc
+"""""""""
+
+let s:reply1 = ""
+func s:HandleRaw1(chan, msg)
+ unlet s:reply1
+ let s:reply1 = a:msg
+endfunc
+
+let s:reply2 = ""
+func s:HandleRaw2(chan, msg)
+ unlet s:reply2
+ let s:reply2 = a:msg
+endfunc
+
+let s:reply3 = ""
+func s:HandleRaw3(chan, msg)
+ unlet s:reply3
+ let s:reply3 = a:msg
+endfunc
+
+func s:raw_one_time_callback(port)
+ let handle = ch_open('localhost:' . a:port, s:chopt)
+ if ch_status(handle) == "fail"
+ call assert_false(1, "Can't open channel")
+ return
+ endif
+ call ch_setoptions(handle, {'mode': 'raw'})
+
+ " The message are sent raw, we do our own JSON strings here.
+ call ch_sendraw(handle, "[1, \"hello!\"]", {'callback': 's:HandleRaw1'})
+ sleep 10m
+ call assert_equal("[1, \"got it\"]", s:reply1)
+ call ch_sendraw(handle, "[2, \"echo something\"]", {'callback': 's:HandleRaw2'})
+ call ch_sendraw(handle, "[3, \"wait a bit\"]", {'callback': 's:HandleRaw3'})
+ sleep 10m
+ call assert_equal("[2, \"something\"]", s:reply2)
+ " wait for up to 500 msec for the 200 msec delayed reply
+ for i in range(50)
+ sleep 10m
+ if s:reply3 != ''
+ break
+ endif
+ endfor
+ call assert_equal("[3, \"waited\"]", s:reply3)
+endfunc
+
+func Test_raw_one_time_callback()
+ call ch_logfile('channellog', 'w')
+ call ch_log('Test_raw_one_time_callback()')
+ call s:run_server('s:raw_one_time_callback')
+ call ch_logfile('')
+endfunc
+
+"""""""""
+
" Test that trying to connect to a non-existing port fails quickly.
func Test_connect_waittime()
call ch_log('Test_connect_waittime()')
@@ -325,6 +382,8 @@ func Test_connect_waittime()
endtry
endfunc
+"""""""""
+
func Test_raw_pipe()
if !has('job')
return