annotate src/testdir/test_channel.vim @ 8130:3462f9cfedf8 v7.4.1359

commit https://github.com/vim/vim/commit/1f6ef66254c1e25ef1c7972aa9a0ba119ebc17e4 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 19 22:59:44 2016 +0100 patch 7.4.1359 Problem: Channel test ch_sendexpr() times out. Solution: Increase the timeout
author Christian Brabandt <cb@256bit.org>
date Fri, 19 Feb 2016 23:00:06 +0100
parents 310dd635e8c9
children f96536c291d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test for channel functions.
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 scriptencoding utf-8
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3
7922
14540239601d commit https://github.com/vim/vim/commit/e24692573a266f5060c06dd80bde264092c90dd5
Christian Brabandt <cb@256bit.org>
parents: 7918
diff changeset
4 if !has('channel')
14540239601d commit https://github.com/vim/vim/commit/e24692573a266f5060c06dd80bde264092c90dd5
Christian Brabandt <cb@256bit.org>
parents: 7918
diff changeset
5 finish
14540239601d commit https://github.com/vim/vim/commit/e24692573a266f5060c06dd80bde264092c90dd5
Christian Brabandt <cb@256bit.org>
parents: 7918
diff changeset
6 endif
14540239601d commit https://github.com/vim/vim/commit/e24692573a266f5060c06dd80bde264092c90dd5
Christian Brabandt <cb@256bit.org>
parents: 7918
diff changeset
7
14540239601d commit https://github.com/vim/vim/commit/e24692573a266f5060c06dd80bde264092c90dd5
Christian Brabandt <cb@256bit.org>
parents: 7918
diff changeset
8 " This test requires the Python command to run the test server.
7929
e44240b5a6da commit https://github.com/vim/vim/commit/a8343c1808f2f268282f3030ce4adaf22e8ade54
Christian Brabandt <cb@256bit.org>
parents: 7925
diff changeset
9 " This most likely only works on Unix and Windows.
7902
f12d6235a753 commit https://github.com/vim/vim/commit/a0f9cd148eaab23b2037d2f543f3b8f5a3a7ad3c
Christian Brabandt <cb@256bit.org>
parents: 7899
diff changeset
10 if has('unix')
7957
b74549818500 commit https://github.com/vim/vim/commit/835dc636a5350f610b62f110227d2363b5b2880a
Christian Brabandt <cb@256bit.org>
parents: 7939
diff changeset
11 " We also need the job feature or the pkill command to make sure the server
b74549818500 commit https://github.com/vim/vim/commit/835dc636a5350f610b62f110227d2363b5b2880a
Christian Brabandt <cb@256bit.org>
parents: 7939
diff changeset
12 " can be stopped.
b74549818500 commit https://github.com/vim/vim/commit/835dc636a5350f610b62f110227d2363b5b2880a
Christian Brabandt <cb@256bit.org>
parents: 7939
diff changeset
13 if !(executable('python') && (has('job') || executable('pkill')))
7902
f12d6235a753 commit https://github.com/vim/vim/commit/a0f9cd148eaab23b2037d2f543f3b8f5a3a7ad3c
Christian Brabandt <cb@256bit.org>
parents: 7899
diff changeset
14 finish
f12d6235a753 commit https://github.com/vim/vim/commit/a0f9cd148eaab23b2037d2f543f3b8f5a3a7ad3c
Christian Brabandt <cb@256bit.org>
parents: 7899
diff changeset
15 endif
8066
1aa8ed4ee48b commit https://github.com/vim/vim/commit/b6a7737938e7e7b34f862f58aa5498e6f652e33d
Christian Brabandt <cb@256bit.org>
parents: 8059
diff changeset
16 let s:python = 'python'
7929
e44240b5a6da commit https://github.com/vim/vim/commit/a8343c1808f2f268282f3030ce4adaf22e8ade54
Christian Brabandt <cb@256bit.org>
parents: 7925
diff changeset
17 elseif has('win32')
8066
1aa8ed4ee48b commit https://github.com/vim/vim/commit/b6a7737938e7e7b34f862f58aa5498e6f652e33d
Christian Brabandt <cb@256bit.org>
parents: 8059
diff changeset
18 " Use Python Launcher for Windows (py.exe) if available.
1aa8ed4ee48b commit https://github.com/vim/vim/commit/b6a7737938e7e7b34f862f58aa5498e6f652e33d
Christian Brabandt <cb@256bit.org>
parents: 8059
diff changeset
19 if executable('py.exe')
1aa8ed4ee48b commit https://github.com/vim/vim/commit/b6a7737938e7e7b34f862f58aa5498e6f652e33d
Christian Brabandt <cb@256bit.org>
parents: 8059
diff changeset
20 let s:python = 'py.exe'
1aa8ed4ee48b commit https://github.com/vim/vim/commit/b6a7737938e7e7b34f862f58aa5498e6f652e33d
Christian Brabandt <cb@256bit.org>
parents: 8059
diff changeset
21 elseif executable('python.exe')
1aa8ed4ee48b commit https://github.com/vim/vim/commit/b6a7737938e7e7b34f862f58aa5498e6f652e33d
Christian Brabandt <cb@256bit.org>
parents: 8059
diff changeset
22 let s:python = 'python.exe'
1aa8ed4ee48b commit https://github.com/vim/vim/commit/b6a7737938e7e7b34f862f58aa5498e6f652e33d
Christian Brabandt <cb@256bit.org>
parents: 8059
diff changeset
23 else
7902
f12d6235a753 commit https://github.com/vim/vim/commit/a0f9cd148eaab23b2037d2f543f3b8f5a3a7ad3c
Christian Brabandt <cb@256bit.org>
parents: 7899
diff changeset
24 finish
f12d6235a753 commit https://github.com/vim/vim/commit/a0f9cd148eaab23b2037d2f543f3b8f5a3a7ad3c
Christian Brabandt <cb@256bit.org>
parents: 7899
diff changeset
25 endif
f12d6235a753 commit https://github.com/vim/vim/commit/a0f9cd148eaab23b2037d2f543f3b8f5a3a7ad3c
Christian Brabandt <cb@256bit.org>
parents: 7899
diff changeset
26 else
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
27 " Can't run this test.
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 finish
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 endif
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
8096
882ba5080c5c commit https://github.com/vim/vim/commit/e74e8e7d758e9312165a931f176185f07a64231a
Christian Brabandt <cb@256bit.org>
parents: 8094
diff changeset
31 let s:chopt = {}
7916
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
32
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
33 " Run "testfunc" after sarting the server and stop the server afterwards.
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
34 func s:run_server(testfunc, ...)
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
35 " The Python program writes the port number in Xportnr.
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
36 call delete("Xportnr")
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
37
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
38 if a:0 == 1
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
39 let arg = ' ' . a:1
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
40 else
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
41 let arg = ''
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
42 endif
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
43 let cmd = s:python . " test_channel.py" . arg
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
44
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
45 try
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
46 if has('job')
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
47 let s:job = job_start(cmd)
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
48 elseif has('win32')
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
49 exe 'silent !start cmd /c start "test_channel" ' . cmd
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
50 else
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
51 exe 'silent !' . cmd . '&'
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
52 endif
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
54 " Wait for up to 2 seconds for the port number to be there.
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
55 let cnt = 20
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
56 let l = []
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
57 while cnt > 0
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
58 try
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
59 let l = readfile("Xportnr")
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
60 catch
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
61 endtry
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
62 if len(l) >= 1
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
63 break
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
64 endif
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
65 sleep 100m
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
66 let cnt -= 1
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
67 endwhile
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
68 call delete("Xportnr")
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
69
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
70 if len(l) == 0
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
71 " Can't make the connection, give up.
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
72 call assert_false(1, "Can't start test_channel.py")
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
73 return -1
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 endif
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
75 let port = l[0]
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
77 call call(function(a:testfunc), [port])
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
78 catch
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
79 call assert_false(1, "Caught exception: " . v:exception)
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
80 finally
7902
f12d6235a753 commit https://github.com/vim/vim/commit/a0f9cd148eaab23b2037d2f543f3b8f5a3a7ad3c
Christian Brabandt <cb@256bit.org>
parents: 7899
diff changeset
81 call s:kill_server()
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
82 endtry
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
83 endfunc
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
84
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
85 func s:kill_server()
7957
b74549818500 commit https://github.com/vim/vim/commit/835dc636a5350f610b62f110227d2363b5b2880a
Christian Brabandt <cb@256bit.org>
parents: 7939
diff changeset
86 if has('job')
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
87 if exists('s:job')
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
88 call job_stop(s:job)
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
89 unlet s:job
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
90 endif
7957
b74549818500 commit https://github.com/vim/vim/commit/835dc636a5350f610b62f110227d2363b5b2880a
Christian Brabandt <cb@256bit.org>
parents: 7939
diff changeset
91 elseif has('win32')
8066
1aa8ed4ee48b commit https://github.com/vim/vim/commit/b6a7737938e7e7b34f862f58aa5498e6f652e33d
Christian Brabandt <cb@256bit.org>
parents: 8059
diff changeset
92 call system('taskkill /IM ' . s:python . ' /T /F /FI "WINDOWTITLE eq test_channel"')
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
93 else
7914
35973ce58c84 commit https://github.com/vim/vim/commit/608a8919cae982cb38e38725a843df47b234dae6
Christian Brabandt <cb@256bit.org>
parents: 7906
diff changeset
94 call system("pkill -f test_channel.py")
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
95 endif
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
96 endfunc
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
97
7933
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
98 let s:responseMsg = ''
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
99 func s:RequestHandler(handle, msg)
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
100 let s:responseHandle = a:handle
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
101 let s:responseMsg = a:msg
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
102 endfunc
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
103
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
104 func s:communicate(port)
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
105 let handle = ch_open('localhost:' . a:port, s:chopt)
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
106 if ch_status(handle) == "fail"
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
107 call assert_false(1, "Can't open channel")
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 return
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 endif
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 " Simple string request and reply.
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 call assert_equal('got it', ch_sendexpr(handle, 'hello!'))
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 " Request that triggers sending two ex commands. These will usually be
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 " handled before getting the response, but it's not guaranteed, thus wait a
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 " tiny bit for the commands to get executed.
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
117 call assert_equal('ok', ch_sendexpr(handle, 'make change'))
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 sleep 10m
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 call assert_equal('added1', getline(line('$') - 1))
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 call assert_equal('added2', getline('$'))
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121
7939
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
122 call assert_equal('ok', ch_sendexpr(handle, 'do normal'))
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
123 sleep 10m
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
124 call assert_equal('added more', getline('$'))
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
125
7933
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
126 " Send a request with a specific handler.
8094
18a3f0f05244 commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents: 8084
diff changeset
127 call ch_sendexpr(handle, 'hello!', {'callback': 's:RequestHandler'})
7933
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
128 sleep 10m
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
129 if !exists('s:responseHandle')
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
130 call assert_false(1, 's:responseHandle was not set')
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
131 else
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
132 call assert_equal(handle, s:responseHandle)
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
133 endif
7933
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
134 call assert_equal('got it', s:responseMsg)
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
135
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
136 unlet s:responseHandle
8017
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
137 let s:responseMsg = ''
8094
18a3f0f05244 commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents: 8084
diff changeset
138 call ch_sendexpr(handle, 'hello!', {'callback': function('s:RequestHandler')})
8017
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
139 sleep 10m
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
140 if !exists('s:responseHandle')
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
141 call assert_false(1, 's:responseHandle was not set')
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
142 else
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
143 call assert_equal(handle, s:responseHandle)
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
144 endif
8017
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
145 call assert_equal('got it', s:responseMsg)
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
146
8124
310dd635e8c9 commit https://github.com/vim/vim/commit/40ea1da14ba196a23309789852e1b663fd92e3a8
Christian Brabandt <cb@256bit.org>
parents: 8118
diff changeset
147 " check setting options (without testing the effect)
310dd635e8c9 commit https://github.com/vim/vim/commit/40ea1da14ba196a23309789852e1b663fd92e3a8
Christian Brabandt <cb@256bit.org>
parents: 8118
diff changeset
148 call ch_setoptions(handle, {'callback': 's:NotUsed'})
8130
3462f9cfedf8 commit https://github.com/vim/vim/commit/1f6ef66254c1e25ef1c7972aa9a0ba119ebc17e4
Christian Brabandt <cb@256bit.org>
parents: 8124
diff changeset
149 call ch_setoptions(handle, {'timeout': 1111})
8124
310dd635e8c9 commit https://github.com/vim/vim/commit/40ea1da14ba196a23309789852e1b663fd92e3a8
Christian Brabandt <cb@256bit.org>
parents: 8118
diff changeset
150 call assert_fails("call ch_setoptions(handle, {'waittime': 111})", "E475")
310dd635e8c9 commit https://github.com/vim/vim/commit/40ea1da14ba196a23309789852e1b663fd92e3a8
Christian Brabandt <cb@256bit.org>
parents: 8118
diff changeset
151 call assert_fails("call ch_setoptions(handle, {'mode': 'json'})", "E475")
310dd635e8c9 commit https://github.com/vim/vim/commit/40ea1da14ba196a23309789852e1b663fd92e3a8
Christian Brabandt <cb@256bit.org>
parents: 8118
diff changeset
152
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
153 " Send an eval request that works.
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
154 call assert_equal('ok', ch_sendexpr(handle, 'eval-works'))
7925
b724dbb299d5 commit https://github.com/vim/vim/commit/a02b321686d9827ac806353ea8af780676da340d
Christian Brabandt <cb@256bit.org>
parents: 7922
diff changeset
155 sleep 10m
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
156 call assert_equal([-1, 'foo123'], ch_sendexpr(handle, 'eval-result'))
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
157
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
158 " Send an eval request that fails.
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
159 call assert_equal('ok', ch_sendexpr(handle, 'eval-fails'))
7925
b724dbb299d5 commit https://github.com/vim/vim/commit/a02b321686d9827ac806353ea8af780676da340d
Christian Brabandt <cb@256bit.org>
parents: 7922
diff changeset
160 sleep 10m
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
161 call assert_equal([-2, 'ERROR'], ch_sendexpr(handle, 'eval-result'))
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
162
7965
646d5148fee2 commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents: 7957
diff changeset
163 " Send an eval request that works but can't be encoded.
646d5148fee2 commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents: 7957
diff changeset
164 call assert_equal('ok', ch_sendexpr(handle, 'eval-error'))
646d5148fee2 commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents: 7957
diff changeset
165 sleep 10m
646d5148fee2 commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents: 7957
diff changeset
166 call assert_equal([-3, 'ERROR'], ch_sendexpr(handle, 'eval-result'))
646d5148fee2 commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents: 7957
diff changeset
167
7918
ce5a7a613867 commit https://github.com/vim/vim/commit/66624ff0d9e1de2fc5eb4f95f3a3a2ed70b10138
Christian Brabandt <cb@256bit.org>
parents: 7916
diff changeset
168 " Send a bad eval request. There will be no response.
ce5a7a613867 commit https://github.com/vim/vim/commit/66624ff0d9e1de2fc5eb4f95f3a3a2ed70b10138
Christian Brabandt <cb@256bit.org>
parents: 7916
diff changeset
169 call assert_equal('ok', ch_sendexpr(handle, 'eval-bad'))
7925
b724dbb299d5 commit https://github.com/vim/vim/commit/a02b321686d9827ac806353ea8af780676da340d
Christian Brabandt <cb@256bit.org>
parents: 7922
diff changeset
170 sleep 10m
7965
646d5148fee2 commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents: 7957
diff changeset
171 call assert_equal([-3, 'ERROR'], ch_sendexpr(handle, 'eval-result'))
7918
ce5a7a613867 commit https://github.com/vim/vim/commit/66624ff0d9e1de2fc5eb4f95f3a3a2ed70b10138
Christian Brabandt <cb@256bit.org>
parents: 7916
diff changeset
172
7939
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
173 " Send an expr request
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
174 call assert_equal('ok', ch_sendexpr(handle, 'an expr'))
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
175 sleep 10m
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
176 call assert_equal('one', getline(line('$') - 2))
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
177 call assert_equal('two', getline(line('$') - 1))
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
178 call assert_equal('three', getline('$'))
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
179
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
180 " Request a redraw, we don't check for the effect.
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
181 call assert_equal('ok', ch_sendexpr(handle, 'redraw'))
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
182 call assert_equal('ok', ch_sendexpr(handle, 'redraw!'))
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
183
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
184 call assert_equal('ok', ch_sendexpr(handle, 'empty-request'))
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
185
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 " make the server quit, can't check if this works, should not hang.
8094
18a3f0f05244 commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents: 8084
diff changeset
187 call ch_sendexpr(handle, '!quit!', {'callback': 0})
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
188 endfunc
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
190 func Test_communicate()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
191 call ch_log('Test_communicate()')
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
192 call s:run_server('s:communicate')
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 endfunc
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
194
7916
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
195 " Test that we can open two channels.
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
196 func s:two_channels(port)
8013
dfae8bce5920 commit https://github.com/vim/vim/commit/39b21272d521512b6ecac6cc0f310944f21b7443
Christian Brabandt <cb@256bit.org>
parents: 8009
diff changeset
197 let handle = ch_open('localhost:' . a:port, s:chopt)
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
198 if ch_status(handle) == "fail"
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
199 call assert_false(1, "Can't open channel")
7916
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
200 return
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
201 endif
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
202
7916
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
203 call assert_equal('got it', ch_sendexpr(handle, 'hello!'))
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
204
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
205 let newhandle = ch_open('localhost:' . a:port, s:chopt)
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
206 if ch_status(newhandle) == "fail"
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
207 call assert_false(1, "Can't open second channel")
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
208 return
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
209 endif
7916
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
210 call assert_equal('got it', ch_sendexpr(newhandle, 'hello!'))
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
211 call assert_equal('got it', ch_sendexpr(handle, 'hello!'))
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
212
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
213 call ch_close(handle)
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
214 call assert_equal('got it', ch_sendexpr(newhandle, 'hello!'))
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
215
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
216 call ch_close(newhandle)
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
217 endfunc
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
218
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
219 func Test_two_channels()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
220 call ch_log('Test_two_channels()')
8037
9dea1571b352 commit https://github.com/vim/vim/commit/bfa1ffca8bcce92c030d8366036a316954f1ee69
Christian Brabandt <cb@256bit.org>
parents: 8031
diff changeset
221 call s:run_server('s:two_channels')
7916
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
222 endfunc
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
223
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
224 " Test that a server crash is handled gracefully.
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
225 func s:server_crash(port)
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
226 let handle = ch_open('localhost:' . a:port, s:chopt)
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
227 if ch_status(handle) == "fail"
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
228 call assert_false(1, "Can't open channel")
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
229 return
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
230 endif
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
231
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
232 call ch_sendexpr(handle, '!crash!')
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
233
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
234 sleep 10m
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
235 endfunc
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
236
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
237 func Test_server_crash()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
238 call ch_log('Test_server_crash()')
8037
9dea1571b352 commit https://github.com/vim/vim/commit/bfa1ffca8bcce92c030d8366036a316954f1ee69
Christian Brabandt <cb@256bit.org>
parents: 8031
diff changeset
239 call s:run_server('s:server_crash')
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
240 endfunc
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
241
8009
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
242 let s:reply = ""
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
243 func s:Handler(chan, msg)
8017
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
244 unlet s:reply
8009
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
245 let s:reply = a:msg
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
246 endfunc
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
247
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
248 func s:channel_handler(port)
8017
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
249 let handle = ch_open('localhost:' . a:port, s:chopt)
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
250 if ch_status(handle) == "fail"
8009
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
251 call assert_false(1, "Can't open channel")
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
252 return
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
253 endif
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
254
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
255 " Test that it works while waiting on a numbered message.
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
256 call assert_equal('ok', ch_sendexpr(handle, 'call me'))
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
257 sleep 10m
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
258 call assert_equal('we called you', s:reply)
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
259
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
260 " Test that it works while not waiting on a numbered message.
8094
18a3f0f05244 commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents: 8084
diff changeset
261 call ch_sendexpr(handle, 'call me again', {'callback': 0})
8009
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
262 sleep 10m
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
263 call assert_equal('we did call you', s:reply)
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
264 endfunc
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
265
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
266 func Test_channel_handler()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
267 call ch_log('Test_channel_handler()')
8017
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
268 let s:chopt.callback = 's:Handler'
8009
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
269 call s:run_server('s:channel_handler')
8017
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
270 let s:chopt.callback = function('s:Handler')
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
271 call s:run_server('s:channel_handler')
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
272 unlet s:chopt.callback
8009
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
273 endfunc
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
274
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
275 " Test that trying to connect to a non-existing port fails quickly.
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
276 func Test_connect_waittime()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
277 call ch_log('Test_connect_waittime()')
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
278 let start = reltime()
8005
d65aa95725d3 commit https://github.com/vim/vim/commit/a483326e3b04215b86fe9c582ac96bb9679f0812
Christian Brabandt <cb@256bit.org>
parents: 7988
diff changeset
279 let handle = ch_open('localhost:9876', s:chopt)
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
280 if ch_status(handle) != "fail"
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
281 " Oops, port does exists.
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
282 call ch_close(handle)
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
283 else
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
284 let elapsed = reltime(start)
7984
c166ff6797cb commit https://github.com/vim/vim/commit/74f5e65bcc3d77ab879f56eb977f5038edccbcf8
Christian Brabandt <cb@256bit.org>
parents: 7982
diff changeset
285 call assert_true(reltimefloat(elapsed) < 1.0)
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
286 endif
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
287
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
288 let start = reltime()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
289 let handle = ch_open('localhost:9867', {'waittime': 500})
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
290 if ch_status(handle) != "fail"
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
291 " Oops, port does exists.
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
292 call ch_close(handle)
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
293 else
7988
d3fed9a639db commit https://github.com/vim/vim/commit/0fa98e7b85b52c63611b2fe8e370f0aa1c8f6dc9
Christian Brabandt <cb@256bit.org>
parents: 7984
diff changeset
294 " Failed connection doesn't wait the full time on Unix.
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
295 " TODO: why is MS-Windows different?
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
296 let elapsed = reltime(start)
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
297 call assert_true(reltimefloat(elapsed) < 1.0)
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
298 endif
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
299 endfunc
8031
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
300
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
301 func Test_raw_pipe()
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
302 if !has('job')
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
303 return
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
304 endif
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
305 call ch_log('Test_raw_pipe()')
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
306 let job = job_start(s:python . " test_channel_pipe.py", {'mode': 'raw'})
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
307 call assert_equal("run", job_status(job))
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
308 try
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
309 let handle = job_getchannel(job)
8094
18a3f0f05244 commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents: 8084
diff changeset
310 call ch_sendraw(handle, "echo something\n", {'callback': 0})
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
311 let msg = ch_readraw(handle)
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
312 call assert_equal("something\n", substitute(msg, "\r", "", 'g'))
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
313
8094
18a3f0f05244 commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents: 8084
diff changeset
314 call ch_sendraw(handle, "double this\n", {'callback': 0})
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
315 let msg = ch_readraw(handle)
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
316 call assert_equal("this\nAND this\n", substitute(msg, "\r", "", 'g'))
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
317
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
318 let reply = ch_sendraw(handle, "quit\n")
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
319 call assert_equal("Goodbye!\n", substitute(reply, "\r", "", 'g'))
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
320 finally
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
321 call job_stop(job)
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
322 endtry
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
323 endfunc
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
324
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
325 func Test_nl_pipe()
8059
19304db153bc commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents: 8055
diff changeset
326 if !has('job')
8031
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
327 return
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
328 endif
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
329 call ch_log('Test_nl_pipe()')
8066
1aa8ed4ee48b commit https://github.com/vim/vim/commit/b6a7737938e7e7b34f862f58aa5498e6f652e33d
Christian Brabandt <cb@256bit.org>
parents: 8059
diff changeset
330 let job = job_start(s:python . " test_channel_pipe.py")
8031
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
331 call assert_equal("run", job_status(job))
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
332 try
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
333 let handle = job_getchannel(job)
8094
18a3f0f05244 commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents: 8084
diff changeset
334 call ch_sendraw(handle, "echo something\n", {'callback': 0})
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
335 call assert_equal("something", ch_readraw(handle))
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
336
8094
18a3f0f05244 commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents: 8084
diff changeset
337 call ch_sendraw(handle, "double this\n", {'callback': 0})
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
338 call assert_equal("this", ch_readraw(handle))
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
339 call assert_equal("AND this", ch_readraw(handle))
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
340
8031
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
341 let reply = ch_sendraw(handle, "quit\n")
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
342 call assert_equal("Goodbye!", reply)
8031
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
343 finally
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
344 call job_stop(job)
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
345 endtry
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
346 endfunc
8055
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
347
8074
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
348 """"""""""
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
349
8055
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
350 let s:unletResponse = ''
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
351 func s:UnletHandler(handle, msg)
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
352 let s:unletResponse = a:msg
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
353 unlet s:channelfd
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
354 endfunc
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
355
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
356 " Test that "unlet handle" in a handler doesn't crash Vim.
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
357 func s:unlet_handle(port)
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
358 let s:channelfd = ch_open('localhost:' . a:port, s:chopt)
8094
18a3f0f05244 commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents: 8084
diff changeset
359 call ch_sendexpr(s:channelfd, "test", {'callback': function('s:UnletHandler')})
8055
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
360 sleep 10m
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
361 call assert_equal('what?', s:unletResponse)
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
362 endfunc
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
363
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
364 func Test_unlet_handle()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
365 call ch_log('Test_unlet_handle()')
8055
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
366 call s:run_server('s:unlet_handle')
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
367 endfunc
8070
e4c3f6720b03 commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents: 8066
diff changeset
368
8074
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
369 """"""""""
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
370
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
371 let s:unletResponse = ''
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
372 func s:CloseHandler(handle, msg)
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
373 let s:unletResponse = a:msg
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
374 call ch_close(s:channelfd)
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
375 endfunc
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
376
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
377 " Test that "unlet handle" in a handler doesn't crash Vim.
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
378 func s:close_handle(port)
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
379 let s:channelfd = ch_open('localhost:' . a:port, s:chopt)
8094
18a3f0f05244 commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents: 8084
diff changeset
380 call ch_sendexpr(s:channelfd, "test", {'callback': function('s:CloseHandler')})
8074
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
381 sleep 10m
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
382 call assert_equal('what?', s:unletResponse)
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
383 endfunc
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
384
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
385 func Test_close_handle()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
386 call ch_log('Test_close_handle()')
8074
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
387 call s:run_server('s:close_handle')
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
388 endfunc
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
389
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
390 """"""""""
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
391
8070
e4c3f6720b03 commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents: 8066
diff changeset
392 func Test_open_fail()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
393 call ch_log('Test_open_fail()')
8070
e4c3f6720b03 commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents: 8066
diff changeset
394 silent! let ch = ch_open("noserver")
e4c3f6720b03 commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents: 8066
diff changeset
395 echo ch
e4c3f6720b03 commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents: 8066
diff changeset
396 let d = ch
e4c3f6720b03 commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents: 8066
diff changeset
397 endfunc
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
398
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
399 """"""""""
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
400
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
401 func s:open_delay(port)
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
402 " Wait up to a second for the port to open.
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
403 let s:chopt.waittime = 1000
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
404 let channel = ch_open('localhost:' . a:port, s:chopt)
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
405 unlet s:chopt.waittime
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
406 if ch_status(channel) == "fail"
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
407 call assert_false(1, "Can't open channel")
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
408 return
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
409 endif
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
410 call assert_equal('got it', ch_sendexpr(channel, 'hello!'))
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
411 call ch_close(channel)
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
412 endfunc
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
413
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
414 func Test_open_delay()
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
415 call ch_log('Test_open_delay()')
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
416 " The server will wait half a second before creating the port.
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
417 call s:run_server('s:open_delay', 'delay')
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
418 endfunc