annotate src/testdir/test_channel.vim @ 8653:d80edead9675 v7.4.1616

commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 20 14:31:00 2016 +0100 patch 7.4.1616 Problem: Malformed channel request causes a hang. Solution: Drop malformed message. (Damien)
author Christian Brabandt <cb@256bit.org>
date Sun, 20 Mar 2016 14:45:04 +0100
parents fec8655cf1bf
children 1eb302bf2475
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')
8170
a0ffb1f3dedc commit https://github.com/vim/vim/commit/65edff8f51e9e54f85407bdb9156ae8e3e1b76a1
Christian Brabandt <cb@256bit.org>
parents: 8168
diff changeset
47 let s:job = job_start(cmd, {"stoponexit": "hup"})
a0ffb1f3dedc commit https://github.com/vim/vim/commit/65edff8f51e9e54f85407bdb9156ae8e3e1b76a1
Christian Brabandt <cb@256bit.org>
parents: 8168
diff changeset
48 call job_setoptions(s:job, {"stoponexit": "kill"})
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
49 elseif has('win32')
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
50 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
51 else
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
52 exe 'silent !' . cmd . '&'
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
53 endif
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
55 " 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
56 let l = []
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
57 for i in range(200)
8007
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
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
65 sleep 10m
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
66 endfor
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
67 call delete("Xportnr")
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
68
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
69 if len(l) == 0
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
70 " 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
71 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
72 return -1
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 endif
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
74 let port = l[0]
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
76 call call(function(a:testfunc), [port])
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
77 catch
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
78 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
79 finally
7902
f12d6235a753 commit https://github.com/vim/vim/commit/a0f9cd148eaab23b2037d2f543f3b8f5a3a7ad3c
Christian Brabandt <cb@256bit.org>
parents: 7899
diff changeset
80 call s:kill_server()
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
81 endtry
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
82 endfunc
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
83
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
84 func s:kill_server()
7957
b74549818500 commit https://github.com/vim/vim/commit/835dc636a5350f610b62f110227d2363b5b2880a
Christian Brabandt <cb@256bit.org>
parents: 7939
diff changeset
85 if has('job')
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
86 if exists('s:job')
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
87 call job_stop(s:job)
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
88 unlet s:job
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
89 endif
7957
b74549818500 commit https://github.com/vim/vim/commit/835dc636a5350f610b62f110227d2363b5b2880a
Christian Brabandt <cb@256bit.org>
parents: 7939
diff changeset
90 elseif has('win32')
8066
1aa8ed4ee48b commit https://github.com/vim/vim/commit/b6a7737938e7e7b34f862f58aa5498e6f652e33d
Christian Brabandt <cb@256bit.org>
parents: 8059
diff changeset
91 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
92 else
7914
35973ce58c84 commit https://github.com/vim/vim/commit/608a8919cae982cb38e38725a843df47b234dae6
Christian Brabandt <cb@256bit.org>
parents: 7906
diff changeset
93 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
94 endif
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
95 endfunc
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
96
7933
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
97 let s:responseMsg = ''
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
98 func s:RequestHandler(handle, msg)
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
99 let s:responseHandle = a:handle
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
100 let s:responseMsg = a:msg
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
101 endfunc
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
102
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
103 " Wait for up to a second for "expr" to become true.
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
104 func s:waitFor(expr)
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
105 for i in range(100)
8459
9fb171e8466d commit https://github.com/vim/vim/commit/d9d473ea124339c4dd173127db47c4583645ac2c
Christian Brabandt <cb@256bit.org>
parents: 8457
diff changeset
106 try
9fb171e8466d commit https://github.com/vim/vim/commit/d9d473ea124339c4dd173127db47c4583645ac2c
Christian Brabandt <cb@256bit.org>
parents: 8457
diff changeset
107 if eval(a:expr)
9fb171e8466d commit https://github.com/vim/vim/commit/d9d473ea124339c4dd173127db47c4583645ac2c
Christian Brabandt <cb@256bit.org>
parents: 8457
diff changeset
108 return
9fb171e8466d commit https://github.com/vim/vim/commit/d9d473ea124339c4dd173127db47c4583645ac2c
Christian Brabandt <cb@256bit.org>
parents: 8457
diff changeset
109 endif
9fb171e8466d commit https://github.com/vim/vim/commit/d9d473ea124339c4dd173127db47c4583645ac2c
Christian Brabandt <cb@256bit.org>
parents: 8457
diff changeset
110 catch
9fb171e8466d commit https://github.com/vim/vim/commit/d9d473ea124339c4dd173127db47c4583645ac2c
Christian Brabandt <cb@256bit.org>
parents: 8457
diff changeset
111 endtry
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
112 sleep 10m
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
113 endfor
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
114 endfunc
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
115
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
116 func s:communicate(port)
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
117 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
118 if ch_status(handle) == "fail"
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
119 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
120 return
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 endif
8424
be45d4921f1f commit https://github.com/vim/vim/commit/839fd11d7ed1a96bace3159c4d1861658864aae3
Christian Brabandt <cb@256bit.org>
parents: 8420
diff changeset
122 if has('job')
be45d4921f1f commit https://github.com/vim/vim/commit/839fd11d7ed1a96bace3159c4d1861658864aae3
Christian Brabandt <cb@256bit.org>
parents: 8420
diff changeset
123 " check that no job is handled correctly
be45d4921f1f commit https://github.com/vim/vim/commit/839fd11d7ed1a96bace3159c4d1861658864aae3
Christian Brabandt <cb@256bit.org>
parents: 8420
diff changeset
124 call assert_equal('no process', string(ch_getjob(handle)))
be45d4921f1f commit https://github.com/vim/vim/commit/839fd11d7ed1a96bace3159c4d1861658864aae3
Christian Brabandt <cb@256bit.org>
parents: 8420
diff changeset
125 endif
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
126 " Simple string request and reply.
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
127 call assert_equal('got it', ch_evalexpr(handle, 'hello!'))
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
128
8653
d80edead9675 commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents: 8540
diff changeset
129 " Malformed command should be ignored.
d80edead9675 commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents: 8540
diff changeset
130 call assert_equal('ok', ch_evalexpr(handle, 'malformed'))
d80edead9675 commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents: 8540
diff changeset
131
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 " 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
133 " 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
134 " tiny bit for the commands to get executed.
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
135 call assert_equal('ok', ch_evalexpr(handle, 'make change'))
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
136 call s:waitFor('"added2" == getline("$")')
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 call assert_equal('added1', getline(line('$') - 1))
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 call assert_equal('added2', getline('$'))
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139
8380
892d7dcf17ec commit https://github.com/vim/vim/commit/da94fdf2588b3910d38e477a755748ce2c6d2e66
Christian Brabandt <cb@256bit.org>
parents: 8346
diff changeset
140 call assert_equal('ok', ch_evalexpr(handle, 'do normal', {'timeout': 100}))
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
141 call s:waitFor('"added more" == getline("$")')
7939
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
142 call assert_equal('added more', getline('$'))
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
143
7933
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
144 " 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
145 call ch_sendexpr(handle, 'hello!', {'callback': 's:RequestHandler'})
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
146 call s:waitFor('exists("s:responseHandle")')
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
147 if !exists('s:responseHandle')
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
148 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
149 else
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
150 call assert_equal(handle, s:responseHandle)
8222
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8210
diff changeset
151 unlet s:responseHandle
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
152 endif
7933
1f0743f4f88f commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents: 7929
diff changeset
153 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
154
8017
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
155 let s:responseMsg = ''
8094
18a3f0f05244 commit https://github.com/vim/vim/commit/910b8aac5dc4693c4508b7acd2cef0bbfac04242
Christian Brabandt <cb@256bit.org>
parents: 8084
diff changeset
156 call ch_sendexpr(handle, 'hello!', {'callback': function('s:RequestHandler')})
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
157 call s:waitFor('exists("s:responseHandle")')
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
158 if !exists('s:responseHandle')
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
159 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
160 else
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
161 call assert_equal(handle, s:responseHandle)
8222
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8210
diff changeset
162 unlet s:responseHandle
8041
c6443e78cf2d commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents: 8037
diff changeset
163 endif
8017
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
164 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
165
8420
f6d21a33d489 commit https://github.com/vim/vim/commit/38fd4bb2842df7634823b99c655b3896a7a2e988
Christian Brabandt <cb@256bit.org>
parents: 8404
diff changeset
166 " Collect garbage, tests that our handle isn't collected.
f6d21a33d489 commit https://github.com/vim/vim/commit/38fd4bb2842df7634823b99c655b3896a7a2e988
Christian Brabandt <cb@256bit.org>
parents: 8404
diff changeset
167 call garbagecollect()
f6d21a33d489 commit https://github.com/vim/vim/commit/38fd4bb2842df7634823b99c655b3896a7a2e988
Christian Brabandt <cb@256bit.org>
parents: 8404
diff changeset
168
8124
310dd635e8c9 commit https://github.com/vim/vim/commit/40ea1da14ba196a23309789852e1b663fd92e3a8
Christian Brabandt <cb@256bit.org>
parents: 8118
diff changeset
169 " 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
170 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
171 call ch_setoptions(handle, {'timeout': 1111})
8165
973686665238 commit https://github.com/vim/vim/commit/b6b5252bcde68b296858bc090cb424493635dfec
Christian Brabandt <cb@256bit.org>
parents: 8161
diff changeset
172 call ch_setoptions(handle, {'mode': 'json'})
8124
310dd635e8c9 commit https://github.com/vim/vim/commit/40ea1da14ba196a23309789852e1b663fd92e3a8
Christian Brabandt <cb@256bit.org>
parents: 8118
diff changeset
173 call assert_fails("call ch_setoptions(handle, {'waittime': 111})", "E475")
8132
f96536c291d8 commit https://github.com/vim/vim/commit/0ba75a9714884895b2ac09733158c47544a8dfb9
Christian Brabandt <cb@256bit.org>
parents: 8130
diff changeset
174 call ch_setoptions(handle, {'callback': ''})
8124
310dd635e8c9 commit https://github.com/vim/vim/commit/40ea1da14ba196a23309789852e1b663fd92e3a8
Christian Brabandt <cb@256bit.org>
parents: 8118
diff changeset
175
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
176 " Send an eval request that works.
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
177 call assert_equal('ok', ch_evalexpr(handle, 'eval-works'))
7925
b724dbb299d5 commit https://github.com/vim/vim/commit/a02b321686d9827ac806353ea8af780676da340d
Christian Brabandt <cb@256bit.org>
parents: 7922
diff changeset
178 sleep 10m
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
179 call assert_equal([-1, 'foo123'], ch_evalexpr(handle, 'eval-result'))
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
180
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
181 " Send an eval request that fails.
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
182 call assert_equal('ok', ch_evalexpr(handle, 'eval-fails'))
7925
b724dbb299d5 commit https://github.com/vim/vim/commit/a02b321686d9827ac806353ea8af780676da340d
Christian Brabandt <cb@256bit.org>
parents: 7922
diff changeset
183 sleep 10m
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
184 call assert_equal([-2, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
185
7965
646d5148fee2 commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents: 7957
diff changeset
186 " Send an eval request that works but can't be encoded.
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
187 call assert_equal('ok', ch_evalexpr(handle, 'eval-error'))
7965
646d5148fee2 commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents: 7957
diff changeset
188 sleep 10m
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
189 call assert_equal([-3, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
7965
646d5148fee2 commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents: 7957
diff changeset
190
7918
ce5a7a613867 commit https://github.com/vim/vim/commit/66624ff0d9e1de2fc5eb4f95f3a3a2ed70b10138
Christian Brabandt <cb@256bit.org>
parents: 7916
diff changeset
191 " Send a bad eval request. There will be no response.
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
192 call assert_equal('ok', ch_evalexpr(handle, 'eval-bad'))
7925
b724dbb299d5 commit https://github.com/vim/vim/commit/a02b321686d9827ac806353ea8af780676da340d
Christian Brabandt <cb@256bit.org>
parents: 7922
diff changeset
193 sleep 10m
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
194 call assert_equal([-3, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
7918
ce5a7a613867 commit https://github.com/vim/vim/commit/66624ff0d9e1de2fc5eb4f95f3a3a2ed70b10138
Christian Brabandt <cb@256bit.org>
parents: 7916
diff changeset
195
7939
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
196 " Send an expr request
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
197 call assert_equal('ok', ch_evalexpr(handle, 'an expr'))
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
198 call s:waitFor('"three" == getline("$")')
7939
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
199 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
200 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
201 call assert_equal('three', getline('$'))
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
202
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
203 " Request a redraw, we don't check for the effect.
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
204 call assert_equal('ok', ch_evalexpr(handle, 'redraw'))
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
205 call assert_equal('ok', ch_evalexpr(handle, 'redraw!'))
7939
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
206
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
207 call assert_equal('ok', ch_evalexpr(handle, 'empty-request'))
7939
dcc0bd6b1574 commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents: 7935
diff changeset
208
8157
74b44d06d3c7 commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents: 8132
diff changeset
209 " Reading while there is nothing available.
8222
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8210
diff changeset
210 call assert_equal(v:none, ch_read(handle, {'timeout': 0}))
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8210
diff changeset
211 let start = reltime()
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8210
diff changeset
212 call assert_equal(v:none, ch_read(handle, {'timeout': 333}))
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8210
diff changeset
213 let elapsed = reltime(start)
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8210
diff changeset
214 call assert_true(reltimefloat(elapsed) > 0.3)
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8210
diff changeset
215 call assert_true(reltimefloat(elapsed) < 0.6)
8157
74b44d06d3c7 commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents: 8132
diff changeset
216
74b44d06d3c7 commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents: 8132
diff changeset
217 " Send without waiting for a response, then wait for a response.
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
218 call ch_sendexpr(handle, 'wait a bit')
8157
74b44d06d3c7 commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents: 8132
diff changeset
219 let resp = ch_read(handle)
74b44d06d3c7 commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents: 8132
diff changeset
220 call assert_equal(type([]), type(resp))
74b44d06d3c7 commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents: 8132
diff changeset
221 call assert_equal(type(11), type(resp[0]))
74b44d06d3c7 commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents: 8132
diff changeset
222 call assert_equal('waited', resp[1])
74b44d06d3c7 commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents: 8132
diff changeset
223
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 " make the server quit, can't check if this works, should not hang.
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
225 call ch_sendexpr(handle, '!quit!')
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
226 endfunc
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
228 func Test_communicate()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
229 call ch_log('Test_communicate()')
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
230 call s:run_server('s:communicate')
7899
93c61501c2cf commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 endfunc
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
232
7916
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
233 " 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
234 func s:two_channels(port)
8013
dfae8bce5920 commit https://github.com/vim/vim/commit/39b21272d521512b6ecac6cc0f310944f21b7443
Christian Brabandt <cb@256bit.org>
parents: 8009
diff changeset
235 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
236 if ch_status(handle) == "fail"
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
237 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
238 return
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
239 endif
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
240
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
241 call assert_equal('got it', ch_evalexpr(handle, 'hello!'))
7916
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
242
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
243 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
244 if ch_status(newhandle) == "fail"
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
245 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
246 return
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
247 endif
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
248 call assert_equal('got it', ch_evalexpr(newhandle, 'hello!'))
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
249 call assert_equal('got it', ch_evalexpr(handle, 'hello!'))
7916
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
250
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
251 call ch_close(handle)
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
252 call assert_equal('got it', ch_evalexpr(newhandle, 'hello!'))
7916
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
253
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
254 call ch_close(newhandle)
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
255 endfunc
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
256
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
257 func Test_two_channels()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
258 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
259 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
260 endfunc
54602dcac207 commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents: 7914
diff changeset
261
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
262 " 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
263 func s:server_crash(port)
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
264 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
265 if ch_status(handle) == "fail"
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
266 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
267 return
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
268 endif
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
269
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
270 call ch_evalexpr(handle, '!crash!')
7906
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
271
ea1fd8d750a6 commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents: 7904
diff changeset
272 sleep 10m
8007
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
273 endfunc
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
274
ac78cba9e72b commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents: 8005
diff changeset
275 func Test_server_crash()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
276 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
277 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
278 endfunc
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
279
8382
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
280 """""""""
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
281
8009
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
282 let s:reply = ""
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
283 func s:Handler(chan, msg)
8017
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
284 unlet s:reply
8009
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
285 let s:reply = a:msg
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
286 endfunc
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
287
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
288 func s:channel_handler(port)
8017
c59a65524084 commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents: 8013
diff changeset
289 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
290 if ch_status(handle) == "fail"
8009
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
291 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
292 return
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
293 endif
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
294
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
295 " Test that it works while waiting on a numbered message.
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
296 call assert_equal('ok', ch_evalexpr(handle, 'call me'))
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
297 call s:waitFor('"we called you" == s:reply')
8009
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
298 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
299
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
300 " Test that it works while not waiting on a numbered message.
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
301 call ch_sendexpr(handle, 'call me again')
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
302 call s:waitFor('"we did call you" == s:reply')
8009
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
303 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
304 endfunc
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
305
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
306 func Test_channel_handler()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
307 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
308 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
309 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
310 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
311 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
312 unlet s:chopt.callback
8009
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
313 endfunc
b2cfa3416ba0 commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents: 8007
diff changeset
314
8382
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
315 """""""""
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
316
8404
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
317 let s:ch_reply = ''
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
318 func s:ChHandler(chan, msg)
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
319 unlet s:ch_reply
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
320 let s:ch_reply = a:msg
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
321 endfunc
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
322
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
323 let s:zero_reply = ''
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
324 func s:OneHandler(chan, msg)
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
325 unlet s:zero_reply
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
326 let s:zero_reply = a:msg
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
327 endfunc
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
328
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
329 func s:channel_zero(port)
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
330 let handle = ch_open('localhost:' . a:port, s:chopt)
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
331 if ch_status(handle) == "fail"
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
332 call assert_false(1, "Can't open channel")
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
333 return
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
334 endif
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
335
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
336 " Check that eval works.
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
337 call assert_equal('got it', ch_evalexpr(handle, 'hello!'))
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
338
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
339 " Check that eval works if a zero id message is sent back.
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
340 let s:ch_reply = ''
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
341 call assert_equal('sent zero', ch_evalexpr(handle, 'send zero'))
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
342 if s:has_handler
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
343 call s:waitFor('"zero index" == s:ch_reply')
8404
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
344 call assert_equal('zero index', s:ch_reply)
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
345 else
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
346 sleep 20m
8404
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
347 call assert_equal('', s:ch_reply)
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
348 endif
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
349
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
350 " Check that handler works if a zero id message is sent back.
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
351 let s:ch_reply = ''
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
352 let s:zero_reply = ''
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
353 call ch_sendexpr(handle, 'send zero', {'callback': 's:OneHandler'})
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
354 call s:waitFor('"sent zero" == s:zero_reply')
8404
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
355 if s:has_handler
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
356 call assert_equal('zero index', s:ch_reply)
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
357 else
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
358 call assert_equal('', s:ch_reply)
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
359 endif
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
360 call assert_equal('sent zero', s:zero_reply)
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
361 endfunc
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
362
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
363 func Test_zero_reply()
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
364 call ch_log('Test_zero_reply()')
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
365 " Run with channel handler
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
366 let s:has_handler = 1
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
367 let s:chopt.callback = 's:ChHandler'
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
368 call s:run_server('s:channel_zero')
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
369 unlet s:chopt.callback
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
370
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
371 " Run without channel handler
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
372 let s:has_handler = 0
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
373 call s:run_server('s:channel_zero')
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
374 endfunc
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
375
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
376 """""""""
8894d595b786 commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents: 8386
diff changeset
377
8382
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
378 let s:reply1 = ""
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
379 func s:HandleRaw1(chan, msg)
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
380 unlet s:reply1
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
381 let s:reply1 = a:msg
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
382 endfunc
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
383
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
384 let s:reply2 = ""
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
385 func s:HandleRaw2(chan, msg)
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
386 unlet s:reply2
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
387 let s:reply2 = a:msg
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
388 endfunc
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
389
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
390 let s:reply3 = ""
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
391 func s:HandleRaw3(chan, msg)
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
392 unlet s:reply3
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
393 let s:reply3 = a:msg
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
394 endfunc
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
395
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
396 func s:raw_one_time_callback(port)
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
397 let handle = ch_open('localhost:' . a:port, s:chopt)
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
398 if ch_status(handle) == "fail"
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
399 call assert_false(1, "Can't open channel")
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
400 return
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
401 endif
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
402 call ch_setoptions(handle, {'mode': 'raw'})
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
403
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
404 " The message are sent raw, we do our own JSON strings here.
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
405 call ch_sendraw(handle, "[1, \"hello!\"]", {'callback': 's:HandleRaw1'})
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
406 call s:waitFor('s:reply1 != ""')
8382
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
407 call assert_equal("[1, \"got it\"]", s:reply1)
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
408 call ch_sendraw(handle, "[2, \"echo something\"]", {'callback': 's:HandleRaw2'})
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
409 call ch_sendraw(handle, "[3, \"wait a bit\"]", {'callback': 's:HandleRaw3'})
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
410 call s:waitFor('s:reply2 != ""')
8382
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
411 call assert_equal("[2, \"something\"]", s:reply2)
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
412 " wait for the 200 msec delayed reply
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
413 call s:waitFor('s:reply3 != ""')
8382
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
414 call assert_equal("[3, \"waited\"]", s:reply3)
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
415 endfunc
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
416
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
417 func Test_raw_one_time_callback()
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
418 call ch_log('Test_raw_one_time_callback()')
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
419 call s:run_server('s:raw_one_time_callback')
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
420 endfunc
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
421
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
422 """""""""
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
423
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
424 " 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
425 func Test_connect_waittime()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
426 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
427 let start = reltime()
8005
d65aa95725d3 commit https://github.com/vim/vim/commit/a483326e3b04215b86fe9c582ac96bb9679f0812
Christian Brabandt <cb@256bit.org>
parents: 7988
diff changeset
428 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
429 if ch_status(handle) != "fail"
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
430 " Oops, port does exists.
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
431 call ch_close(handle)
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
432 else
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
433 let elapsed = reltime(start)
7984
c166ff6797cb commit https://github.com/vim/vim/commit/74f5e65bcc3d77ab879f56eb977f5038edccbcf8
Christian Brabandt <cb@256bit.org>
parents: 7982
diff changeset
434 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
435 endif
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
436
8168
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
437 " We intend to use a socket that doesn't exist and wait for half a second
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
438 " before giving up. If the socket does exist it can fail in various ways.
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
439 " Check for "Connection reset by peer" to avoid flakyness.
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
440 let start = reltime()
8168
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
441 try
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
442 let handle = ch_open('localhost:9867', {'waittime': 500})
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
443 if ch_status(handle) != "fail"
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
444 " Oops, port does exists.
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
445 call ch_close(handle)
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
446 else
8500
1227dc21865b commit https://github.com/vim/vim/commit/ac42afd10b96424b89762871905e3e785cdfba3d
Christian Brabandt <cb@256bit.org>
parents: 8491
diff changeset
447 " Failed connection should wait about 500 msec. Can be longer if the
1227dc21865b commit https://github.com/vim/vim/commit/ac42afd10b96424b89762871905e3e785cdfba3d
Christian Brabandt <cb@256bit.org>
parents: 8491
diff changeset
448 " computer is busy with other things.
8168
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
449 let elapsed = reltime(start)
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
450 call assert_true(reltimefloat(elapsed) > 0.3)
8500
1227dc21865b commit https://github.com/vim/vim/commit/ac42afd10b96424b89762871905e3e785cdfba3d
Christian Brabandt <cb@256bit.org>
parents: 8491
diff changeset
451 call assert_true(reltimefloat(elapsed) < 1.5)
8168
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
452 endif
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
453 catch
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
454 if v:exception !~ 'Connection reset by peer'
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
455 call assert_false(1, "Caught exception: " . v:exception)
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
456 endif
454a30a7590e commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents: 8165
diff changeset
457 endtry
7982
5c30ba57aaea commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents: 7965
diff changeset
458 endfunc
8031
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
459
8382
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
460 """""""""
3dbe93a240d8 commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents: 8380
diff changeset
461
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
462 func Test_raw_pipe()
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
463 if !has('job')
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
464 return
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
465 endif
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
466 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
467 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
468 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
469 try
8436
0e6fd2f802b3 commit https://github.com/vim/vim/commit/151f656e171f6ffbb0cbeb343cbcf2ffac0c36b0
Christian Brabandt <cb@256bit.org>
parents: 8430
diff changeset
470 " For a change use the job where a channel is expected.
0e6fd2f802b3 commit https://github.com/vim/vim/commit/151f656e171f6ffbb0cbeb343cbcf2ffac0c36b0
Christian Brabandt <cb@256bit.org>
parents: 8430
diff changeset
471 call ch_sendraw(job, "echo something\n")
0e6fd2f802b3 commit https://github.com/vim/vim/commit/151f656e171f6ffbb0cbeb343cbcf2ffac0c36b0
Christian Brabandt <cb@256bit.org>
parents: 8430
diff changeset
472 let msg = ch_readraw(job)
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
473 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
474
8436
0e6fd2f802b3 commit https://github.com/vim/vim/commit/151f656e171f6ffbb0cbeb343cbcf2ffac0c36b0
Christian Brabandt <cb@256bit.org>
parents: 8430
diff changeset
475 call ch_sendraw(job, "double this\n")
0e6fd2f802b3 commit https://github.com/vim/vim/commit/151f656e171f6ffbb0cbeb343cbcf2ffac0c36b0
Christian Brabandt <cb@256bit.org>
parents: 8430
diff changeset
476 let msg = ch_readraw(job)
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
477 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
478
8436
0e6fd2f802b3 commit https://github.com/vim/vim/commit/151f656e171f6ffbb0cbeb343cbcf2ffac0c36b0
Christian Brabandt <cb@256bit.org>
parents: 8430
diff changeset
479 let reply = ch_evalraw(job, "quit\n", {'timeout': 100})
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
480 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
481 finally
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
482 call job_stop(job)
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
483 endtry
8502
ee5cb2e9ed5a commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents: 8500
diff changeset
484
ee5cb2e9ed5a commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents: 8500
diff changeset
485 let s:job = job
ee5cb2e9ed5a commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents: 8500
diff changeset
486 call s:waitFor('"dead" == job_status(s:job)')
ee5cb2e9ed5a commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents: 8500
diff changeset
487 let info = job_info(job)
ee5cb2e9ed5a commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents: 8500
diff changeset
488 call assert_equal("dead", info.status)
ee5cb2e9ed5a commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents: 8500
diff changeset
489 call assert_equal("term", info.stoponexit)
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
490 endfunc
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
491
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
492 func Test_nl_pipe()
8059
19304db153bc commit https://github.com/vim/vim/commit/d807036d10615b960c814ef3890ecad335b57f56
Christian Brabandt <cb@256bit.org>
parents: 8055
diff changeset
493 if !has('job')
8031
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
494 return
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
495 endif
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
496 call ch_log('Test_nl_pipe()')
8504
0b31cc4b261e commit https://github.com/vim/vim/commit/1adda3403d80e96446248a92ceafee036053765c
Christian Brabandt <cb@256bit.org>
parents: 8502
diff changeset
497 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
498 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
499 try
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
500 let handle = job_getchannel(job)
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
501 call ch_sendraw(handle, "echo something\n")
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
502 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
503
8384
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
504 call ch_sendraw(handle, "echoerr wrong\n")
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
505 call assert_equal("wrong", ch_readraw(handle, {'part': 'err'}))
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
506
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
507 call ch_sendraw(handle, "double this\n")
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
508 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
509 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
510
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
511 let reply = ch_evalraw(handle, "quit\n")
8084
3ea56a74077f commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents: 8078
diff changeset
512 call assert_equal("Goodbye!", reply)
8031
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
513 finally
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
514 call job_stop(job)
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
515 endtry
ece323e2b57f commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents: 8027
diff changeset
516 endfunc
8055
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
517
8384
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
518 func Test_nl_err_to_out_pipe()
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
519 if !has('job')
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
520 return
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
521 endif
8506
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
522 call ch_logfile('Xlog')
8384
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
523 call ch_log('Test_nl_err_to_out_pipe()')
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
524 let job = job_start(s:python . " test_channel_pipe.py", {'err_io': 'out'})
8384
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
525 call assert_equal("run", job_status(job))
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
526 try
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
527 let handle = job_getchannel(job)
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
528 call ch_sendraw(handle, "echo something\n")
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
529 call assert_equal("something", ch_readraw(handle))
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
530
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
531 call ch_sendraw(handle, "echoerr wrong\n")
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
532 call assert_equal("wrong", ch_readraw(handle))
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
533 finally
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
534 call job_stop(job)
8506
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
535 call ch_logfile('')
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
536 let loglines = readfile('Xlog')
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
537 call assert_true(len(loglines) > 10)
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
538 let found_test = 0
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
539 let found_send = 0
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
540 let found_recv = 0
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
541 let found_stop = 0
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
542 for l in loglines
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
543 if l =~ 'Test_nl_err_to_out_pipe'
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
544 let found_test = 1
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
545 endif
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
546 if l =~ 'SEND on.*echo something'
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
547 let found_send = 1
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
548 endif
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
549 if l =~ 'RECV on.*something'
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
550 let found_recv = 1
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
551 endif
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
552 if l =~ 'Stopping job with'
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
553 let found_stop = 1
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
554 endif
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
555 endfor
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
556 call assert_equal(1, found_test)
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
557 call assert_equal(1, found_send)
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
558 call assert_equal(1, found_recv)
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
559 call assert_equal(1, found_stop)
c93c352717b3 commit https://github.com/vim/vim/commit/5a6ec52392b78d41153660d0353d5b86a2dc583c
Christian Brabandt <cb@256bit.org>
parents: 8504
diff changeset
560 call delete('Xlog')
8384
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
561 endtry
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
562 endfunc
764dba33605c commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents: 8382
diff changeset
563
8430
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
564 func Test_nl_read_file()
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
565 if !has('job')
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
566 return
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
567 endif
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
568 call ch_log('Test_nl_read_file()')
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
569 call writefile(['echo something', 'echoerr wrong', 'double this'], 'Xinput')
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
570 let job = job_start(s:python . " test_channel_pipe.py",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
571 \ {'in_io': 'file', 'in_name': 'Xinput'})
8430
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
572 call assert_equal("run", job_status(job))
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
573 try
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
574 let handle = job_getchannel(job)
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
575 call assert_equal("something", ch_readraw(handle))
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
576 call assert_equal("wrong", ch_readraw(handle, {'part': 'err'}))
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
577 call assert_equal("this", ch_readraw(handle))
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
578 call assert_equal("AND this", ch_readraw(handle))
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
579 finally
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
580 call job_stop(job)
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
581 call delete('Xinput')
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
582 endtry
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
583 endfunc
800423dbc260 commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents: 8426
diff changeset
584
8447
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
585 func Test_nl_write_out_file()
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
586 if !has('job')
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
587 return
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
588 endif
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
589 call ch_log('Test_nl_write_out_file()')
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
590 let job = job_start(s:python . " test_channel_pipe.py",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
591 \ {'out_io': 'file', 'out_name': 'Xoutput'})
8447
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
592 call assert_equal("run", job_status(job))
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
593 try
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
594 let handle = job_getchannel(job)
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
595 call ch_sendraw(handle, "echo line one\n")
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
596 call ch_sendraw(handle, "echo line two\n")
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
597 call ch_sendraw(handle, "double this\n")
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
598 call s:waitFor('len(readfile("Xoutput")) > 2')
8447
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
599 call assert_equal(['line one', 'line two', 'this', 'AND this'], readfile('Xoutput'))
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
600 finally
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
601 call job_stop(job)
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
602 call delete('Xoutput')
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
603 endtry
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
604 endfunc
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
605
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
606 func Test_nl_write_err_file()
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
607 if !has('job')
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
608 return
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
609 endif
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
610 call ch_log('Test_nl_write_err_file()')
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
611 let job = job_start(s:python . " test_channel_pipe.py",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
612 \ {'err_io': 'file', 'err_name': 'Xoutput'})
8447
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
613 call assert_equal("run", job_status(job))
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
614 try
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
615 let handle = job_getchannel(job)
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
616 call ch_sendraw(handle, "echoerr line one\n")
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
617 call ch_sendraw(handle, "echoerr line two\n")
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
618 call ch_sendraw(handle, "doubleerr this\n")
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
619 call s:waitFor('len(readfile("Xoutput")) > 2')
8447
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
620 call assert_equal(['line one', 'line two', 'this', 'AND this'], readfile('Xoutput'))
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
621 finally
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
622 call job_stop(job)
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
623 call delete('Xoutput')
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
624 endtry
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
625 endfunc
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
626
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
627 func Test_nl_write_both_file()
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
628 if !has('job')
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
629 return
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
630 endif
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
631 call ch_log('Test_nl_write_both_file()')
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
632 let job = job_start(s:python . " test_channel_pipe.py",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
633 \ {'out_io': 'file', 'out_name': 'Xoutput', 'err_io': 'out'})
8447
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
634 call assert_equal("run", job_status(job))
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
635 try
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
636 let handle = job_getchannel(job)
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
637 call ch_sendraw(handle, "echoerr line one\n")
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
638 call ch_sendraw(handle, "echo line two\n")
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
639 call ch_sendraw(handle, "double this\n")
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
640 call ch_sendraw(handle, "doubleerr that\n")
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
641 call s:waitFor('len(readfile("Xoutput")) > 5')
8447
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
642 call assert_equal(['line one', 'line two', 'this', 'AND this', 'that', 'AND that'], readfile('Xoutput'))
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
643 finally
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
644 call job_stop(job)
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
645 call delete('Xoutput')
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
646 endtry
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
647 endfunc
6f26b680c243 commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents: 8443
diff changeset
648
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
649 func Run_test_pipe_to_buffer(use_name)
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
650 if !has('job')
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
651 return
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
652 endif
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
653 call ch_log('Test_pipe_to_buffer()')
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
654 let options = {'out_io': 'buffer'}
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
655 if a:use_name
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
656 let options['out_name'] = 'pipe-output'
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
657 let firstline = 'Reading from channel output...'
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
658 else
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
659 sp pipe-output
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
660 let options['out_buf'] = bufnr('%')
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
661 quit
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
662 let firstline = ''
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
663 endif
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
664 let job = job_start(s:python . " test_channel_pipe.py", options)
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
665 call assert_equal("run", job_status(job))
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
666 try
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
667 let handle = job_getchannel(job)
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
668 call ch_sendraw(handle, "echo line one\n")
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
669 call ch_sendraw(handle, "echo line two\n")
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
670 call ch_sendraw(handle, "double this\n")
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
671 call ch_sendraw(handle, "quit\n")
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
672 sp pipe-output
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
673 call s:waitFor('line("$") >= 6')
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
674 call assert_equal([firstline, 'line one', 'line two', 'this', 'AND this', 'Goodbye!'], getline(1, '$'))
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
675 bwipe!
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
676 finally
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
677 call job_stop(job)
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
678 endtry
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
679 endfunc
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
680
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
681 func Test_pipe_to_buffer_name()
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
682 call Run_test_pipe_to_buffer(1)
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
683 endfunc
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
684
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
685 func Test_pipe_to_buffer_nr()
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
686 call Run_test_pipe_to_buffer(0)
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
687 endfunc
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
688
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
689 func Run_test_pipe_err_to_buffer(use_name)
8463
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
690 if !has('job')
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
691 return
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
692 endif
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
693 call ch_log('Test_pipe_err_to_buffer()')
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
694 let options = {'err_io': 'buffer'}
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
695 if a:use_name
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
696 let options['err_name'] = 'pipe-err'
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
697 let firstline = 'Reading from channel error...'
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
698 else
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
699 sp pipe-err
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
700 let options['err_buf'] = bufnr('%')
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
701 quit
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
702 let firstline = ''
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
703 endif
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
704 let job = job_start(s:python . " test_channel_pipe.py", options)
8463
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
705 call assert_equal("run", job_status(job))
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
706 try
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
707 let handle = job_getchannel(job)
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
708 call ch_sendraw(handle, "echoerr line one\n")
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
709 call ch_sendraw(handle, "echoerr line two\n")
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
710 call ch_sendraw(handle, "doubleerr this\n")
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
711 call ch_sendraw(handle, "quit\n")
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
712 sp pipe-err
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
713 call s:waitFor('line("$") >= 5')
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
714 call assert_equal([firstline, 'line one', 'line two', 'this', 'AND this'], getline(1, '$'))
8463
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
715 bwipe!
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
716 finally
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
717 call job_stop(job)
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
718 endtry
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
719 endfunc
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
720
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
721 func Test_pipe_err_to_buffer_name()
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
722 call Run_test_pipe_err_to_buffer(1)
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
723 endfunc
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
724
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
725 func Test_pipe_err_to_buffer_nr()
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
726 call Run_test_pipe_err_to_buffer(0)
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
727 endfunc
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
728
8463
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
729 func Test_pipe_both_to_buffer()
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
730 if !has('job')
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
731 return
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
732 endif
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
733 call ch_log('Test_pipe_both_to_buffer()')
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
734 let job = job_start(s:python . " test_channel_pipe.py",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
735 \ {'out_io': 'buffer', 'out_name': 'pipe-err', 'err_io': 'out'})
8463
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
736 call assert_equal("run", job_status(job))
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
737 try
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
738 let handle = job_getchannel(job)
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
739 call ch_sendraw(handle, "echo line one\n")
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
740 call ch_sendraw(handle, "echoerr line two\n")
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
741 call ch_sendraw(handle, "double this\n")
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
742 call ch_sendraw(handle, "doubleerr that\n")
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
743 call ch_sendraw(handle, "quit\n")
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
744 sp pipe-err
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
745 call s:waitFor('line("$") >= 7')
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
746 call assert_equal(['Reading from channel output...', 'line one', 'line two', 'this', 'AND this', 'that', 'AND that', 'Goodbye!'], getline(1, '$'))
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
747 bwipe!
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
748 finally
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
749 call job_stop(job)
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
750 endtry
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
751 endfunc
508504ca52ac commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents: 8459
diff changeset
752
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
753 func Run_test_pipe_from_buffer(use_name)
8386
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
754 if !has('job')
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
755 return
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
756 endif
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
757 call ch_log('Test_pipe_from_buffer()')
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
758
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
759 sp pipe-input
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
760 call setline(1, ['echo one', 'echo two', 'echo three'])
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
761 let options = {'in_io': 'buffer'}
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
762 if a:use_name
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
763 let options['in_name'] = 'pipe-input'
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
764 else
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
765 let options['in_buf'] = bufnr('%')
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
766 endif
8386
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
767
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
768 let job = job_start(s:python . " test_channel_pipe.py", options)
8386
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
769 call assert_equal("run", job_status(job))
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
770 try
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
771 let handle = job_getchannel(job)
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
772 call assert_equal('one', ch_read(handle))
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
773 call assert_equal('two', ch_read(handle))
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
774 call assert_equal('three', ch_read(handle))
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
775 bwipe!
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
776 finally
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
777 call job_stop(job)
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
778 endtry
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
779 endfunc
3b9a306724ec commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents: 8384
diff changeset
780
8477
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
781 func Test_pipe_from_buffer_name()
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
782 call Run_test_pipe_from_buffer(1)
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
783 endfunc
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
784
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
785 func Test_pipe_from_buffer_nr()
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
786 call Run_test_pipe_from_buffer(0)
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
787 endfunc
c08c6d19db4d commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents: 8471
diff changeset
788
8291
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
789 func Test_pipe_to_nameless_buffer()
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
790 if !has('job')
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
791 return
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
792 endif
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
793 call ch_log('Test_pipe_to_nameless_buffer()')
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
794 let job = job_start(s:python . " test_channel_pipe.py",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
795 \ {'out_io': 'buffer'})
8291
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
796 call assert_equal("run", job_status(job))
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
797 try
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
798 let handle = job_getchannel(job)
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
799 call ch_sendraw(handle, "echo line one\n")
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
800 call ch_sendraw(handle, "echo line two\n")
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
801 exe ch_getbufnr(handle, "out") . 'sbuf'
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
802 call s:waitFor('line("$") >= 3')
8291
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
803 call assert_equal(['Reading from channel output...', 'line one', 'line two'], getline(1, '$'))
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
804 bwipe!
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
805 finally
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
806 call job_stop(job)
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
807 endtry
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
808 endfunc
ac0c43e7af20 commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents: 8285
diff changeset
809
8346
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
810 func Test_pipe_to_buffer_json()
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
811 if !has('job')
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
812 return
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
813 endif
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
814 call ch_log('Test_pipe_to_buffer_json()')
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
815 let job = job_start(s:python . " test_channel_pipe.py",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
816 \ {'out_io': 'buffer', 'out_mode': 'json'})
8346
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
817 call assert_equal("run", job_status(job))
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
818 try
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
819 let handle = job_getchannel(job)
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
820 call ch_sendraw(handle, "echo [0, \"hello\"]\n")
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
821 call ch_sendraw(handle, "echo [-2, 12.34]\n")
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
822 exe ch_getbufnr(handle, "out") . 'sbuf'
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
823 call s:waitFor('line("$") >= 3')
8346
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
824 call assert_equal(['Reading from channel output...', '[0,"hello"]', '[-2,12.34]'], getline(1, '$'))
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
825 bwipe!
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
826 finally
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
827 call job_stop(job)
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
828 endtry
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
829 endfunc
8fa75a4c39bd commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents: 8324
diff changeset
830
8426
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
831 " Wait a little while for the last line, minus "offset", to equal "line".
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
832 func s:wait_for_last_line(line, offset)
8426
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
833 for i in range(100)
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
834 if getline(line('$') - a:offset) == a:line
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
835 break
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
836 endif
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
837 sleep 10m
8426
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
838 endfor
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
839 endfunc
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
840
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
841 func Test_pipe_io_two_buffers()
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
842 if !has('job')
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
843 return
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
844 endif
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
845 call ch_log('Test_pipe_io_two_buffers()')
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
846
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
847 " Create two buffers, one to read from and one to write to.
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
848 split pipe-output
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
849 set buftype=nofile
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
850 split pipe-input
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
851 set buftype=nofile
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
852
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
853 let job = job_start(s:python . " test_channel_pipe.py",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
854 \ {'in_io': 'buffer', 'in_name': 'pipe-input', 'in_top': 0,
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
855 \ 'out_io': 'buffer', 'out_name': 'pipe-output'})
8426
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
856 call assert_equal("run", job_status(job))
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
857 try
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
858 exe "normal Gaecho hello\<CR>"
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
859 exe bufwinnr('pipe-output') . "wincmd w"
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
860 call s:wait_for_last_line('hello', 0)
8426
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
861 call assert_equal('hello', getline('$'))
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
862
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
863 exe bufwinnr('pipe-input') . "wincmd w"
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
864 exe "normal Gadouble this\<CR>"
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
865 exe bufwinnr('pipe-output') . "wincmd w"
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
866 call s:wait_for_last_line('AND this', 0)
8426
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
867 call assert_equal('this', getline(line('$') - 1))
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
868 call assert_equal('AND this', getline('$'))
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
869
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
870 bwipe!
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
871 exe bufwinnr('pipe-input') . "wincmd w"
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
872 bwipe!
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
873 finally
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
874 call job_stop(job)
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
875 endtry
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
876 endfunc
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
877
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
878 func Test_pipe_io_one_buffer()
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
879 if !has('job')
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
880 return
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
881 endif
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
882 call ch_log('Test_pipe_io_one_buffer()')
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
883
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
884 " Create one buffer to read from and to write to.
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
885 split pipe-io
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
886 set buftype=nofile
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
887
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
888 let job = job_start(s:python . " test_channel_pipe.py",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
889 \ {'in_io': 'buffer', 'in_name': 'pipe-io', 'in_top': 0,
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
890 \ 'out_io': 'buffer', 'out_name': 'pipe-io'})
8426
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
891 call assert_equal("run", job_status(job))
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
892 try
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
893 exe "normal Goecho hello\<CR>"
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
894 call s:wait_for_last_line('hello', 1)
8426
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
895 call assert_equal('hello', getline(line('$') - 1))
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
896
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
897 exe "normal Gadouble this\<CR>"
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
898 call s:wait_for_last_line('AND this', 1)
8426
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
899 call assert_equal('this', getline(line('$') - 2))
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
900 call assert_equal('AND this', getline(line('$') - 1))
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
901
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
902 bwipe!
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
903 finally
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
904 call job_stop(job)
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
905 endtry
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
906 endfunc
02ce040591c8 commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents: 8424
diff changeset
907
8455
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
908 func Test_pipe_null()
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
909 if !has('job')
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
910 return
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
911 endif
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
912 call ch_log('Test_pipe_null()')
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
913
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
914 " We cannot check that no I/O works, we only check that the job starts
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
915 " properly.
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
916 let job = job_start(s:python . " test_channel_pipe.py something",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
917 \ {'in_io': 'null'})
8455
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
918 call assert_equal("run", job_status(job))
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
919 try
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
920 call assert_equal('something', ch_read(job))
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
921 finally
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
922 call job_stop(job)
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
923 endtry
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
924
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
925 let job = job_start(s:python . " test_channel_pipe.py err-out",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
926 \ {'out_io': 'null'})
8455
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
927 call assert_equal("run", job_status(job))
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
928 try
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
929 call assert_equal('err-out', ch_read(job, {"part": "err"}))
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
930 finally
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
931 call job_stop(job)
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
932 endtry
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
933
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
934 let job = job_start(s:python . " test_channel_pipe.py something",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
935 \ {'err_io': 'null'})
8455
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
936 call assert_equal("run", job_status(job))
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
937 try
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
938 call assert_equal('something', ch_read(job))
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
939 finally
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
940 call job_stop(job)
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
941 endtry
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
942
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
943 let job = job_start(s:python . " test_channel_pipe.py something",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
944 \ {'out_io': 'null', 'err_io': 'out'})
8455
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
945 call assert_equal("run", job_status(job))
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
946 call job_stop(job)
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
947
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
948 let job = job_start(s:python . " test_channel_pipe.py something",
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
949 \ {'in_io': 'null', 'out_io': 'null', 'err_io': 'null'})
8455
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
950 call assert_equal("run", job_status(job))
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
951 call assert_equal('channel fail', string(job_getchannel(job)))
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
952 call assert_equal('fail', ch_status(job))
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
953 call job_stop(job)
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
954 endfunc
d0717262d802 commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents: 8449
diff changeset
955
8491
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
956 func Test_reuse_channel()
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
957 if !has('job')
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
958 return
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
959 endif
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
960 call ch_log('Test_reuse_channel()')
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
961
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
962 let job = job_start(s:python . " test_channel_pipe.py")
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
963 call assert_equal("run", job_status(job))
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
964 let handle = job_getchannel(job)
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
965 try
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
966 call ch_sendraw(handle, "echo something\n")
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
967 call assert_equal("something", ch_readraw(handle))
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
968 finally
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
969 call job_stop(job)
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
970 endtry
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
971
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
972 let job = job_start(s:python . " test_channel_pipe.py", {'channel': handle})
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
973 call assert_equal("run", job_status(job))
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
974 let handle = job_getchannel(job)
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
975 try
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
976 call ch_sendraw(handle, "echo again\n")
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
977 call assert_equal("again", ch_readraw(handle))
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
978 finally
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
979 call job_stop(job)
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
980 endtry
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
981 endfunc
daebcbd87bd3 commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents: 8477
diff changeset
982
8074
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
983 """"""""""
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
984
8055
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
985 let s:unletResponse = ''
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
986 func s:UnletHandler(handle, msg)
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
987 let s:unletResponse = a:msg
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
988 unlet s:channelfd
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
989 endfunc
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
990
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
991 " 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
992 func s:unlet_handle(port)
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
993 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
994 call ch_sendexpr(s:channelfd, "test", {'callback': function('s:UnletHandler')})
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
995 call s:waitFor('"what?" == s:unletResponse')
8055
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
996 call assert_equal('what?', s:unletResponse)
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
997 endfunc
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
998
6db4b1c863ec commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents: 8045
diff changeset
999 func Test_unlet_handle()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1000 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
1001 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
1002 endfunc
8070
e4c3f6720b03 commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents: 8066
diff changeset
1003
8074
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1004 """"""""""
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1005
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1006 let s:unletResponse = ''
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1007 func s:CloseHandler(handle, msg)
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1008 let s:unletResponse = a:msg
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1009 call ch_close(s:channelfd)
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1010 endfunc
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1011
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1012 " 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
1013 func s:close_handle(port)
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1014 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
1015 call ch_sendexpr(s:channelfd, "test", {'callback': function('s:CloseHandler')})
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
1016 call s:waitFor('"what?" == s:unletResponse')
8074
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1017 call assert_equal('what?', s:unletResponse)
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1018 endfunc
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1019
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1020 func Test_close_handle()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1021 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
1022 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
1023 endfunc
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1024
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1025 """"""""""
dc32c8026899 commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents: 8070
diff changeset
1026
8070
e4c3f6720b03 commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents: 8066
diff changeset
1027 func Test_open_fail()
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1028 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
1029 silent! let ch = ch_open("noserver")
e4c3f6720b03 commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents: 8066
diff changeset
1030 echo ch
e4c3f6720b03 commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents: 8066
diff changeset
1031 let d = ch
e4c3f6720b03 commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents: 8066
diff changeset
1032 endfunc
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1033
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1034 """"""""""
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1035
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1036 func s:open_delay(port)
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1037 " 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
1038 let s:chopt.waittime = 1000
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1039 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
1040 unlet s:chopt.waittime
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1041 if ch_status(channel) == "fail"
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1042 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
1043 return
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1044 endif
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
1045 call assert_equal('got it', ch_evalexpr(channel, 'hello!'))
8114
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1046 call ch_close(channel)
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1047 endfunc
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1048
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1049 func Test_open_delay()
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1050 call ch_log('Test_open_delay()')
4aea0b0aa714 commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents: 8096
diff changeset
1051 " 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
1052 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
1053 endfunc
8159
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1054
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1055 """""""""
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1056
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1057 function MyFunction(a,b,c)
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1058 let s:call_ret = [a:a, a:b, a:c]
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1059 endfunc
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1060
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1061 function s:test_call(port)
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1062 let handle = ch_open('localhost:' . a:port, s:chopt)
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1063 if ch_status(handle) == "fail"
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1064 call assert_false(1, "Can't open channel")
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1065 return
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1066 endif
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1067
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
1068 let s:call_ret = []
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
1069 call assert_equal('ok', ch_evalexpr(handle, 'call-func'))
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
1070 call s:waitFor('len(s:call_ret) > 0')
8159
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1071 call assert_equal([1, 2, 3], s:call_ret)
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1072 endfunc
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1073
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1074 func Test_call()
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1075 call ch_log('Test_call()')
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1076 call s:run_server('s:test_call')
d0958e22d9ff commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents: 8157
diff changeset
1077 endfunc
8174
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1078
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1079 """""""""
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1080
8210
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1081 let s:job_exit_ret = 'not yet'
8174
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1082 function MyExitCb(job, status)
8210
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1083 let s:job_exit_ret = 'done'
8174
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1084 endfunc
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1085
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1086 function s:test_exit_callback(port)
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
1087 call job_setoptions(s:job, {'exit_cb': 'MyExitCb'})
8174
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1088 let s:exit_job = s:job
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
1089 call assert_equal('MyExitCb', job_info(s:job)['exit_cb'])
8174
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1090 endfunc
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1091
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1092 func Test_exit_callback()
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1093 if has('job')
8324
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1094 call ch_log('Test_exit_callback()')
8174
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1095 call s:run_server('s:test_exit_callback')
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1096
8324
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1097 " wait up to a second for the job to exit
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1098 for i in range(100)
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1099 if s:job_exit_ret == 'done'
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1100 break
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1101 endif
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1102 sleep 10m
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1103 " calling job_status() triggers the callback
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1104 call job_status(s:exit_job)
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1105 endfor
8174
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1106
8210
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1107 call assert_equal('done', s:job_exit_ret)
8502
ee5cb2e9ed5a commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents: 8500
diff changeset
1108 call assert_equal('dead', job_info(s:exit_job).status)
8324
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1109 unlet s:exit_job
8174
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1110 endif
f2286ff0c102 commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents: 8170
diff changeset
1111 endfunc
8210
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1112
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1113 """""""""
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1114
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1115 let s:ch_close_ret = 'alive'
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1116 function MyCloseCb(ch)
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1117 let s:ch_close_ret = 'closed'
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1118 endfunc
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1119
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1120 function s:test_close_callback(port)
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1121 let handle = ch_open('localhost:' . a:port, s:chopt)
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1122 if ch_status(handle) == "fail"
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1123 call assert_false(1, "Can't open channel")
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1124 return
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1125 endif
8540
fec8655cf1bf commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents: 8506
diff changeset
1126 call ch_setoptions(handle, {'close_cb': 'MyCloseCb'})
8210
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1127
8285
e05e28dcb590 commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
1128 call assert_equal('', ch_evalexpr(handle, 'close me'))
8449
3d567b5839c5 commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents: 8447
diff changeset
1129 call s:waitFor('"closed" == s:ch_close_ret')
8210
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1130 call assert_equal('closed', s:ch_close_ret)
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1131 endfunc
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1132
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1133 func Test_close_callback()
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1134 call ch_log('Test_close_callback()')
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1135 call s:run_server('s:test_close_callback')
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1136 endfunc
b717dae2f26d commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents: 8174
diff changeset
1137
8324
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1138 " Uncomment this to see what happens, output is in src/testdir/channellog.
5e88bd55b789 commit https://github.com/vim/vim/commit/9730f74a0b2acb490943393a203a24ab8fab923a
Christian Brabandt <cb@256bit.org>
parents: 8291
diff changeset
1139 " call ch_logfile('channellog', 'w')