Mercurial > vim
annotate src/testdir/test_channel.vim @ 28652:27dcbe70e1f0 v8.2.4850
patch 8.2.4850: mksession mixes up "tabpages" and "curdir" arguments
Commit: https://github.com/vim/vim/commit/d7c9564d8d24343f2e27205633032dd6ebe5232c
Author: LemonBoy <thatlemon@gmail.com>
Date: Sat Apr 30 16:10:27 2022 +0100
patch 8.2.4850: mksession mixes up "tabpages" and "curdir" arguments
Problem: Mksession mixes up "tabpages" and "curdir" arguments.
Solution: Correct logic for storing tabpage in session. (closes https://github.com/vim/vim/issues/10312)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 30 Apr 2022 17:15:02 +0200 |
parents | 6b1da12297e5 |
children | 32f3b86352e6 |
rev | line source |
---|---|
17559
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1 " Test for channel and job functions. |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
17559
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
3 " When +channel is supported then +job is too, so we don't check for that. |
17557
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
4 source check.vim |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
5 CheckFeature channel |
7922
14540239601d
commit https://github.com/vim/vim/commit/e24692573a266f5060c06dd80bde264092c90dd5
Christian Brabandt <cb@256bit.org>
parents:
7918
diff
changeset
|
6 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
7 source shared.vim |
17557
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
8 source screendump.vim |
20213
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
9 source view_util.vim |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
10 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
11 let s:python = PythonProg() |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
12 if s:python == '' |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
13 " Can't run this test without Python. |
16965
ba7727889385
patch 8.1.1483: skipped tests are not properly listed
Bram Moolenaar <Bram@vim.org>
parents:
15975
diff
changeset
|
14 throw 'Skipped: Python command missing' |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 endif |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
17 " Uncomment the next line to see what happens. Output is in |
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
18 " src/testdir/channellog. |
17559
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
19 " Add ch_log() calls where you want to see what happens. |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
20 " call ch_logfile('channellog', 'w') |
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
21 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
22 func SetUp() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
23 if g:testfunc =~ '_ipv6()$' |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
24 let s:localhost = '[::1]:' |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
25 let s:testscript = 'test_channel_6.py' |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
26 elseif g:testfunc =~ '_unix()$' |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
27 let s:localhost = 'unix:Xtestsocket' |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
28 let s:testscript = 'test_channel_unix.py' |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
29 else |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
30 let s:localhost = 'localhost:' |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
31 let s:testscript = 'test_channel.py' |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
32 endif |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
33 let s:chopt = {} |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
34 call ch_log(g:testfunc) |
20923
a9516192b1db
patch 8.2.1013: channel tests can be a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
35 |
a9516192b1db
patch 8.2.1013: channel tests can be a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
36 " Most tests use job_start(), which can be flaky |
a9516192b1db
patch 8.2.1013: channel tests can be a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
37 let g:test_is_flaky = 1 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
38 endfunc |
7916
54602dcac207
commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents:
7914
diff
changeset
|
39 |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19157
diff
changeset
|
40 " Run "testfunc" after starting 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
|
41 func s:run_server(testfunc, ...) |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
42 call RunServer(s:testscript, a:testfunc, a:000) |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
43 endfunc |
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
44 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
45 " Returns the address of the test server. |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
46 func s:address(port) |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
47 if s:localhost =~ '^unix:' |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
48 return s:localhost |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
49 else |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
50 return s:localhost . a:port |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
51 end |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
52 endfunc |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
53 |
13357
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
54 " Return a list of open files. |
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
55 " Can be used to make sure no resources leaked. |
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
56 " Returns an empty list on systems where this is not supported. |
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
57 func s:get_resources() |
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
58 let pid = getpid() |
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
59 |
15677
772e72b046a3
patch 8.1.0846: not easy to recognize the system Vim runs on
Bram Moolenaar <Bram@vim.org>
parents:
15625
diff
changeset
|
60 if executable('lsof') |
13357
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
61 return systemlist('lsof -p ' . pid . ' | awk ''$4~/^[0-9]*[rwu]$/&&$5=="REG"{print$NF}''') |
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
62 elseif isdirectory('/proc/' . pid . '/fd/') |
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
63 return systemlist('readlink /proc/' . pid . '/fd/* | grep -v ''^/dev/''') |
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
64 else |
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
65 return [] |
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
66 endif |
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
67 endfunc |
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
68 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
69 let g:Ch_responseMsg = '' |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
70 func Ch_requestHandler(handle, msg) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
71 let g:Ch_responseHandle = a:handle |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
72 let g:Ch_responseMsg = a:msg |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
73 endfunc |
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
74 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
75 func Ch_communicate(port) |
10454
f5c7c76897fa
commit https://github.com/vim/vim/commit/5643db84c6a9f15d14492cefd52647623aa2ac7c
Christian Brabandt <cb@256bit.org>
parents:
10428
diff
changeset
|
76 " Avoid dropping messages, since we don't use a callback here. |
f5c7c76897fa
commit https://github.com/vim/vim/commit/5643db84c6a9f15d14492cefd52647623aa2ac7c
Christian Brabandt <cb@256bit.org>
parents:
10428
diff
changeset
|
77 let s:chopt.drop = 'never' |
14675
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
78 " Also add the noblock flag to try it out. |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
79 let s:chopt.noblock = 1 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
80 let handle = ch_open(s:address(a:port), s:chopt) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8037
diff
changeset
|
81 if ch_status(handle) == "fail" |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
82 call assert_report("Can't open channel") |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 return |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 endif |
17559
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
85 |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
86 " check that getjob without a job is handled correctly |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
87 call assert_equal('no process', string(ch_getjob(handle))) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
88 |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
89 let dict = handle->ch_info() |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
90 call assert_true(dict.id != 0) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
91 call assert_equal('open', dict.status) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
92 if has_key(dict, 'port') |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
93 " Channels using Unix sockets have no 'port' entry. |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
94 call assert_equal(a:port, string(dict.port)) |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
95 end |
8669
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
96 call assert_equal('open', dict.sock_status) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
97 call assert_equal('socket', dict.sock_io) |
06848fe9c816
commit https://github.com/vim/vim/commit/03602ec28ed25739e88b2c835adb0662d3720bb2
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
98 |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 " Simple string request and reply. |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
100 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
|
101 |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8540
diff
changeset
|
102 " Malformed command should be ignored. |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
103 call assert_equal('ok', ch_evalexpr(handle, 'malformed1')) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
104 call assert_equal('ok', ch_evalexpr(handle, 'malformed2')) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
105 call assert_equal('ok', ch_evalexpr(handle, 'malformed3')) |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
106 |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
107 " split command should work |
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
108 call assert_equal('ok', ch_evalexpr(handle, 'split')) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
109 call WaitFor('exists("g:split")') |
8655
1eb302bf2475
commit https://github.com/vim/vim/commit/ba61ac0d61f46de7d29c64bb0de6d25c2e378be0
Christian Brabandt <cb@256bit.org>
parents:
8653
diff
changeset
|
110 call assert_equal(123, g:split) |
8653
d80edead9675
commit https://github.com/vim/vim/commit/ac74d5e86cd16b42e81ba48f58f3d45c72758248
Christian Brabandt <cb@256bit.org>
parents:
8540
diff
changeset
|
111 |
9969
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9719
diff
changeset
|
112 " string with ][ should work |
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9719
diff
changeset
|
113 call assert_equal('this][that', ch_evalexpr(handle, 'echo this][that')) |
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9719
diff
changeset
|
114 |
10422
e664ee056a84
commit https://github.com/vim/vim/commit/4b785f69c0616dba5d3f38e8ce4b5398cec89407
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
115 " nothing to read now |
e664ee056a84
commit https://github.com/vim/vim/commit/4b785f69c0616dba5d3f38e8ce4b5398cec89407
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
116 call assert_equal(0, ch_canread(handle)) |
e664ee056a84
commit https://github.com/vim/vim/commit/4b785f69c0616dba5d3f38e8ce4b5398cec89407
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
117 |
9969
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9719
diff
changeset
|
118 " sending three messages quickly then reading should work |
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9719
diff
changeset
|
119 for i in range(3) |
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9719
diff
changeset
|
120 call ch_sendexpr(handle, 'echo hello ' . i) |
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9719
diff
changeset
|
121 endfor |
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9719
diff
changeset
|
122 call assert_equal('hello 0', ch_read(handle)[1]) |
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9719
diff
changeset
|
123 call assert_equal('hello 1', ch_read(handle)[1]) |
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9719
diff
changeset
|
124 call assert_equal('hello 2', ch_read(handle)[1]) |
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
9719
diff
changeset
|
125 |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 " 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
|
127 " 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
|
128 " 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
|
129 call assert_equal('ok', ch_evalexpr(handle, 'make change')) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
130 call WaitForAssert({-> assert_equal("added2", getline("$"))}) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
131 call assert_equal('added1', getline(line('$') - 1)) |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
132 |
25090
73503bafb3bf
patch 8.2.3082: a channel command "echoerr" does not show anything
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
133 " Request command "echoerr 'this is an error'". |
73503bafb3bf
patch 8.2.3082: a channel command "echoerr" does not show anything
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
134 " This will throw an exception, catch it here. |
73503bafb3bf
patch 8.2.3082: a channel command "echoerr" does not show anything
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
135 let caught = 'no' |
73503bafb3bf
patch 8.2.3082: a channel command "echoerr" does not show anything
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
136 try |
73503bafb3bf
patch 8.2.3082: a channel command "echoerr" does not show anything
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
137 call assert_equal('ok', ch_evalexpr(handle, 'echoerr')) |
73503bafb3bf
patch 8.2.3082: a channel command "echoerr" does not show anything
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
138 catch /this is an error/ |
73503bafb3bf
patch 8.2.3082: a channel command "echoerr" does not show anything
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
139 let caught = 'yes' |
73503bafb3bf
patch 8.2.3082: a channel command "echoerr" does not show anything
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
140 endtry |
73503bafb3bf
patch 8.2.3082: a channel command "echoerr" does not show anything
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
141 if caught != 'yes' |
73503bafb3bf
patch 8.2.3082: a channel command "echoerr" does not show anything
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
142 call assert_report("Expected exception from error message") |
73503bafb3bf
patch 8.2.3082: a channel command "echoerr" does not show anything
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
143 endif |
73503bafb3bf
patch 8.2.3082: a channel command "echoerr" does not show anything
Bram Moolenaar <Bram@vim.org>
parents:
22977
diff
changeset
|
144 |
8746
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8744
diff
changeset
|
145 " Request command "foo bar", which fails silently. |
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8744
diff
changeset
|
146 call assert_equal('ok', ch_evalexpr(handle, 'bad command')) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
147 call WaitForAssert({-> assert_match("E492:.*foo bar", v:errmsg)}) |
8746
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8744
diff
changeset
|
148 |
8380
892d7dcf17ec
commit https://github.com/vim/vim/commit/da94fdf2588b3910d38e477a755748ce2c6d2e66
Christian Brabandt <cb@256bit.org>
parents:
8346
diff
changeset
|
149 call assert_equal('ok', ch_evalexpr(handle, 'do normal', {'timeout': 100})) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
150 call WaitForAssert({-> assert_equal('added more', getline('$'))}) |
7939
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7935
diff
changeset
|
151 |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
152 " Send a request with a specific handler. |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
153 call ch_sendexpr(handle, 'hello!', {'callback': 'Ch_requestHandler'}) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
154 call WaitFor('exists("g:Ch_responseHandle")') |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
155 if !exists('g:Ch_responseHandle') |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
156 call assert_report('g:Ch_responseHandle was not set') |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8037
diff
changeset
|
157 else |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
158 call assert_equal(handle, g:Ch_responseHandle) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
159 unlet g:Ch_responseHandle |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8037
diff
changeset
|
160 endif |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
161 call assert_equal('got it', g:Ch_responseMsg) |
7933
1f0743f4f88f
commit https://github.com/vim/vim/commit/a07fec9c85d062acd9dd433a2e681770f459ba47
Christian Brabandt <cb@256bit.org>
parents:
7929
diff
changeset
|
162 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
163 let g:Ch_responseMsg = '' |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
164 call ch_sendexpr(handle, 'hello!', {'callback': function('Ch_requestHandler')}) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
165 call WaitFor('exists("g:Ch_responseHandle")') |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
166 if !exists('g:Ch_responseHandle') |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
167 call assert_report('g:Ch_responseHandle was not set') |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8037
diff
changeset
|
168 else |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
169 call assert_equal(handle, g:Ch_responseHandle) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
170 unlet g:Ch_responseHandle |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8037
diff
changeset
|
171 endif |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
172 call assert_equal('got it', g:Ch_responseMsg) |
8017
c59a65524084
commit https://github.com/vim/vim/commit/b6a4fee37ebbb0c76f2fbda7d06cbf48a3a07e8d
Christian Brabandt <cb@256bit.org>
parents:
8013
diff
changeset
|
173 |
9527
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
174 " Using lambda. |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
175 let g:Ch_responseMsg = '' |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
176 call ch_sendexpr(handle, 'hello!', {'callback': {a, b -> Ch_requestHandler(a, b)}}) |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
177 call WaitFor('exists("g:Ch_responseHandle")') |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
178 if !exists('g:Ch_responseHandle') |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
179 call assert_report('g:Ch_responseHandle was not set') |
9527
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
180 else |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
181 call assert_equal(handle, g:Ch_responseHandle) |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
182 unlet g:Ch_responseHandle |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
183 endif |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
184 call assert_equal('got it', g:Ch_responseMsg) |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
185 |
8420
f6d21a33d489
commit https://github.com/vim/vim/commit/38fd4bb2842df7634823b99c655b3896a7a2e988
Christian Brabandt <cb@256bit.org>
parents:
8404
diff
changeset
|
186 " Collect garbage, tests that our handle isn't collected. |
9108
d319453f62b3
commit https://github.com/vim/vim/commit/574860b5ee9da281c875dad07a607454e135eaee
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
187 call test_garbagecollect_now() |
8420
f6d21a33d489
commit https://github.com/vim/vim/commit/38fd4bb2842df7634823b99c655b3896a7a2e988
Christian Brabandt <cb@256bit.org>
parents:
8404
diff
changeset
|
188 |
8124
310dd635e8c9
commit https://github.com/vim/vim/commit/40ea1da14ba196a23309789852e1b663fd92e3a8
Christian Brabandt <cb@256bit.org>
parents:
8118
diff
changeset
|
189 " check setting options (without testing the effect) |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
190 eval handle->ch_setoptions({'callback': 's:NotUsed'}) |
8130
3462f9cfedf8
commit https://github.com/vim/vim/commit/1f6ef66254c1e25ef1c7972aa9a0ba119ebc17e4
Christian Brabandt <cb@256bit.org>
parents:
8124
diff
changeset
|
191 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
|
192 call ch_setoptions(handle, {'mode': 'json'}) |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
193 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
|
194 call ch_setoptions(handle, {'callback': ''}) |
10428
a963dce191cf
commit https://github.com/vim/vim/commit/65e08ee1d26aa7bf341ac0e0400839d696d1ab64
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
195 call ch_setoptions(handle, {'drop': 'never'}) |
a963dce191cf
commit https://github.com/vim/vim/commit/65e08ee1d26aa7bf341ac0e0400839d696d1ab64
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
196 call ch_setoptions(handle, {'drop': 'auto'}) |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
197 call assert_fails("call ch_setoptions(handle, {'drop': 'bad'})", 'E475:') |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20031
diff
changeset
|
198 call assert_equal(0, ch_setoptions(handle, test_null_dict())) |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20031
diff
changeset
|
199 call assert_equal(0, ch_setoptions(test_null_channel(), {'drop' : 'never'})) |
8124
310dd635e8c9
commit https://github.com/vim/vim/commit/40ea1da14ba196a23309789852e1b663fd92e3a8
Christian Brabandt <cb@256bit.org>
parents:
8118
diff
changeset
|
200 |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
201 " 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
|
202 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
|
203 sleep 10m |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
204 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
|
205 |
8744
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
206 " Send an eval request with special characters. |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
207 call assert_equal('ok', ch_evalexpr(handle, 'eval-special')) |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
208 sleep 10m |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
209 call assert_equal([-2, "foo\x7f\x10\x01bar"], ch_evalexpr(handle, 'eval-result')) |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
210 |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
211 " Send an eval request to get a line with special characters. |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
212 call setline(3, "a\nb\<CR>c\x01d\x7fe") |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
213 call assert_equal('ok', ch_evalexpr(handle, 'eval-getline')) |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
214 sleep 10m |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
215 call assert_equal([-3, "a\nb\<CR>c\x01d\x7fe"], ch_evalexpr(handle, 'eval-result')) |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
216 |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
217 " 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
|
218 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
|
219 sleep 10m |
8744
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
220 call assert_equal([-4, '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
|
221 |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7957
diff
changeset
|
222 " 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
|
223 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
|
224 sleep 10m |
8744
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
225 call assert_equal([-5, '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
|
226 |
7918
ce5a7a613867
commit https://github.com/vim/vim/commit/66624ff0d9e1de2fc5eb4f95f3a3a2ed70b10138
Christian Brabandt <cb@256bit.org>
parents:
7916
diff
changeset
|
227 " 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
|
228 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
|
229 sleep 10m |
8744
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8692
diff
changeset
|
230 call assert_equal([-5, '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
|
231 |
7939
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7935
diff
changeset
|
232 " Send an expr request |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
233 call assert_equal('ok', ch_evalexpr(handle, 'an expr')) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
234 call WaitForAssert({-> assert_equal('three', getline('$'))}) |
7939
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7935
diff
changeset
|
235 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
|
236 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
|
237 |
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7935
diff
changeset
|
238 " 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
|
239 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
|
240 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
|
241 |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
242 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
|
243 |
8157
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8132
diff
changeset
|
244 " 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
|
245 call assert_equal(v:none, ch_read(handle, {'timeout': 0})) |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
246 if exists('*reltimefloat') |
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
247 let start = reltime() |
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
248 call assert_equal(v:none, ch_read(handle, {'timeout': 333})) |
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
249 let elapsed = reltime(start) |
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
250 call assert_inrange(0.3, 0.6, reltimefloat(reltime(start))) |
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
251 endif |
8157
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8132
diff
changeset
|
252 |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8132
diff
changeset
|
253 " 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
|
254 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
|
255 let resp = ch_read(handle) |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8132
diff
changeset
|
256 call assert_equal(type([]), type(resp)) |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8132
diff
changeset
|
257 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
|
258 call assert_equal('waited', resp[1]) |
74b44d06d3c7
commit https://github.com/vim/vim/commit/6f3a544228c1faf92211cbaf8bbedb1dff883f90
Christian Brabandt <cb@256bit.org>
parents:
8132
diff
changeset
|
259 |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
260 " 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
|
261 call ch_sendexpr(handle, '!quit!') |
8007
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
262 endfunc |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
263 |
8007
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
264 func Test_communicate() |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
265 call s:run_server('Ch_communicate') |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
266 endfunc |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
267 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
268 func Test_communicate_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
269 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
270 call Test_communicate() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
271 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
272 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
273 func Test_communicate_unix() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
274 CheckUnix |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
275 call Test_communicate() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
276 call delete('Xtestsocket') |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
277 endfunc |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
278 |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
279 |
7916
54602dcac207
commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents:
7914
diff
changeset
|
280 " Test that we can open two channels. |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
281 func Ch_two_channels(port) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
282 let handle = ch_open(s:address(a:port), s:chopt) |
9587
05a56bbe34a1
commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents:
9527
diff
changeset
|
283 call assert_equal(v:t_channel, type(handle)) |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
284 if handle->ch_status() == "fail" |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
285 call assert_report("Can't open channel") |
7916
54602dcac207
commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents:
7914
diff
changeset
|
286 return |
54602dcac207
commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents:
7914
diff
changeset
|
287 endif |
8007
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
288 |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
289 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
|
290 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
291 let newhandle = ch_open(s:address(a:port), s:chopt) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8037
diff
changeset
|
292 if ch_status(newhandle) == "fail" |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
293 call assert_report("Can't open second channel") |
8007
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
294 return |
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
295 endif |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
296 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
|
297 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
|
298 |
54602dcac207
commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents:
7914
diff
changeset
|
299 call ch_close(handle) |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
300 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
|
301 |
8007
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
302 call ch_close(newhandle) |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
303 call assert_fails("call ch_close(newhandle)", 'E906:') |
8007
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
304 endfunc |
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
305 |
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
306 func Test_two_channels() |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
307 eval 'Test_two_channels()'->ch_log() |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
308 call s:run_server('Ch_two_channels') |
7916
54602dcac207
commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents:
7914
diff
changeset
|
309 endfunc |
54602dcac207
commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents:
7914
diff
changeset
|
310 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
311 func Test_two_channels_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
312 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
313 call Test_two_channels() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
314 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
315 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
316 func Test_two_channels_unix() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
317 CheckUnix |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
318 call Test_two_channels() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
319 call delete('Xtestsocket') |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
320 endfunc |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
321 |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
322 " Test that a server crash is handled gracefully. |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
323 func Ch_server_crash(port) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
324 let handle = ch_open(s:address(a:port), s:chopt) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8037
diff
changeset
|
325 if ch_status(handle) == "fail" |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
326 call assert_report("Can't open channel") |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
327 return |
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
328 endif |
8007
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
329 |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
330 call ch_evalexpr(handle, '!crash!') |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
331 |
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
332 sleep 10m |
8007
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
333 endfunc |
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
334 |
ac78cba9e72b
commit https://github.com/vim/vim/commit/d6a8d48587b2ff43c343fa365898576cc1e235ea
Christian Brabandt <cb@256bit.org>
parents:
8005
diff
changeset
|
335 func Test_server_crash() |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
336 call s:run_server('Ch_server_crash') |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7904
diff
changeset
|
337 endfunc |
7982
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7965
diff
changeset
|
338 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
339 func Test_server_crash_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
340 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
341 call Test_server_crash() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
342 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
343 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
344 func Test_server_crash_unix() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
345 CheckUnix |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
346 call Test_server_crash() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
347 call delete('Xtestsocket') |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
348 endfunc |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
349 |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
350 """"""""" |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
351 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
352 func Ch_handler(chan, msg) |
10428
a963dce191cf
commit https://github.com/vim/vim/commit/65e08ee1d26aa7bf341ac0e0400839d696d1ab64
Christian Brabandt <cb@256bit.org>
parents:
10422
diff
changeset
|
353 call ch_log('Ch_handler()') |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
354 unlet g:Ch_reply |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
355 let g:Ch_reply = a:msg |
8009
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
356 endfunc |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
357 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
358 func Ch_channel_handler(port) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
359 let handle = ch_open(s:address(a:port), s:chopt) |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8037
diff
changeset
|
360 if ch_status(handle) == "fail" |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
361 call assert_report("Can't open channel") |
8009
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
362 return |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
363 endif |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
364 |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
365 " 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
|
366 call assert_equal('ok', ch_evalexpr(handle, 'call me')) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
367 call WaitForAssert({-> assert_equal('we called you', g:Ch_reply)}) |
8009
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
368 |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
369 " 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
|
370 call ch_sendexpr(handle, 'call me again') |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
371 call WaitForAssert({-> assert_equal('we did call you', g:Ch_reply)}) |
8009
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
372 endfunc |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
373 |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
374 func Test_channel_handler() |
10030
3b4b2ac811f0
commit https://github.com/vim/vim/commit/6fc8227ebfbdfbbb48b81b679db81f421dbce79b
Christian Brabandt <cb@256bit.org>
parents:
9994
diff
changeset
|
375 let g:Ch_reply = "" |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
376 let s:chopt.callback = 'Ch_handler' |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
377 call s:run_server('Ch_channel_handler') |
10030
3b4b2ac811f0
commit https://github.com/vim/vim/commit/6fc8227ebfbdfbbb48b81b679db81f421dbce79b
Christian Brabandt <cb@256bit.org>
parents:
9994
diff
changeset
|
378 let g:Ch_reply = "" |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
379 let s:chopt.callback = function('Ch_handler') |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
380 call s:run_server('Ch_channel_handler') |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
381 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
382 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
383 func Test_channel_handler_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
384 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
385 call Test_channel_handler() |
8009
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
386 endfunc |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
8007
diff
changeset
|
387 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
388 func Test_channel_handler_unix() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
389 CheckUnix |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
390 call Test_channel_handler() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
391 call delete('Xtestsocket') |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
392 endfunc |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
393 |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
394 """"""""" |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
395 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
396 let g:Ch_reply = '' |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
397 func Ch_zeroHandler(chan, msg) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
398 unlet g:Ch_reply |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
399 let g:Ch_reply = a:msg |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
400 endfunc |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
401 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
402 let g:Ch_zero_reply = '' |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
403 func Ch_oneHandler(chan, msg) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
404 unlet g:Ch_zero_reply |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
405 let g:Ch_zero_reply = a:msg |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
406 endfunc |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
407 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
408 func Ch_channel_zero(port) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
409 let handle = (s:address(a:port))->ch_open(s:chopt) |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
410 if ch_status(handle) == "fail" |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
411 call assert_report("Can't open channel") |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
412 return |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
413 endif |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
414 |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
415 " Check that eval works. |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
416 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
|
417 |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
418 " Check that eval works if a zero id message is sent back. |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
419 let g:Ch_reply = '' |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
420 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
|
421 if s:has_handler |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
422 call WaitForAssert({-> assert_equal('zero index', g:Ch_reply)}) |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
423 else |
8449
3d567b5839c5
commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents:
8447
diff
changeset
|
424 sleep 20m |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
425 call assert_equal('', g:Ch_reply) |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
426 endif |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
427 |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
428 " Check that handler works if a zero id message is sent back. |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
429 let g:Ch_reply = '' |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
430 let g:Ch_zero_reply = '' |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
431 call ch_sendexpr(handle, 'send zero', {'callback': 'Ch_oneHandler'}) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
432 call WaitForAssert({-> assert_equal('sent zero', g:Ch_zero_reply)}) |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
433 if s:has_handler |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
434 call assert_equal('zero index', g:Ch_reply) |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
435 else |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
436 call assert_equal('', g:Ch_reply) |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
437 endif |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
438 endfunc |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
439 |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
440 func Test_zero_reply() |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
441 " Run with channel handler |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
442 let s:has_handler = 1 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
443 let s:chopt.callback = 'Ch_zeroHandler' |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
444 call s:run_server('Ch_channel_zero') |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
445 unlet s:chopt.callback |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
446 |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
447 " Run without channel handler |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
448 let s:has_handler = 0 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
449 call s:run_server('Ch_channel_zero') |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
450 endfunc |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
451 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
452 func Test_zero_reply_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
453 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
454 call Test_zero_reply() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
455 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
456 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
457 func Test_zero_reply_unix() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
458 CheckUnix |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
459 call Test_zero_reply() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
460 call delete('Xtestsocket') |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
461 endfunc |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
462 |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
463 |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
464 """"""""" |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8386
diff
changeset
|
465 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
466 let g:Ch_reply1 = "" |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
467 func Ch_handleRaw1(chan, msg) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
468 unlet g:Ch_reply1 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
469 let g:Ch_reply1 = a:msg |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
470 endfunc |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
471 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
472 let g:Ch_reply2 = "" |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
473 func Ch_handleRaw2(chan, msg) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
474 unlet g:Ch_reply2 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
475 let g:Ch_reply2 = a:msg |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
476 endfunc |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
477 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
478 let g:Ch_reply3 = "" |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
479 func Ch_handleRaw3(chan, msg) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
480 unlet g:Ch_reply3 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
481 let g:Ch_reply3 = a:msg |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
482 endfunc |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
483 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
484 func Ch_raw_one_time_callback(port) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
485 let handle = ch_open(s:address(a:port), s:chopt) |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
486 if ch_status(handle) == "fail" |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
487 call assert_report("Can't open channel") |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
488 return |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
489 endif |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
490 call ch_setoptions(handle, {'mode': 'raw'}) |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
491 |
10422
e664ee056a84
commit https://github.com/vim/vim/commit/4b785f69c0616dba5d3f38e8ce4b5398cec89407
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
492 " The messages are sent raw, we do our own JSON strings here. |
9973
01c3f981ce08
commit https://github.com/vim/vim/commit/dd74ab9b464f3d1a5f6f6395469b76f8e0e6dccd
Christian Brabandt <cb@256bit.org>
parents:
9969
diff
changeset
|
493 call ch_sendraw(handle, "[1, \"hello!\"]\n", {'callback': 'Ch_handleRaw1'}) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
494 call WaitForAssert({-> assert_equal("[1, \"got it\"]", g:Ch_reply1)}) |
9973
01c3f981ce08
commit https://github.com/vim/vim/commit/dd74ab9b464f3d1a5f6f6395469b76f8e0e6dccd
Christian Brabandt <cb@256bit.org>
parents:
9969
diff
changeset
|
495 call ch_sendraw(handle, "[2, \"echo something\"]\n", {'callback': 'Ch_handleRaw2'}) |
01c3f981ce08
commit https://github.com/vim/vim/commit/dd74ab9b464f3d1a5f6f6395469b76f8e0e6dccd
Christian Brabandt <cb@256bit.org>
parents:
9969
diff
changeset
|
496 call ch_sendraw(handle, "[3, \"wait a bit\"]\n", {'callback': 'Ch_handleRaw3'}) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
497 call WaitForAssert({-> assert_equal("[2, \"something\"]", g:Ch_reply2)}) |
8449
3d567b5839c5
commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents:
8447
diff
changeset
|
498 " wait for the 200 msec delayed reply |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
499 call WaitForAssert({-> assert_equal("[3, \"waited\"]", g:Ch_reply3)}) |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
500 endfunc |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
501 |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
502 func Test_raw_one_time_callback() |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
503 call s:run_server('Ch_raw_one_time_callback') |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
504 endfunc |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
505 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
506 func Test_raw_one_time_callback_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
507 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
508 call Test_raw_one_time_callback() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
509 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
510 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
511 func Test_raw_one_time_callback_unix() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
512 CheckUnix |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
513 call Test_raw_one_time_callback() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
514 call delete('Xtestsocket') |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
515 endfunc |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
516 |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
517 """"""""" |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
518 |
7982
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7965
diff
changeset
|
519 " 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
|
520 func Test_connect_waittime() |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
521 CheckFunction reltimefloat |
19715
e73167dd8cac
patch 8.2.0414: channel connect_waittime() test is flaky
Bram Moolenaar <Bram@vim.org>
parents:
19707
diff
changeset
|
522 " this is timing sensitive |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
523 |
7982
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7965
diff
changeset
|
524 let start = reltime() |
8005
d65aa95725d3
commit https://github.com/vim/vim/commit/a483326e3b04215b86fe9c582ac96bb9679f0812
Christian Brabandt <cb@256bit.org>
parents:
7988
diff
changeset
|
525 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
|
526 if ch_status(handle) != "fail" |
7982
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7965
diff
changeset
|
527 " Oops, port does exists. |
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7965
diff
changeset
|
528 call ch_close(handle) |
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7965
diff
changeset
|
529 else |
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7965
diff
changeset
|
530 let elapsed = reltime(start) |
7984
c166ff6797cb
commit https://github.com/vim/vim/commit/74f5e65bcc3d77ab879f56eb977f5038edccbcf8
Christian Brabandt <cb@256bit.org>
parents:
7982
diff
changeset
|
531 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
|
532 endif |
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7965
diff
changeset
|
533 |
8168
454a30a7590e
commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
534 " 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
|
535 " before giving up. If the socket does exist it can fail in various ways. |
19195
2ef19eed524a
patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents:
19157
diff
changeset
|
536 " Check for "Connection reset by peer" to avoid flakiness. |
7982
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7965
diff
changeset
|
537 let start = reltime() |
8168
454a30a7590e
commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
538 try |
454a30a7590e
commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
539 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
|
540 if ch_status(handle) != "fail" |
454a30a7590e
commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
541 " Oops, port does exists. |
454a30a7590e
commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
542 call ch_close(handle) |
454a30a7590e
commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
543 else |
8500
1227dc21865b
commit https://github.com/vim/vim/commit/ac42afd10b96424b89762871905e3e785cdfba3d
Christian Brabandt <cb@256bit.org>
parents:
8491
diff
changeset
|
544 " 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
|
545 " computer is busy with other things. |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
546 call assert_inrange(0.3, 1.5, reltimefloat(reltime(start))) |
8168
454a30a7590e
commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
547 endif |
454a30a7590e
commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
548 catch |
454a30a7590e
commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
549 if v:exception !~ 'Connection reset by peer' |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
550 call assert_report("Caught exception: " . v:exception) |
8168
454a30a7590e
commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
551 endif |
454a30a7590e
commit https://github.com/vim/vim/commit/08298fa1d3e32c2af476582792fc4f70cd57a59a
Christian Brabandt <cb@256bit.org>
parents:
8165
diff
changeset
|
552 endtry |
7982
5c30ba57aaea
commit https://github.com/vim/vim/commit/7a84dbe6be0ef0e1ffbb7148cfe4ab50b9ba8f41
Christian Brabandt <cb@256bit.org>
parents:
7965
diff
changeset
|
553 endfunc |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8027
diff
changeset
|
554 |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
555 """"""""" |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8380
diff
changeset
|
556 |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8078
diff
changeset
|
557 func Test_raw_pipe() |
10422
e664ee056a84
commit https://github.com/vim/vim/commit/4b785f69c0616dba5d3f38e8ce4b5398cec89407
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
558 " Add a dummy close callback to avoid that messages are dropped when calling |
e664ee056a84
commit https://github.com/vim/vim/commit/4b785f69c0616dba5d3f38e8ce4b5398cec89407
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
559 " ch_canread(). |
14675
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
560 " Also test the non-blocking option. |
10422
e664ee056a84
commit https://github.com/vim/vim/commit/4b785f69c0616dba5d3f38e8ce4b5398cec89407
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
561 let job = job_start(s:python . " test_channel_pipe.py", |
14675
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
562 \ {'mode': 'raw', 'drop': 'never', 'noblock': 1}) |
9587
05a56bbe34a1
commit https://github.com/vim/vim/commit/f562e72df726c6191fa305e1c0a113f1cfb87f76
Christian Brabandt <cb@256bit.org>
parents:
9527
diff
changeset
|
563 call assert_equal(v:t_job, type(job)) |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8078
diff
changeset
|
564 call assert_equal("run", job_status(job)) |
10233
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
565 |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
566 call assert_equal("open", ch_status(job)) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
567 call assert_equal("open", ch_status(job), {"part": "out"}) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
568 call assert_equal("open", ch_status(job), {"part": "err"}) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
569 call assert_fails('call ch_status(job, {"in_mode": "raw"})', 'E475:') |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
570 call assert_fails('call ch_status(job, {"part": "in"})', 'E475:') |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
571 |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
572 let dict = ch_info(job) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
573 call assert_true(dict.id != 0) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
574 call assert_equal('open', dict.status) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
575 call assert_equal('open', dict.out_status) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
576 call assert_equal('RAW', dict.out_mode) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
577 call assert_equal('pipe', dict.out_io) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
578 call assert_equal('open', dict.err_status) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
579 call assert_equal('RAW', dict.err_mode) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
580 call assert_equal('pipe', dict.err_io) |
d709622a18c9
commit https://github.com/vim/vim/commit/7ef3810d28b7ab2edbfcafab3fe8ad8bc2c2f138
Christian Brabandt <cb@256bit.org>
parents:
10147
diff
changeset
|
581 |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8078
diff
changeset
|
582 try |
8436
0e6fd2f802b3
commit https://github.com/vim/vim/commit/151f656e171f6ffbb0cbeb343cbcf2ffac0c36b0
Christian Brabandt <cb@256bit.org>
parents:
8430
diff
changeset
|
583 " 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
|
584 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
|
585 let msg = ch_readraw(job) |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8078
diff
changeset
|
586 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
|
587 |
8436
0e6fd2f802b3
commit https://github.com/vim/vim/commit/151f656e171f6ffbb0cbeb343cbcf2ffac0c36b0
Christian Brabandt <cb@256bit.org>
parents:
8430
diff
changeset
|
588 call ch_sendraw(job, "double this\n") |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
589 let g:handle = job->job_getchannel() |
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
590 call WaitFor('g:handle->ch_canread()') |
10422
e664ee056a84
commit https://github.com/vim/vim/commit/4b785f69c0616dba5d3f38e8ce4b5398cec89407
Christian Brabandt <cb@256bit.org>
parents:
10386
diff
changeset
|
591 unlet g:handle |
8436
0e6fd2f802b3
commit https://github.com/vim/vim/commit/151f656e171f6ffbb0cbeb343cbcf2ffac0c36b0
Christian Brabandt <cb@256bit.org>
parents:
8430
diff
changeset
|
592 let msg = ch_readraw(job) |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8078
diff
changeset
|
593 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
|
594 |
10030
3b4b2ac811f0
commit https://github.com/vim/vim/commit/6fc8227ebfbdfbbb48b81b679db81f421dbce79b
Christian Brabandt <cb@256bit.org>
parents:
9994
diff
changeset
|
595 let g:Ch_reply = "" |
3b4b2ac811f0
commit https://github.com/vim/vim/commit/6fc8227ebfbdfbbb48b81b679db81f421dbce79b
Christian Brabandt <cb@256bit.org>
parents:
9994
diff
changeset
|
596 call ch_sendraw(job, "double this\n", {'callback': 'Ch_handler'}) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
597 call WaitForAssert({-> assert_equal("this\nAND this\n", substitute(g:Ch_reply, "\r", "", 'g'))}) |
10030
3b4b2ac811f0
commit https://github.com/vim/vim/commit/6fc8227ebfbdfbbb48b81b679db81f421dbce79b
Christian Brabandt <cb@256bit.org>
parents:
9994
diff
changeset
|
598 |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
599 call assert_fails("let i = ch_evalraw(job, '2 + 2', {'callback' : 'abc'})", 'E917:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
600 call assert_fails("let i = ch_evalexpr(job, '2 + 2')", 'E912:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
601 call assert_fails("let i = ch_evalraw(job, '2 + 2', {'drop' : ''})", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
602 call assert_fails("let i = ch_evalraw(test_null_job(), '2 + 2')", 'E906:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
603 |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
604 let reply = job->ch_evalraw("quit\n", {'timeout': 100}) |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8078
diff
changeset
|
605 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
|
606 finally |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8078
diff
changeset
|
607 call job_stop(job) |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8078
diff
changeset
|
608 endtry |
8502
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8500
diff
changeset
|
609 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
610 let g:Ch_job = job |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
611 call WaitForAssert({-> assert_equal("dead", job_status(g:Ch_job))}) |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
612 let info = job->job_info() |
8502
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8500
diff
changeset
|
613 call assert_equal("dead", info.status) |
ee5cb2e9ed5a
commit https://github.com/vim/vim/commit/8950a563b306ce76f259573d91c2ddccdf52e32e
Christian Brabandt <cb@256bit.org>
parents:
8500
diff
changeset
|
614 call assert_equal("term", info.stoponexit) |
13740
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13650
diff
changeset
|
615 call assert_equal(2, len(info.cmd)) |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13650
diff
changeset
|
616 call assert_equal("test_channel_pipe.py", info.cmd[1]) |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13650
diff
changeset
|
617 |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13650
diff
changeset
|
618 let found = 0 |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13650
diff
changeset
|
619 for j in job_info() |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13650
diff
changeset
|
620 if j == job |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13650
diff
changeset
|
621 let found += 1 |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13650
diff
changeset
|
622 endif |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13650
diff
changeset
|
623 endfor |
f309afff6f25
patch 8.0.1742: cannot get a list of all the jobs
Christian Brabandt <cb@256bit.org>
parents:
13650
diff
changeset
|
624 call assert_equal(1, found) |
19724
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19715
diff
changeset
|
625 |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
626 call assert_fails("call job_stop('abc')", 'E475:') |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20923
diff
changeset
|
627 call assert_fails("call job_stop(job, [])", 'E730:') |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
628 call assert_fails("call job_stop(test_null_job())", 'E916:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
629 |
19724
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19715
diff
changeset
|
630 " Try to use the job and channel where a number is expected. This is not |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19715
diff
changeset
|
631 " related to testing the raw pipe. This test is here just to reuse the |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19715
diff
changeset
|
632 " already created job/channel. |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19715
diff
changeset
|
633 let ch = job_getchannel(job) |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19715
diff
changeset
|
634 call assert_fails('let i = job + 1', 'E910:') |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19715
diff
changeset
|
635 call assert_fails('let j = ch + 1', 'E913:') |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19715
diff
changeset
|
636 call assert_fails('echo 2.0 == job', 'E911:') |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19715
diff
changeset
|
637 call assert_fails('echo 2.0 == ch', 'E914:') |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8078
diff
changeset
|
638 endfunc |
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8078
diff
changeset
|
639 |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
640 func Test_raw_pipe_blob() |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
641 " Add a dummy close callback to avoid that messages are dropped when calling |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
642 " ch_canread(). |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
643 " Also test the non-blocking option. |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
644 let job = job_start(s:python . " test_channel_pipe.py", |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
645 \ {'mode': 'raw', 'drop': 'never', 'noblock': 1}) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
646 call assert_equal(v:t_job, type(job)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
647 call assert_equal("run", job_status(job)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
648 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
649 call assert_equal("open", ch_status(job)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
650 call assert_equal("open", ch_status(job), {"part": "out"}) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
651 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
652 try |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
653 " Create a blob with the echo command and write it. |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
654 let blob = 0z00 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
655 let cmd = "echo something\n" |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
656 for i in range(0, len(cmd) - 1) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
657 let blob[i] = char2nr(cmd[i]) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
658 endfor |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
659 call assert_equal(len(cmd), len(blob)) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
660 call ch_sendraw(job, blob) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
661 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
662 " Read a blob with the reply. |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
663 let msg = job->ch_readblob() |
15454
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
664 let expected = 'something' |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
665 for i in range(0, len(expected) - 1) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
666 call assert_equal(char2nr(expected[i]), msg[i]) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
667 endfor |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
668 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
669 let reply = ch_evalraw(job, "quit\n", {'timeout': 100}) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
670 call assert_equal("Goodbye!\n", substitute(reply, "\r", "", 'g')) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
671 finally |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
672 call job_stop(job) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
673 endtry |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
674 |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
675 let g:Ch_job = job |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
676 call WaitForAssert({-> assert_equal("dead", job_status(g:Ch_job))}) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
677 let info = job_info(job) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
678 call assert_equal("dead", info.status) |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
679 endfunc |
1d2b5c016f17
patch 8.1.0735: cannot handle binary data
Bram Moolenaar <Bram@vim.org>
parents:
15404
diff
changeset
|
680 |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8078
diff
changeset
|
681 func Test_nl_pipe() |
8504
0b31cc4b261e
commit https://github.com/vim/vim/commit/1adda3403d80e96446248a92ceafee036053765c
Christian Brabandt <cb@256bit.org>
parents:
8502
diff
changeset
|
682 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
|
683 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
|
684 try |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8027
diff
changeset
|
685 let handle = job_getchannel(job) |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
686 call ch_sendraw(handle, "echo something\n") |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
687 call assert_equal("something", handle->ch_readraw()) |
8084
3ea56a74077f
commit https://github.com/vim/vim/commit/9a6e33a19b18f20c25b73392cd2faa3ec4890c8c
Christian Brabandt <cb@256bit.org>
parents:
8078
diff
changeset
|
688 |
8384
764dba33605c
commit https://github.com/vim/vim/commit/c25558bff4ed10d2642e6f5c016701641c494916
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
689 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
|
690 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
|
691 |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
692 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
|
693 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
|
694 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
|
695 |
9238
7d13d180a6ae
commit https://github.com/vim/vim/commit/bbe8d91e695184771d7e45315258fab8eb3e6b07
Christian Brabandt <cb@256bit.org>
parents:
9191
diff
changeset
|
696 call ch_sendraw(handle, "split this line\n") |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
697 call assert_equal("this linethis linethis line", handle->ch_read()) |
9238
7d13d180a6ae
commit https://github.com/vim/vim/commit/bbe8d91e695184771d7e45315258fab8eb3e6b07
Christian Brabandt <cb@256bit.org>
parents:
9191
diff
changeset
|
698 |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
699 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
|
700 call assert_equal("Goodbye!", reply) |
8031
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8027
diff
changeset
|
701 finally |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8027
diff
changeset
|
702 call job_stop(job) |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8027
diff
changeset
|
703 endtry |
ece323e2b57f
commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab
Christian Brabandt <cb@256bit.org>
parents:
8027
diff
changeset
|
704 endfunc |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8045
diff
changeset
|
705 |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
706 func Stop_g_job() |
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
707 call job_stop(g:job) |
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
708 if has('win32') |
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
709 " On MS-Windows the server must close the file handle before we are able |
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
710 " to delete the file. |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
711 call WaitForAssert({-> assert_equal('dead', job_status(g:job))}) |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
712 sleep 10m |
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
713 endif |
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
714 endfunc |
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
715 |
8430
800423dbc260
commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents:
8426
diff
changeset
|
716 func Test_nl_read_file() |
800423dbc260
commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents:
8426
diff
changeset
|
717 call writefile(['echo something', 'echoerr wrong', 'double this'], 'Xinput') |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
718 let g: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
|
719 \ {'in_io': 'file', 'in_name': 'Xinput'}) |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
720 call assert_equal("run", job_status(g:job)) |
8430
800423dbc260
commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents:
8426
diff
changeset
|
721 try |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
722 let handle = job_getchannel(g:job) |
8430
800423dbc260
commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents:
8426
diff
changeset
|
723 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
|
724 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
|
725 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
|
726 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
|
727 finally |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
728 call Stop_g_job() |
8430
800423dbc260
commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents:
8426
diff
changeset
|
729 call delete('Xinput') |
800423dbc260
commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents:
8426
diff
changeset
|
730 endtry |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
731 call assert_fails("echo ch_read(test_null_channel(), {'callback' : 'abc'})", 'E475:') |
8430
800423dbc260
commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents:
8426
diff
changeset
|
732 endfunc |
800423dbc260
commit https://github.com/vim/vim/commit/b69fccf377f43544b86817b0de6cc1498a4ff9ec
Christian Brabandt <cb@256bit.org>
parents:
8426
diff
changeset
|
733 |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
734 func Test_nl_write_out_file() |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
735 let g: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
|
736 \ {'out_io': 'file', 'out_name': 'Xoutput'}) |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
737 call assert_equal("run", job_status(g:job)) |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
738 try |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
739 let handle = job_getchannel(g:job) |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
740 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
|
741 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
|
742 call ch_sendraw(handle, "double this\n") |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
743 call WaitForAssert({-> assert_equal(['line one', 'line two', 'this', 'AND this'], readfile('Xoutput'))}) |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
744 finally |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
745 call Stop_g_job() |
13357
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
746 call assert_equal(-1, match(s:get_resources(), '\(^\|/\)Xoutput$')) |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
747 call delete('Xoutput') |
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
748 endtry |
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
749 endfunc |
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
750 |
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
751 func Test_nl_write_err_file() |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
752 let g: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
|
753 \ {'err_io': 'file', 'err_name': 'Xoutput'}) |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
754 call assert_equal("run", job_status(g:job)) |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
755 try |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
756 let handle = job_getchannel(g:job) |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
757 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
|
758 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
|
759 call ch_sendraw(handle, "doubleerr this\n") |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
760 call WaitForAssert({-> assert_equal(['line one', 'line two', 'this', 'AND this'], readfile('Xoutput'))}) |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
761 finally |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
762 call Stop_g_job() |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
763 call delete('Xoutput') |
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
764 endtry |
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
765 endfunc |
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
766 |
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
767 func Test_nl_write_both_file() |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
768 let g: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
|
769 \ {'out_io': 'file', 'out_name': 'Xoutput', 'err_io': 'out'}) |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
770 call assert_equal("run", job_status(g:job)) |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
771 try |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
772 let handle = job_getchannel(g:job) |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
773 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
|
774 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
|
775 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
|
776 call ch_sendraw(handle, "doubleerr that\n") |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
777 call WaitForAssert({-> assert_equal(['line one', 'line two', 'this', 'AND this', 'that', 'AND that'], readfile('Xoutput'))}) |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
778 finally |
10060
cf9e550f17f6
commit https://github.com/vim/vim/commit/641ad6c7ac7367f95fd927b8efa4bf74ddb9ccf3
Christian Brabandt <cb@256bit.org>
parents:
10054
diff
changeset
|
779 call Stop_g_job() |
13357
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
780 call assert_equal(-1, match(s:get_resources(), '\(^\|/\)Xoutput$')) |
8447
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
781 call delete('Xoutput') |
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
782 endtry |
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
783 endfunc |
6f26b680c243
commit https://github.com/vim/vim/commit/e98d12105213975f37b8d653bd909bd787a2cda9
Christian Brabandt <cb@256bit.org>
parents:
8443
diff
changeset
|
784 |
9187
fb1a19011fbe
commit https://github.com/vim/vim/commit/01d46e41ba4967ee534db4b94ad642007634841e
Christian Brabandt <cb@256bit.org>
parents:
9147
diff
changeset
|
785 func BufCloseCb(ch) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
786 let g:Ch_bufClosed = 'yes' |
9187
fb1a19011fbe
commit https://github.com/vim/vim/commit/01d46e41ba4967ee534db4b94ad642007634841e
Christian Brabandt <cb@256bit.org>
parents:
9147
diff
changeset
|
787 endfunc |
fb1a19011fbe
commit https://github.com/vim/vim/commit/01d46e41ba4967ee534db4b94ad642007634841e
Christian Brabandt <cb@256bit.org>
parents:
9147
diff
changeset
|
788 |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
789 func Run_test_pipe_to_buffer(use_name, nomod, do_msg) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
790 let g:Ch_bufClosed = 'no' |
9187
fb1a19011fbe
commit https://github.com/vim/vim/commit/01d46e41ba4967ee534db4b94ad642007634841e
Christian Brabandt <cb@256bit.org>
parents:
9147
diff
changeset
|
791 let options = {'out_io': 'buffer', 'close_cb': 'BufCloseCb'} |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
792 let expected = ['', 'line one', 'line two', 'this', 'AND this', 'Goodbye!'] |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
793 if a:use_name |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8506
diff
changeset
|
794 let options['out_name'] = 'pipe-output' |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
795 if a:do_msg |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
796 let expected[0] = 'Reading from channel output...' |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
797 else |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
798 let options['out_msg'] = 0 |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
799 call remove(expected, 0) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
800 endif |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
801 else |
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
802 sp pipe-output |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8506
diff
changeset
|
803 let options['out_buf'] = bufnr('%') |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
804 quit |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
805 call remove(expected, 0) |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
806 endif |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
807 if a:nomod |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
808 let options['out_modifiable'] = 0 |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
809 endif |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
810 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
|
811 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
|
812 try |
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
813 let handle = job_getchannel(job) |
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
814 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
|
815 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
|
816 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
|
817 call ch_sendraw(handle, "quit\n") |
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
818 sp pipe-output |
12734
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
819 call WaitFor('line("$") == ' . len(expected) . ' && g:Ch_bufClosed == "yes"') |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
820 call assert_equal(expected, getline(1, '$')) |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
821 if a:nomod |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
822 call assert_equal(0, &modifiable) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
823 else |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
824 call assert_equal(1, &modifiable) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
825 endif |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
826 call assert_equal('yes', g:Ch_bufClosed) |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
827 bwipe! |
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
828 finally |
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
829 call job_stop(job) |
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
830 endtry |
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
831 endfunc |
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
832 |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
833 func Test_pipe_to_buffer_name() |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
834 call Run_test_pipe_to_buffer(1, 0, 1) |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
835 endfunc |
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
836 |
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
837 func Test_pipe_to_buffer_nr() |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
838 call Run_test_pipe_to_buffer(0, 0, 1) |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
839 endfunc |
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
840 |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
841 func Test_pipe_to_buffer_name_nomod() |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
842 call Run_test_pipe_to_buffer(1, 1, 1) |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
843 endfunc |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
844 |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
845 func Test_pipe_to_buffer_name_nomsg() |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
846 call Run_test_pipe_to_buffer(1, 0, 1) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
847 endfunc |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
848 |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
849 func Test_close_output_buffer() |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
25891
diff
changeset
|
850 let g:test_is_flaky = 1 |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
851 enew! |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
852 let test_lines = ['one', 'two'] |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
853 call setline(1, test_lines) |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
854 let options = {'out_io': 'buffer'} |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
855 let options['out_name'] = 'buffer-output' |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
856 let options['out_msg'] = 0 |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
857 split buffer-output |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
858 let job = job_start(s:python . " test_channel_write.py", options) |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
859 call assert_equal("run", job_status(job)) |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
860 try |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
861 call WaitForAssert({-> assert_equal(3, line('$'))}) |
11666
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
862 quit! |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
863 sleep 100m |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
864 " Make sure the write didn't happen to the wrong buffer. |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
865 call assert_equal(test_lines, getline(1, line('$'))) |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
866 call assert_equal(-1, bufwinnr('buffer-output')) |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
867 sbuf buffer-output |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
868 call assert_notequal(-1, bufwinnr('buffer-output')) |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
869 sleep 100m |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
870 close " no more writes |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
871 bwipe! |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
872 finally |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
873 call job_stop(job) |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
874 endtry |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
875 endfunc |
5cd9ba96561d
patch 8.0.0716: not easy to start Vim cleanly
Christian Brabandt <cb@256bit.org>
parents:
11183
diff
changeset
|
876 |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
877 func Run_test_pipe_err_to_buffer(use_name, nomod, do_msg) |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8506
diff
changeset
|
878 let options = {'err_io': 'buffer'} |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
879 let expected = ['', 'line one', 'line two', 'this', 'AND this'] |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
880 if a:use_name |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8506
diff
changeset
|
881 let options['err_name'] = 'pipe-err' |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
882 if a:do_msg |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
883 let expected[0] = 'Reading from channel error...' |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
884 else |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
885 let options['err_msg'] = 0 |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
886 call remove(expected, 0) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
887 endif |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
888 else |
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
889 sp pipe-err |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8506
diff
changeset
|
890 let options['err_buf'] = bufnr('%') |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
891 quit |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
892 call remove(expected, 0) |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
893 endif |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
894 if a:nomod |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
895 let options['err_modifiable'] = 0 |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
896 endif |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
897 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
|
898 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
|
899 try |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
900 let handle = job_getchannel(job) |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
901 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
|
902 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
|
903 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
|
904 call ch_sendraw(handle, "quit\n") |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
905 sp pipe-err |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
906 call WaitForAssert({-> assert_equal(expected, getline(1, '$'))}) |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
907 if a:nomod |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
908 call assert_equal(0, &modifiable) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
909 else |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
910 call assert_equal(1, &modifiable) |
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
911 endif |
8463
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
912 bwipe! |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
913 finally |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
914 call job_stop(job) |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
915 endtry |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
916 endfunc |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
917 |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
918 func Test_pipe_err_to_buffer_name() |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
919 call Run_test_pipe_err_to_buffer(1, 0, 1) |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
920 endfunc |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
921 |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
922 func Test_pipe_err_to_buffer_nr() |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
923 call Run_test_pipe_err_to_buffer(0, 0, 1) |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
924 endfunc |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
925 |
9147
053bc64433ec
commit https://github.com/vim/vim/commit/9f5842e63fc63d438cbffcec503e072a06f74dc2
Christian Brabandt <cb@256bit.org>
parents:
9108
diff
changeset
|
926 func Test_pipe_err_to_buffer_name_nomod() |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
927 call Run_test_pipe_err_to_buffer(1, 1, 1) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
928 endfunc |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
929 |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
930 func Test_pipe_err_to_buffer_name_nomsg() |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
931 call Run_test_pipe_err_to_buffer(1, 0, 0) |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
932 endfunc |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
933 |
8463
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
934 func Test_pipe_both_to_buffer() |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
935 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
|
936 \ {'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
|
937 call assert_equal("run", job_status(job)) |
20178
2fb397573541
patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
938 let handle = job_getchannel(job) |
2fb397573541
patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
939 call assert_equal(bufnr('pipe-err'), ch_getbufnr(handle, 'out')) |
2fb397573541
patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
940 call assert_equal(bufnr('pipe-err'), ch_getbufnr(handle, 'err')) |
8463
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
941 try |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
942 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
|
943 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
|
944 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
|
945 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
|
946 call ch_sendraw(handle, "quit\n") |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
947 sp pipe-err |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
948 call WaitForAssert({-> assert_equal(['Reading from channel output...', 'line one', 'line two', 'this', 'AND this', 'that', 'AND that', 'Goodbye!'], getline(1, '$'))}) |
8463
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
949 bwipe! |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
950 finally |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
951 call job_stop(job) |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
952 endtry |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
953 endfunc |
508504ca52ac
commit https://github.com/vim/vim/commit/6ff02c96519946716069f05c62849986a706033b
Christian Brabandt <cb@256bit.org>
parents:
8459
diff
changeset
|
954 |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
955 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
|
956 sp pipe-input |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8384
diff
changeset
|
957 call setline(1, ['echo one', 'echo two', 'echo three']) |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
958 let options = {'in_io': 'buffer', 'block_write': 1} |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
959 if a:use_name |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8506
diff
changeset
|
960 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
|
961 else |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8506
diff
changeset
|
962 let options['in_buf'] = bufnr('%') |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
963 endif |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8384
diff
changeset
|
964 |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
965 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
|
966 call assert_equal("run", job_status(job)) |
20178
2fb397573541
patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
967 if has('unix') && !a:use_name |
2fb397573541
patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
968 call assert_equal(bufnr('%'), ch_getbufnr(job, 'in')) |
2fb397573541
patch 8.2.0644: insufficient testing for invalid function arguments
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
969 endif |
8386
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8384
diff
changeset
|
970 try |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8384
diff
changeset
|
971 let handle = job_getchannel(job) |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8384
diff
changeset
|
972 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
|
973 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
|
974 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
|
975 bwipe! |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8384
diff
changeset
|
976 finally |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8384
diff
changeset
|
977 call job_stop(job) |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8384
diff
changeset
|
978 endtry |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8384
diff
changeset
|
979 endfunc |
3b9a306724ec
commit https://github.com/vim/vim/commit/014069a7ac51557e531eb3c8b94e36f2193f6c21
Christian Brabandt <cb@256bit.org>
parents:
8384
diff
changeset
|
980 |
8477
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
981 func Test_pipe_from_buffer_name() |
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
982 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
|
983 endfunc |
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
984 |
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
985 func Test_pipe_from_buffer_nr() |
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
986 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
|
987 endfunc |
c08c6d19db4d
commit https://github.com/vim/vim/commit/29fd03878c41526a586d77b3f3cd7938d26297af
Christian Brabandt <cb@256bit.org>
parents:
8471
diff
changeset
|
988 |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
989 func Run_pipe_through_sort(all, use_buffer) |
17657
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17559
diff
changeset
|
990 CheckExecutable sort |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
25891
diff
changeset
|
991 let g:test_is_flaky = 1 |
17657
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17559
diff
changeset
|
992 |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
993 let options = {'out_io': 'buffer', 'out_name': 'sortout'} |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
994 if a:use_buffer |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
995 split sortin |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
996 call setline(1, ['ccc', 'aaa', 'ddd', 'bbb', 'eee']) |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
997 let options.in_io = 'buffer' |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
998 let options.in_name = 'sortin' |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
999 endif |
10052
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1000 if !a:all |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1001 let options.in_top = 2 |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1002 let options.in_bot = 4 |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1003 endif |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1004 let job = job_start('sort', options) |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1005 |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1006 if !a:use_buffer |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1007 call assert_equal("run", job_status(job)) |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1008 call ch_sendraw(job, "ccc\naaa\nddd\nbbb\neee\n") |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
1009 eval job->ch_close_in() |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1010 endif |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1011 |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1012 call WaitForAssert({-> assert_equal("dead", job_status(job))}) |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1013 |
10052
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1014 sp sortout |
10090
68303019acc9
commit https://github.com/vim/vim/commit/f7f3e32fcc4984d87f26337316379c2e2d90f7f1
Christian Brabandt <cb@256bit.org>
parents:
10060
diff
changeset
|
1015 call WaitFor('line("$") > 3') |
10052
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1016 call assert_equal('Reading from channel output...', getline(1)) |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1017 if a:all |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1018 call assert_equal(['aaa', 'bbb', 'ccc', 'ddd', 'eee'], getline(2, 6)) |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1019 else |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1020 call assert_equal(['aaa', 'bbb', 'ddd'], getline(2, 4)) |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1021 endif |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1022 |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1023 call job_stop(job) |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1024 if a:use_buffer |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1025 bwipe! sortin |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1026 endif |
10052
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1027 bwipe! sortout |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1028 endfunc |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1029 |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1030 func Test_pipe_through_sort_all() |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1031 call Run_pipe_through_sort(1, 1) |
10052
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1032 endfunc |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1033 |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1034 func Test_pipe_through_sort_some() |
10054
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1035 call Run_pipe_through_sort(0, 1) |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1036 endfunc |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1037 |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1038 func Test_pipe_through_sort_feed() |
d4b7232fc63a
commit https://github.com/vim/vim/commit/0874a83e9be1b39fdb217f02b427bf1d6133a4d8
Christian Brabandt <cb@256bit.org>
parents:
10052
diff
changeset
|
1039 call Run_pipe_through_sort(1, 0) |
10052
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1040 endfunc |
c1ba49441c90
commit https://github.com/vim/vim/commit/d8b554904d18fe19bd9fa79dbda880845cb017d2
Christian Brabandt <cb@256bit.org>
parents:
10030
diff
changeset
|
1041 |
8291
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8285
diff
changeset
|
1042 func Test_pipe_to_nameless_buffer() |
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8285
diff
changeset
|
1043 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
|
1044 \ {'out_io': 'buffer'}) |
8291
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8285
diff
changeset
|
1045 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
|
1046 try |
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8285
diff
changeset
|
1047 let handle = job_getchannel(job) |
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8285
diff
changeset
|
1048 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
|
1049 call ch_sendraw(handle, "echo line two\n") |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
1050 exe handle->ch_getbufnr("out") .. 'sbuf' |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1051 call WaitFor('line("$") >= 3') |
8291
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8285
diff
changeset
|
1052 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
|
1053 bwipe! |
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8285
diff
changeset
|
1054 finally |
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8285
diff
changeset
|
1055 call job_stop(job) |
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8285
diff
changeset
|
1056 endtry |
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8285
diff
changeset
|
1057 endfunc |
ac0c43e7af20
commit https://github.com/vim/vim/commit/c7f0ebc6d1e1cdaed816b88a0d6092c5ace615eb
Christian Brabandt <cb@256bit.org>
parents:
8285
diff
changeset
|
1058 |
8346
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8324
diff
changeset
|
1059 func Test_pipe_to_buffer_json() |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1060 CheckFunction reltimefloat |
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1061 |
8346
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8324
diff
changeset
|
1062 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
|
1063 \ {'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
|
1064 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
|
1065 try |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8324
diff
changeset
|
1066 let handle = job_getchannel(job) |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8324
diff
changeset
|
1067 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
|
1068 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
|
1069 exe ch_getbufnr(handle, "out") . 'sbuf' |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1070 call WaitFor('line("$") >= 3') |
8346
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8324
diff
changeset
|
1071 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
|
1072 bwipe! |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8324
diff
changeset
|
1073 finally |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8324
diff
changeset
|
1074 call job_stop(job) |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8324
diff
changeset
|
1075 endtry |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8324
diff
changeset
|
1076 endfunc |
8fa75a4c39bd
commit https://github.com/vim/vim/commit/cc7f8be3e0e6c4d902b02052a862e21c3a3fbe22
Christian Brabandt <cb@256bit.org>
parents:
8324
diff
changeset
|
1077 |
8426
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1078 " 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
|
1079 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
|
1080 for i in range(100) |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1081 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
|
1082 break |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1083 endif |
8449
3d567b5839c5
commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents:
8447
diff
changeset
|
1084 sleep 10m |
8426
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1085 endfor |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1086 endfunc |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1087 |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1088 func Test_pipe_io_two_buffers() |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1089 " 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
|
1090 split pipe-output |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1091 set buftype=nofile |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1092 split pipe-input |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1093 set buftype=nofile |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1094 |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1095 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
|
1096 \ {'in_io': 'buffer', 'in_name': 'pipe-input', 'in_top': 0, |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1097 \ 'out_io': 'buffer', 'out_name': 'pipe-output', |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1098 \ 'block_write': 1}) |
8426
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1099 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
|
1100 try |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1101 exe "normal Gaecho hello\<CR>" |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1102 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
|
1103 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
|
1104 call assert_equal('hello', getline('$')) |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1105 |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1106 exe bufwinnr('pipe-input') . "wincmd w" |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1107 exe "normal Gadouble this\<CR>" |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1108 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
|
1109 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
|
1110 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
|
1111 call assert_equal('AND this', getline('$')) |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1112 |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1113 bwipe! |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1114 exe bufwinnr('pipe-input') . "wincmd w" |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1115 bwipe! |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1116 finally |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1117 call job_stop(job) |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1118 endtry |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1119 endfunc |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1120 |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1121 func Test_pipe_io_one_buffer() |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1122 " 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
|
1123 split pipe-io |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1124 set buftype=nofile |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1125 |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1126 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
|
1127 \ {'in_io': 'buffer', 'in_name': 'pipe-io', 'in_top': 0, |
8761
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1128 \ 'out_io': 'buffer', 'out_name': 'pipe-io', |
f8707ec9efe4
commit https://github.com/vim/vim/commit/8b877ac38e96424a08a8b8eb713ef4b3cf0064be
Christian Brabandt <cb@256bit.org>
parents:
8753
diff
changeset
|
1129 \ 'block_write': 1}) |
8426
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1130 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
|
1131 try |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1132 exe "normal Goecho hello\<CR>" |
8449
3d567b5839c5
commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents:
8447
diff
changeset
|
1133 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
|
1134 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
|
1135 |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1136 exe "normal Gadouble this\<CR>" |
8449
3d567b5839c5
commit https://github.com/vim/vim/commit/9fe885e49ade94e6277db0dd18a5bbc1c94c60c4
Christian Brabandt <cb@256bit.org>
parents:
8447
diff
changeset
|
1137 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
|
1138 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
|
1139 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
|
1140 |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1141 bwipe! |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1142 finally |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1143 call job_stop(job) |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1144 endtry |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1145 endfunc |
02ce040591c8
commit https://github.com/vim/vim/commit/3f39f648662bf8723f687d14694041779ed0780c
Christian Brabandt <cb@256bit.org>
parents:
8424
diff
changeset
|
1146 |
17557
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1147 func Test_write_to_buffer_and_scroll() |
17657
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17559
diff
changeset
|
1148 CheckScreendump |
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17559
diff
changeset
|
1149 |
17557
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1150 let lines =<< trim END |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1151 new Xscrollbuffer |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1152 call setline(1, range(1, 200)) |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1153 $ |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1154 redraw |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1155 wincmd w |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1156 call deletebufline('Xscrollbuffer', 1, '$') |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1157 if has('win32') |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1158 let cmd = ['cmd', '/c', 'echo sometext'] |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1159 else |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1160 let cmd = [&shell, &shellcmdflag, 'echo sometext'] |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1161 endif |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1162 call job_start(cmd, #{out_io: 'buffer', out_name: 'Xscrollbuffer'}) |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1163 END |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1164 call writefile(lines, 'XtestBufferScroll') |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1165 let buf = RunVimInTerminal('-S XtestBufferScroll', #{rows: 10}) |
19954
c087099e9163
patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents:
19852
diff
changeset
|
1166 call TermWait(buf, 50) |
17557
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1167 call VerifyScreenDump(buf, 'Test_job_buffer_scroll_1', {}) |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1168 |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1169 " clean up |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1170 call StopVimInTerminal(buf) |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1171 call delete('XtestBufferScroll') |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1172 endfunc |
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1173 |
8455
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1174 func Test_pipe_null() |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1175 " 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
|
1176 " properly. |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1177 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
|
1178 \ {'in_io': 'null'}) |
8455
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1179 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
|
1180 try |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1181 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
|
1182 finally |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1183 call job_stop(job) |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1184 endtry |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1185 |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1186 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
|
1187 \ {'out_io': 'null'}) |
8455
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1188 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
|
1189 try |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1190 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
|
1191 finally |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1192 call job_stop(job) |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1193 endtry |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1194 |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1195 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
|
1196 \ {'err_io': 'null'}) |
8455
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1197 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
|
1198 try |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1199 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
|
1200 finally |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1201 call job_stop(job) |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1202 endtry |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1203 |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1204 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
|
1205 \ {'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
|
1206 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
|
1207 call job_stop(job) |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1208 |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1209 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
|
1210 \ {'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
|
1211 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
|
1212 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
|
1213 call assert_equal('fail', ch_status(job)) |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
1214 call assert_equal('no process', string(test_null_job())) |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
1215 call assert_equal('channel fail', string(test_null_channel())) |
8455
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1216 call job_stop(job) |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1217 endfunc |
d0717262d802
commit https://github.com/vim/vim/commit/f65333c9b59654a70f2a07200f65c93dfcaa49b3
Christian Brabandt <cb@256bit.org>
parents:
8449
diff
changeset
|
1218 |
9367
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1219 func Test_pipe_to_buffer_raw() |
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1220 let options = {'out_mode': 'raw', 'out_io': 'buffer', 'out_name': 'testout'} |
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1221 split testout |
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1222 let job = job_start([s:python, '-c', |
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1223 \ 'import sys; [sys.stdout.write(".") and sys.stdout.flush() for _ in range(10000)]'], options) |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1224 " the job may be done quickly, also accept "dead" |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1225 call assert_match('^\%(dead\|run\)$', job_status(job)) |
13650
87ffb7f85b28
patch 8.0.1697: various tests are still a bit flaky
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
1226 call WaitFor('len(join(getline(1, "$"), "")) >= 10000') |
9367
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1227 try |
12734
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1228 let totlen = 0 |
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1229 for line in getline(1, '$') |
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1230 call assert_equal('', substitute(line, '^\.*', '', '')) |
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1231 let totlen += len(line) |
9367
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1232 endfor |
12734
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1233 call assert_equal(10000, totlen) |
9367
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1234 finally |
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1235 call job_stop(job) |
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1236 bwipe! |
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1237 endtry |
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1238 endfunc |
2465b6cda394
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Christian Brabandt <cb@256bit.org>
parents:
9266
diff
changeset
|
1239 |
8491
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1240 func Test_reuse_channel() |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1241 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
|
1242 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
|
1243 let handle = job_getchannel(job) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1244 try |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1245 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
|
1246 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
|
1247 finally |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1248 call job_stop(job) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1249 endtry |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1250 |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1251 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
|
1252 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
|
1253 let handle = job_getchannel(job) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1254 try |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1255 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
|
1256 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
|
1257 finally |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1258 call job_stop(job) |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1259 endtry |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1260 endfunc |
daebcbd87bd3
commit https://github.com/vim/vim/commit/de27989157f35172b25f9e01e0c147ed8f6ae3ce
Christian Brabandt <cb@256bit.org>
parents:
8477
diff
changeset
|
1261 |
8676
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1262 func Test_out_cb() |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
25891
diff
changeset
|
1263 let g:test_is_flaky = 1 |
8676
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1264 let dict = {'thisis': 'dict: '} |
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1265 func dict.outHandler(chan, msg) dict |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10524
diff
changeset
|
1266 if type(a:msg) == v:t_string |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10524
diff
changeset
|
1267 let g:Ch_outmsg = self.thisis . a:msg |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10524
diff
changeset
|
1268 else |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10524
diff
changeset
|
1269 let g:Ch_outobj = a:msg |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10524
diff
changeset
|
1270 endif |
8676
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1271 endfunc |
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1272 func dict.errHandler(chan, msg) dict |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1273 let g:Ch_errmsg = self.thisis . a:msg |
8676
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1274 endfunc |
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1275 let job = job_start(s:python . " test_channel_pipe.py", |
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1276 \ {'out_cb': dict.outHandler, |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1277 \ 'out_mode': 'json', |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1278 \ 'err_cb': dict.errHandler, |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1279 \ 'err_mode': 'json'}) |
8676
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1280 call assert_equal("run", job_status(job)) |
20156
49694eceaa55
patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents:
20120
diff
changeset
|
1281 call test_garbagecollect_now() |
8676
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1282 try |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1283 let g:Ch_outmsg = '' |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1284 let g:Ch_errmsg = '' |
8676
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1285 call ch_sendraw(job, "echo [0, \"hello\"]\n") |
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1286 call ch_sendraw(job, "echoerr [0, \"there\"]\n") |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1287 call WaitForAssert({-> assert_equal("dict: hello", g:Ch_outmsg)}) |
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1288 call WaitForAssert({-> assert_equal("dict: there", g:Ch_errmsg)}) |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10524
diff
changeset
|
1289 |
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10524
diff
changeset
|
1290 " Receive a json object split in pieces |
19441
a5ac657fcd70
patch 8.2.0278: channel test is flaky on Mac
Bram Moolenaar <Bram@vim.org>
parents:
19362
diff
changeset
|
1291 let g:Ch_outobj = '' |
10845
c31782d57569
patch 8.0.0312: failure when a channel receives a split json message
Christian Brabandt <cb@256bit.org>
parents:
10524
diff
changeset
|
1292 call ch_sendraw(job, "echosplit [0, {\"one\": 1,| \"tw|o\": 2, \"three\": 3|}]\n") |
19838
4403ab355d5e
patch 8.2.0475: channel out_cb test still fails sometimes on Mac
Bram Moolenaar <Bram@vim.org>
parents:
19793
diff
changeset
|
1293 " For unknown reasons this can be very slow on Mac. |
26610
95a267994eac
patch 8.2.3834: Test_out_cb often fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
1294 " Increase the timeout on every run. |
95a267994eac
patch 8.2.3834: Test_out_cb often fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
1295 if g:run_nr == 1 |
95a267994eac
patch 8.2.3834: Test_out_cb often fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
1296 let timeout = 5000 |
95a267994eac
patch 8.2.3834: Test_out_cb often fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
1297 elseif g:run_nr == 2 |
95a267994eac
patch 8.2.3834: Test_out_cb often fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
1298 let timeout = 10000 |
95a267994eac
patch 8.2.3834: Test_out_cb often fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
1299 elseif g:run_nr == 3 |
19838
4403ab355d5e
patch 8.2.0475: channel out_cb test still fails sometimes on Mac
Bram Moolenaar <Bram@vim.org>
parents:
19793
diff
changeset
|
1300 let timeout = 20000 |
4403ab355d5e
patch 8.2.0475: channel out_cb test still fails sometimes on Mac
Bram Moolenaar <Bram@vim.org>
parents:
19793
diff
changeset
|
1301 else |
26610
95a267994eac
patch 8.2.3834: Test_out_cb often fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
25969
diff
changeset
|
1302 let timeout = 40000 |
19838
4403ab355d5e
patch 8.2.0475: channel out_cb test still fails sometimes on Mac
Bram Moolenaar <Bram@vim.org>
parents:
19793
diff
changeset
|
1303 endif |
4403ab355d5e
patch 8.2.0475: channel out_cb test still fails sometimes on Mac
Bram Moolenaar <Bram@vim.org>
parents:
19793
diff
changeset
|
1304 call WaitForAssert({-> assert_equal({'one': 1, 'two': 2, 'three': 3}, g:Ch_outobj)}, timeout) |
8676
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1305 finally |
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1306 call job_stop(job) |
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1307 endtry |
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1308 endfunc |
289765409225
commit https://github.com/vim/vim/commit/75f7265dd402665b8600fdf21ba33f19db06ac0d
Christian Brabandt <cb@256bit.org>
parents:
8669
diff
changeset
|
1309 |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1310 func Test_out_close_cb() |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1311 let s:counter = 1 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1312 let g:Ch_msg1 = '' |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1313 let g:Ch_closemsg = 0 |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1314 func! OutHandler(chan, msg) |
9044
5abf6f38cbbb
commit https://github.com/vim/vim/commit/d75263c020a5044fa73bc8cd57ce73ca5e23b360
Christian Brabandt <cb@256bit.org>
parents:
9007
diff
changeset
|
1315 if s:counter == 1 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1316 let g:Ch_msg1 = a:msg |
9044
5abf6f38cbbb
commit https://github.com/vim/vim/commit/d75263c020a5044fa73bc8cd57ce73ca5e23b360
Christian Brabandt <cb@256bit.org>
parents:
9007
diff
changeset
|
1317 endif |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1318 let s:counter += 1 |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1319 endfunc |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1320 func! CloseHandler(chan) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1321 let g:Ch_closemsg = s:counter |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1322 let s:counter += 1 |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1323 endfunc |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1324 let job = job_start(s:python . " test_channel_pipe.py quit now", |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1325 \ {'out_cb': 'OutHandler', |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1326 \ 'close_cb': 'CloseHandler'}) |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1327 " the job may be done quickly, also accept "dead" |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1328 call assert_match('^\%(dead\|run\)$', job_status(job)) |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1329 try |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1330 call WaitForAssert({-> assert_equal('quit', g:Ch_msg1)}) |
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1331 call WaitForAssert({-> assert_equal(2, g:Ch_closemsg)}) |
9003
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1332 finally |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1333 call job_stop(job) |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1334 delfunc OutHandler |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1335 delfunc CloseHandler |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1336 endtry |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1337 endfunc |
072556995a8e
commit https://github.com/vim/vim/commit/b2658a1ab02cd0ba848164f70c7c464fdc398162
Christian Brabandt <cb@256bit.org>
parents:
8881
diff
changeset
|
1338 |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
1339 func Test_read_in_close_cb() |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1340 let g:Ch_received = '' |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
1341 func! CloseHandler(chan) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1342 let g:Ch_received = ch_read(a:chan) |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
1343 endfunc |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
1344 let job = job_start(s:python . " test_channel_pipe.py quit now", |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
1345 \ {'close_cb': 'CloseHandler'}) |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1346 " the job may be done quickly, also accept "dead" |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1347 call assert_match('^\%(dead\|run\)$', job_status(job)) |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
1348 try |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1349 call WaitForAssert({-> assert_equal('quit', g:Ch_received)}) |
9007
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
1350 finally |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
1351 call job_stop(job) |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
1352 delfunc CloseHandler |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
1353 endtry |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
1354 endfunc |
d5c6f1c5cd28
commit https://github.com/vim/vim/commit/437905c25d4cedfa16d0f87392e4a000d22362b7
Christian Brabandt <cb@256bit.org>
parents:
9003
diff
changeset
|
1355 |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1356 " Use channel in NL mode but received text does not end in NL. |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1357 func Test_read_in_close_cb_incomplete() |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1358 let g:Ch_received = '' |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1359 func! CloseHandler(chan) |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1360 while ch_status(a:chan, {'part': 'out'}) == 'buffered' |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1361 let g:Ch_received .= ch_read(a:chan) |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1362 endwhile |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1363 endfunc |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1364 let job = job_start(s:python . " test_channel_pipe.py incomplete", |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1365 \ {'close_cb': 'CloseHandler'}) |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1366 " the job may be done quickly, also accept "dead" |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1367 call assert_match('^\%(dead\|run\)$', job_status(job)) |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1368 try |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1369 call WaitForAssert({-> assert_equal('incomplete', g:Ch_received)}) |
13010
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1370 finally |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1371 call job_stop(job) |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1372 delfunc CloseHandler |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1373 endtry |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1374 endfunc |
c522585ce88d
patch 8.0.1381: ch_readraw() waits for NL if channel mode is NL
Christian Brabandt <cb@256bit.org>
parents:
12979
diff
changeset
|
1375 |
9527
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1376 func Test_out_cb_lambda() |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1377 let job = job_start(s:python . " test_channel_pipe.py", |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1378 \ {'out_cb': {ch, msg -> execute("let g:Ch_outmsg = 'lambda: ' . msg")}, |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1379 \ 'out_mode': 'json', |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1380 \ 'err_cb': {ch, msg -> execute(":let g:Ch_errmsg = 'lambda: ' . msg")}, |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1381 \ 'err_mode': 'json'}) |
9527
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1382 call assert_equal("run", job_status(job)) |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1383 try |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1384 let g:Ch_outmsg = '' |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1385 let g:Ch_errmsg = '' |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1386 call ch_sendraw(job, "echo [0, \"hello\"]\n") |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1387 call ch_sendraw(job, "echoerr [0, \"there\"]\n") |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1388 call WaitForAssert({-> assert_equal("lambda: hello", g:Ch_outmsg)}) |
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1389 call WaitForAssert({-> assert_equal("lambda: there", g:Ch_errmsg)}) |
9527
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1390 finally |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1391 call job_stop(job) |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1392 endtry |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1393 endfunc |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1394 |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
1395 func Test_close_and_exit_cb() |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
25891
diff
changeset
|
1396 let g:test_is_flaky = 1 |
12734
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1397 let g:retdict = {'ret': {}} |
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1398 func g:retdict.close_cb(ch) dict |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
1399 let self.ret['close_cb'] = a:ch->ch_getjob()->job_status() |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
1400 endfunc |
12734
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1401 func g:retdict.exit_cb(job, status) dict |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
1402 let self.ret['exit_cb'] = job_status(a:job) |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
1403 endfunc |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
1404 |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1405 let job = job_start([&shell, &shellcmdflag, 'echo'], |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1406 \ {'close_cb': g:retdict.close_cb, |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1407 \ 'exit_cb': g:retdict.exit_cb}) |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1408 " the job may be done quickly, also accept "dead" |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1409 call assert_match('^\%(dead\|run\)$', job_status(job)) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1410 call WaitForAssert({-> assert_equal(2, len(g:retdict.ret))}) |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1411 call assert_match('^\%(dead\|run\)$', g:retdict.ret['close_cb']) |
12734
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1412 call assert_equal('dead', g:retdict.ret['exit_cb']) |
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1413 unlet g:retdict |
10386
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
1414 endfunc |
d3f0946b4a80
commit https://github.com/vim/vim/commit/7df915d113ac1981792c50e8b000c9f5f784b78b
Christian Brabandt <cb@256bit.org>
parents:
10309
diff
changeset
|
1415 |
8074
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1416 """""""""" |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1417 |
14675
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1418 function ExitCbWipe(job, status) |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1419 exe g:wipe_buf 'bw!' |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1420 endfunction |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1421 |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1422 " This caused a crash, because messages were handled while peeking for a |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1423 " character. |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1424 func Test_exit_cb_wipes_buf() |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
1425 CheckFeature timers |
14675
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1426 set cursorline lazyredraw |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1427 call test_override('redraw_flag', 1) |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1428 new |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1429 let g:wipe_buf = bufnr('') |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1430 |
14919
7ad55ed0a4f3
patch 8.1.0471: some tests are flaky or fail on some systems
Bram Moolenaar <Bram@vim.org>
parents:
14905
diff
changeset
|
1431 let job = job_start(has('win32') ? 'cmd /c echo:' : ['true'], |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
1432 \ {'exit_cb': 'ExitCbWipe'}) |
14675
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1433 let timer = timer_start(300, {-> feedkeys("\<Esc>", 'nt')}, {'repeat': 5}) |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1434 call feedkeys(repeat('g', 1000) . 'o', 'ntx!') |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1435 call WaitForAssert({-> assert_equal("dead", job_status(job))}) |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1436 call timer_stop(timer) |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1437 |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1438 set nocursorline nolazyredraw |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1439 unlet g:wipe_buf |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1440 call test_override('ALL', 0) |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1441 endfunc |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1442 |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1443 """""""""" |
71c17b688bc6
patch 8.1.0350: Vim may block on ch_sendraw()
Christian Brabandt <cb@256bit.org>
parents:
13798
diff
changeset
|
1444 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1445 let g:Ch_unletResponse = '' |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8045
diff
changeset
|
1446 func s:UnletHandler(handle, msg) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1447 let g:Ch_unletResponse = a:msg |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8045
diff
changeset
|
1448 unlet s:channelfd |
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8045
diff
changeset
|
1449 endfunc |
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8045
diff
changeset
|
1450 |
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8045
diff
changeset
|
1451 " Test that "unlet handle" in a handler doesn't crash Vim. |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1452 func Ch_unlet_handle(port) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1453 let s:channelfd = ch_open(s:address(a:port), s:chopt) |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
1454 eval s:channelfd->ch_sendexpr("test", {'callback': function('s:UnletHandler')}) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1455 call WaitForAssert({-> assert_equal('what?', g:Ch_unletResponse)}) |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8045
diff
changeset
|
1456 endfunc |
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8045
diff
changeset
|
1457 |
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8045
diff
changeset
|
1458 func Test_unlet_handle() |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1459 call s:run_server('Ch_unlet_handle') |
8055
6db4b1c863ec
commit https://github.com/vim/vim/commit/3bece9fee9c02934d3e295b29d253e13d4ef26a7
Christian Brabandt <cb@256bit.org>
parents:
8045
diff
changeset
|
1460 endfunc |
8070
e4c3f6720b03
commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents:
8066
diff
changeset
|
1461 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1462 func Test_unlet_handle_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1463 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1464 call Test_unlet_handle() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1465 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1466 |
8074
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1467 """""""""" |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1468 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1469 let g:Ch_unletResponse = '' |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1470 func Ch_CloseHandler(handle, msg) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1471 let g:Ch_unletResponse = a:msg |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
1472 eval s:channelfd->ch_close() |
8074
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1473 endfunc |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1474 |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1475 " Test that "unlet handle" in a handler doesn't crash Vim. |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1476 func Ch_close_handle(port) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1477 let s:channelfd = ch_open(s:address(a:port), s:chopt) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1478 call ch_sendexpr(s:channelfd, "test", {'callback': function('Ch_CloseHandler')}) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1479 call WaitForAssert({-> assert_equal('what?', g:Ch_unletResponse)}) |
8074
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1480 endfunc |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1481 |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1482 func Test_close_handle() |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1483 call s:run_server('Ch_close_handle') |
8074
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1484 endfunc |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1485 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1486 func Test_close_handle_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1487 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1488 call Test_close_handle() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1489 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1490 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1491 """""""""" |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1492 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1493 func Ch_open_ipv6(port) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1494 let handle = ch_open(s:address(a:port), s:chopt) |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1495 call assert_notequal('fail', ch_status(handle)) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1496 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1497 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1498 func Test_open_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1499 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1500 call s:run_server('Ch_open_ipv6') |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1501 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1502 |
8074
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1503 """""""""" |
dc32c8026899
commit https://github.com/vim/vim/commit/d46ae142aa9452e99576b5e923de974704e3c896
Christian Brabandt <cb@256bit.org>
parents:
8070
diff
changeset
|
1504 |
8070
e4c3f6720b03
commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents:
8066
diff
changeset
|
1505 func Test_open_fail() |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1506 call assert_fails("let ch = ch_open('noserver')", 'E475:') |
8070
e4c3f6720b03
commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents:
8066
diff
changeset
|
1507 echo ch |
e4c3f6720b03
commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents:
8066
diff
changeset
|
1508 let d = ch |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1509 call assert_fails("let ch = ch_open('noserver', 10)", 'E474:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1510 call assert_fails("let ch = ch_open('localhost:-1')", 'E475:') |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1511 call assert_fails("let ch = ch_open('localhost:65537')", 'E475:') |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1512 call assert_fails("let ch = ch_open('localhost:8765', {'timeout' : -1})", |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1513 \ 'E474:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1514 call assert_fails("let ch = ch_open('localhost:8765', {'axby' : 1})", |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1515 \ 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1516 call assert_fails("let ch = ch_open('localhost:8765', {'mode' : 'abc'})", |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1517 \ 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1518 call assert_fails("let ch = ch_open('localhost:8765', {'part' : 'out'})", |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1519 \ 'E475:') |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1520 call assert_fails("let ch = ch_open('[::]')", 'E475:') |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1521 call assert_fails("let ch = ch_open('[::.80')", 'E475:') |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1522 call assert_fails("let ch = ch_open('[::]8080')", 'E475:') |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1523 endfunc |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1524 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1525 func Test_ch_info_fail() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1526 call assert_fails("let x = ch_info(10)", 'E475:') |
8070
e4c3f6720b03
commit https://github.com/vim/vim/commit/5cefd4098204b4677387511b586673649f2fab48
Christian Brabandt <cb@256bit.org>
parents:
8066
diff
changeset
|
1527 endfunc |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1528 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1529 """""""""" |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1530 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1531 func Ch_open_delay(port) |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1532 " 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
|
1533 let s:chopt.waittime = 1000 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1534 let channel = ch_open(s:address(a:port), s:chopt) |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1535 if ch_status(channel) == "fail" |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
1536 call assert_report("Can't open channel") |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1537 return |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1538 endif |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
1539 call assert_equal('got it', channel->ch_evalexpr('hello!')) |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1540 call ch_close(channel) |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1541 endfunc |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1542 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1543 func Test_open_delay() |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1544 " The server will wait half a second before creating the port. |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1545 call s:run_server('Ch_open_delay', 'delay') |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8096
diff
changeset
|
1546 endfunc |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1547 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1548 func Test_open_delay_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1549 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1550 call Test_open_delay() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1551 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1552 |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1553 """"""""" |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1554 |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1555 function MyFunction(a,b,c) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1556 let g:Ch_call_ret = [a:a, a:b, a:c] |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1557 endfunc |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1558 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1559 function Ch_test_call(port) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1560 let handle = ch_open(s:address(a:port), s:chopt) |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1561 if ch_status(handle) == "fail" |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
1562 call assert_report("Can't open channel") |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1563 return |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1564 endif |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1565 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1566 let g:Ch_call_ret = [] |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
1567 call assert_equal('ok', ch_evalexpr(handle, 'call-func')) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1568 call WaitForAssert({-> assert_equal([1, 2, 3], g:Ch_call_ret)}) |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1569 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1570 call assert_fails("let i = ch_evalexpr(handle, '2 + 2', {'callback' : 'abc'})", 'E917:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1571 call assert_fails("let i = ch_evalexpr(handle, '2 + 2', {'drop' : ''})", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1572 call assert_fails("let i = ch_evalexpr(test_null_job(), '2 + 2')", 'E906:') |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1573 endfunc |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1574 |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1575 func Test_call() |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1576 call s:run_server('Ch_test_call') |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8157
diff
changeset
|
1577 endfunc |
8174
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
1578 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1579 func Test_call_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1580 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1581 call Test_call() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1582 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1583 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1584 func Test_call_unix() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1585 CheckUnix |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1586 call Test_call() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1587 call delete('Xtestsocket') |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1588 endfunc |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1589 |
8174
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
1590 """"""""" |
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
1591 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1592 let g:Ch_job_exit_ret = 'not yet' |
8174
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
1593 function MyExitCb(job, status) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1594 let g:Ch_job_exit_ret = 'done' |
8174
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
1595 endfunc |
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
1596 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1597 function Ch_test_exit_callback(port) |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
1598 eval g:currentJob->job_setoptions({'exit_cb': 'MyExitCb'}) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1599 let g:Ch_exit_job = g:currentJob |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1600 call assert_equal('MyExitCb', job_info(g:currentJob)['exit_cb']) |
8174
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
1601 endfunc |
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
1602 |
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
1603 func Test_exit_callback() |
17559
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1604 call s:run_server('Ch_test_exit_callback') |
8174
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
1605 |
17559
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1606 " wait up to a second for the job to exit |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1607 for i in range(100) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1608 if g:Ch_job_exit_ret == 'done' |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1609 break |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1610 endif |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1611 sleep 10m |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1612 " calling job_status() triggers the callback |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1613 call job_status(g:Ch_exit_job) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1614 endfor |
8174
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
1615 |
17559
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1616 call assert_equal('done', g:Ch_job_exit_ret) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1617 call assert_equal('dead', job_info(g:Ch_exit_job).status) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
1618 unlet g:Ch_exit_job |
8174
f2286ff0c102
commit https://github.com/vim/vim/commit/ee1cffc07a42441924c5353af7fd7ab6e97e5aae
Christian Brabandt <cb@256bit.org>
parents:
8170
diff
changeset
|
1619 endfunc |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1620 |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
1621 function MyExitTimeCb(job, status) |
10309
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1622 if job_info(a:job).process == g:exit_cb_val.process |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1623 let g:exit_cb_val.end = reltime(g:exit_cb_val.start) |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1624 endif |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1625 call Resume() |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
1626 endfunction |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
1627 |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
1628 func Test_exit_callback_interval() |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1629 CheckFunction reltimefloat |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
25891
diff
changeset
|
1630 let g:test_is_flaky = 1 |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
19195
diff
changeset
|
1631 |
10309
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1632 let g:exit_cb_val = {'start': reltime(), 'end': 0, 'process': 0} |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
1633 let job = [s:python, '-c', 'import time;time.sleep(0.5)']->job_start({'exit_cb': 'MyExitTimeCb'}) |
10309
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1634 let g:exit_cb_val.process = job_info(job).process |
13650
87ffb7f85b28
patch 8.0.1697: various tests are still a bit flaky
Christian Brabandt <cb@256bit.org>
parents:
13598
diff
changeset
|
1635 call WaitFor('type(g:exit_cb_val.end) != v:t_number || g:exit_cb_val.end != 0') |
10309
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1636 let elapsed = reltimefloat(g:exit_cb_val.end) |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1637 call assert_true(elapsed > 0.5) |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1638 call assert_true(elapsed < 1.0) |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1639 |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1640 " case: unreferenced job, using timer |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1641 if !has('timers') |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1642 return |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1643 endif |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1644 |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1645 let g:exit_cb_val = {'start': reltime(), 'end': 0, 'process': 0} |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1646 let g:job = job_start([s:python, '-c', 'import time;time.sleep(0.5)'], {'exit_cb': 'MyExitTimeCb'}) |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1647 let g:exit_cb_val.process = job_info(g:job).process |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1648 unlet g:job |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1649 call Standby(1000) |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1650 if type(g:exit_cb_val.end) != v:t_number || g:exit_cb_val.end != 0 |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1651 let elapsed = reltimefloat(g:exit_cb_val.end) |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1652 else |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1653 let elapsed = 1.0 |
88331ee68367
commit https://github.com/vim/vim/commit/01688ad545ff0809ddad5c8fa6b149dc5d67312b
Christian Brabandt <cb@256bit.org>
parents:
10297
diff
changeset
|
1654 endif |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1655 call assert_inrange(0.5, 1.0, elapsed) |
10279
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
1656 endfunc |
c5c15c818bda
commit https://github.com/vim/vim/commit/97792de2762cc79cc365a8a0b858f27753179577
Christian Brabandt <cb@256bit.org>
parents:
10259
diff
changeset
|
1657 |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1658 """"""""" |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1659 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1660 let g:Ch_close_ret = 'alive' |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1661 function MyCloseCb(ch) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1662 let g:Ch_close_ret = 'closed' |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1663 endfunc |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1664 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1665 function Ch_test_close_callback(port) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1666 let handle = ch_open(s:address(a:port), s:chopt) |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1667 if ch_status(handle) == "fail" |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
1668 call assert_report("Can't open channel") |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1669 return |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1670 endif |
8540
fec8655cf1bf
commit https://github.com/vim/vim/commit/d6c2f0526064eef6f8917d2bad00df707d79ea16
Christian Brabandt <cb@256bit.org>
parents:
8506
diff
changeset
|
1671 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
|
1672 |
8285
e05e28dcb590
commit https://github.com/vim/vim/commit/8b1862a31639becadcbbca5dc2eaa92db73e8e5f
Christian Brabandt <cb@256bit.org>
parents:
8222
diff
changeset
|
1673 call assert_equal('', ch_evalexpr(handle, 'close me')) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1674 call WaitForAssert({-> assert_equal('closed', g:Ch_close_ret)}) |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1675 endfunc |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1676 |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1677 func Test_close_callback() |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1678 call s:run_server('Ch_test_close_callback') |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1679 endfunc |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8174
diff
changeset
|
1680 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1681 func Test_close_callback_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1682 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1683 call Test_close_callback() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1684 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1685 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1686 func Test_close_callback_unix() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1687 CheckUnix |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1688 call Test_close_callback() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1689 call delete('Xtestsocket') |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1690 endfunc |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1691 |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1692 function Ch_test_close_partial(port) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1693 let handle = ch_open(s:address(a:port), s:chopt) |
8798
176647a751d7
commit https://github.com/vim/vim/commit/bdf0bda968a53a55149a4c83a10a60c28e431305
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
1694 if ch_status(handle) == "fail" |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
1695 call assert_report("Can't open channel") |
8798
176647a751d7
commit https://github.com/vim/vim/commit/bdf0bda968a53a55149a4c83a10a60c28e431305
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
1696 return |
176647a751d7
commit https://github.com/vim/vim/commit/bdf0bda968a53a55149a4c83a10a60c28e431305
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
1697 endif |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1698 let g:Ch_d = {} |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1699 func g:Ch_d.closeCb(ch) dict |
8798
176647a751d7
commit https://github.com/vim/vim/commit/bdf0bda968a53a55149a4c83a10a60c28e431305
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
1700 let self.close_ret = 'closed' |
176647a751d7
commit https://github.com/vim/vim/commit/bdf0bda968a53a55149a4c83a10a60c28e431305
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
1701 endfunc |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1702 call ch_setoptions(handle, {'close_cb': g:Ch_d.closeCb}) |
8798
176647a751d7
commit https://github.com/vim/vim/commit/bdf0bda968a53a55149a4c83a10a60c28e431305
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
1703 |
176647a751d7
commit https://github.com/vim/vim/commit/bdf0bda968a53a55149a4c83a10a60c28e431305
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
1704 call assert_equal('', ch_evalexpr(handle, 'close me')) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1705 call WaitForAssert({-> assert_equal('closed', g:Ch_d.close_ret)}) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1706 unlet g:Ch_d |
8798
176647a751d7
commit https://github.com/vim/vim/commit/bdf0bda968a53a55149a4c83a10a60c28e431305
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
1707 endfunc |
176647a751d7
commit https://github.com/vim/vim/commit/bdf0bda968a53a55149a4c83a10a60c28e431305
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
1708 |
176647a751d7
commit https://github.com/vim/vim/commit/bdf0bda968a53a55149a4c83a10a60c28e431305
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
1709 func Test_close_partial() |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
9367
diff
changeset
|
1710 call s:run_server('Ch_test_close_partial') |
8798
176647a751d7
commit https://github.com/vim/vim/commit/bdf0bda968a53a55149a4c83a10a60c28e431305
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
1711 endfunc |
176647a751d7
commit https://github.com/vim/vim/commit/bdf0bda968a53a55149a4c83a10a60c28e431305
Christian Brabandt <cb@256bit.org>
parents:
8761
diff
changeset
|
1712 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1713 func Test_close_partial_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1714 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1715 call Test_close_partial() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1716 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
1717 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1718 func Test_close_partial_unix() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1719 CheckUnix |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1720 call Test_close_partial() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1721 call delete('Xtestsocket') |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1722 endfunc |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1723 |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1724 func Test_job_start_fails() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1725 " this was leaking memory |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1726 call assert_fails("call job_start([''])", "E474:") |
8753
df91c8263f04
commit https://github.com/vim/vim/commit/8038568722a0aad72d001edf4972c29abab57f8f
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
1727 call assert_fails('call job_start($x)', 'E474:') |
df91c8263f04
commit https://github.com/vim/vim/commit/8038568722a0aad72d001edf4972c29abab57f8f
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
1728 call assert_fails('call job_start("")', 'E474:') |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1729 call assert_fails('call job_start("ls", {"out_io" : "abc"})', 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1730 call assert_fails('call job_start("ls", {"err_io" : "abc"})', 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1731 call assert_fails('call job_start("ls", [])', 'E715:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1732 call assert_fails("call job_start('ls', {'in_top' : -1})", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1733 call assert_fails("call job_start('ls', {'in_bot' : -1})", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1734 call assert_fails("call job_start('ls', {'channel' : -1})", 'E475:') |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20923
diff
changeset
|
1735 call assert_fails("call job_start('ls', {'callback' : -1})", 'E921:') |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20923
diff
changeset
|
1736 call assert_fails("call job_start('ls', {'out_cb' : -1})", 'E921:') |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20923
diff
changeset
|
1737 call assert_fails("call job_start('ls', {'err_cb' : -1})", 'E921:') |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20923
diff
changeset
|
1738 call assert_fails("call job_start('ls', {'close_cb' : -1})", 'E921:') |
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20923
diff
changeset
|
1739 call assert_fails("call job_start('ls', {'exit_cb' : -1})", 'E921:') |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1740 call assert_fails("call job_start('ls', {'term_name' : []})", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1741 call assert_fails("call job_start('ls', {'term_finish' : 'run'})", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1742 call assert_fails("call job_start('ls', {'term_api' : []})", 'E475:') |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
20923
diff
changeset
|
1743 call assert_fails("call job_start('ls', {'stoponexit' : []})", 'E730:') |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1744 call assert_fails("call job_start('ls', {'in_io' : 'file'})", 'E920:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1745 call assert_fails("call job_start('ls', {'out_io' : 'file'})", 'E920:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1746 call assert_fails("call job_start('ls', {'err_io' : 'file'})", 'E920:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1747 call assert_fails("call job_start('ls', {'in_mode' : 'abc'})", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1748 call assert_fails("call job_start('ls', {'out_mode' : 'abc'})", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1749 call assert_fails("call job_start('ls', {'err_mode' : 'abc'})", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1750 call assert_fails("call job_start('ls', |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1751 \ {'in_io' : 'buffer', 'in_buf' : 99999})", 'E86:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1752 call assert_fails("call job_start('ls', |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1753 \ {'out_io' : 'buffer', 'out_buf' : 99999})", 'E86:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1754 call assert_fails("call job_start('ls', |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1755 \ {'err_io' : 'buffer', 'err_buf' : 99999})", 'E86:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1756 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1757 call assert_fails("call job_start('ls', |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1758 \ {'in_io' : 'buffer', 'in_buf' : -1})", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1759 call assert_fails("call job_start('ls', |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1760 \ {'out_io' : 'buffer', 'out_buf' : -1})", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1761 call assert_fails("call job_start('ls', |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1762 \ {'err_io' : 'buffer', 'err_buf' : -1})", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1763 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1764 set nomodifiable |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1765 call assert_fails("call job_start('cmd /c dir', |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1766 \ {'out_io' : 'buffer', 'out_buf' :" .. bufnr() .. "})", 'E21:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1767 call assert_fails("call job_start('cmd /c dir', |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1768 \ {'err_io' : 'buffer', 'err_buf' :" .. bufnr() .. "})", 'E21:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1769 set modifiable |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1770 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1771 call assert_fails("call job_start('ls', {'in_io' : 'buffer'})", 'E915:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1772 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1773 edit! XXX |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1774 let bnum = bufnr() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1775 enew |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1776 call assert_fails("call job_start('ls', |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1777 \ {'in_io' : 'buffer', 'in_buf' : bnum})", 'E918:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1778 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1779 " Empty job tests |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1780 " This was crashing on MS-Windows. |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1781 call assert_fails('let job = job_start([""])', 'E474:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1782 call assert_fails('let job = job_start([" "])', 'E474:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1783 call assert_fails('let job = job_start("")', 'E474:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1784 call assert_fails('let job = job_start(" ")', 'E474:') |
20031
6486f456b06a
patch 8.2.0571: double free when passing invalid argument to job_start()
Bram Moolenaar <Bram@vim.org>
parents:
20003
diff
changeset
|
1785 call assert_fails('let job = job_start(["ls", []])', 'E730:') |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20031
diff
changeset
|
1786 call assert_fails('call job_setoptions(test_null_job(), {})', 'E916:') |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
1787 %bw! |
8753
df91c8263f04
commit https://github.com/vim/vim/commit/8038568722a0aad72d001edf4972c29abab57f8f
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
1788 endfunc |
df91c8263f04
commit https://github.com/vim/vim/commit/8038568722a0aad72d001edf4972c29abab57f8f
Christian Brabandt <cb@256bit.org>
parents:
8749
diff
changeset
|
1789 |
10297
c90f4cc9c3fe
commit https://github.com/vim/vim/commit/bb09ceb95477ecc271854b3fdd8d2776eca66adf
Christian Brabandt <cb@256bit.org>
parents:
10279
diff
changeset
|
1790 func Test_job_stop_immediately() |
12734
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1791 let g:job = job_start([s:python, '-c', 'import time;time.sleep(10)']) |
10297
c90f4cc9c3fe
commit https://github.com/vim/vim/commit/bb09ceb95477ecc271854b3fdd8d2776eca66adf
Christian Brabandt <cb@256bit.org>
parents:
10279
diff
changeset
|
1792 try |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
1793 eval g:job->job_stop() |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1794 call WaitForAssert({-> assert_equal('dead', job_status(g:job))}) |
10297
c90f4cc9c3fe
commit https://github.com/vim/vim/commit/bb09ceb95477ecc271854b3fdd8d2776eca66adf
Christian Brabandt <cb@256bit.org>
parents:
10279
diff
changeset
|
1795 finally |
12734
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1796 call job_stop(g:job, 'kill') |
810a4c3d4f7e
patch 8.0.1245: when WaitFor() has a wrong expression it just waits a second
Christian Brabandt <cb@256bit.org>
parents:
12596
diff
changeset
|
1797 unlet g:job |
10297
c90f4cc9c3fe
commit https://github.com/vim/vim/commit/bb09ceb95477ecc271854b3fdd8d2776eca66adf
Christian Brabandt <cb@256bit.org>
parents:
10279
diff
changeset
|
1798 endtry |
c90f4cc9c3fe
commit https://github.com/vim/vim/commit/bb09ceb95477ecc271854b3fdd8d2776eca66adf
Christian Brabandt <cb@256bit.org>
parents:
10279
diff
changeset
|
1799 endfunc |
c90f4cc9c3fe
commit https://github.com/vim/vim/commit/bb09ceb95477ecc271854b3fdd8d2776eca66adf
Christian Brabandt <cb@256bit.org>
parents:
10279
diff
changeset
|
1800 |
25686
838a0108a92d
patch 8.2.3379: crash when using NULL job
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
1801 func Test_null_job_eval() |
838a0108a92d
patch 8.2.3379: crash when using NULL job
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
1802 call assert_fails('eval test_null_job()->eval()', 'E121:') |
838a0108a92d
patch 8.2.3379: crash when using NULL job
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
1803 endfunc |
838a0108a92d
patch 8.2.3379: crash when using NULL job
Bram Moolenaar <Bram@vim.org>
parents:
25501
diff
changeset
|
1804 |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
1805 " This was leaking memory. |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1806 func Test_partial_in_channel_cycle() |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1807 let d = {} |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1808 let d.a = function('string', [d]) |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1809 try |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1810 let d.b = ch_open('nowhere:123', {'close_cb': d.a}) |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
1811 call test_garbagecollect_now() |
8859
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1812 catch |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1813 call assert_exception('E901:') |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1814 endtry |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1815 unlet d |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1816 endfunc |
03250bc0c63a
commit https://github.com/vim/vim/commit/0e4c1de5560c7f8b4cae539ec8cff0949daba3fc
Christian Brabandt <cb@256bit.org>
parents:
8798
diff
changeset
|
1817 |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
1818 func Test_using_freed_memory() |
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
1819 let g:a = job_start(['ls']) |
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
1820 sleep 10m |
9108
d319453f62b3
commit https://github.com/vim/vim/commit/574860b5ee9da281c875dad07a607454e135eaee
Christian Brabandt <cb@256bit.org>
parents:
9050
diff
changeset
|
1821 call test_garbagecollect_now() |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
1822 endfunc |
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
1823 |
9266
78fc4c84476e
commit https://github.com/vim/vim/commit/b8aefa46adf5e825118716e142fab7ef32076475
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1824 func Test_collapse_buffers() |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
25891
diff
changeset
|
1825 let g:test_is_flaky = 1 |
17657
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17559
diff
changeset
|
1826 CheckExecutable cat |
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17559
diff
changeset
|
1827 |
9266
78fc4c84476e
commit https://github.com/vim/vim/commit/b8aefa46adf5e825118716e142fab7ef32076475
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1828 sp test_channel.vim |
78fc4c84476e
commit https://github.com/vim/vim/commit/b8aefa46adf5e825118716e142fab7ef32076475
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1829 let g:linecount = line('$') |
78fc4c84476e
commit https://github.com/vim/vim/commit/b8aefa46adf5e825118716e142fab7ef32076475
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1830 close |
78fc4c84476e
commit https://github.com/vim/vim/commit/b8aefa46adf5e825118716e142fab7ef32076475
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1831 split testout |
78fc4c84476e
commit https://github.com/vim/vim/commit/b8aefa46adf5e825118716e142fab7ef32076475
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1832 1,$delete |
78fc4c84476e
commit https://github.com/vim/vim/commit/b8aefa46adf5e825118716e142fab7ef32076475
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1833 call job_start('cat test_channel.vim', {'out_io': 'buffer', 'out_name': 'testout'}) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1834 call WaitForAssert({-> assert_inrange(g:linecount, g:linecount + 1, line('$'))}) |
9266
78fc4c84476e
commit https://github.com/vim/vim/commit/b8aefa46adf5e825118716e142fab7ef32076475
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1835 bwipe! |
78fc4c84476e
commit https://github.com/vim/vim/commit/b8aefa46adf5e825118716e142fab7ef32076475
Christian Brabandt <cb@256bit.org>
parents:
9238
diff
changeset
|
1836 endfunc |
8881
ed0b39dd7fd6
commit https://github.com/vim/vim/commit/ebf7dfa6f121c82f97d2adca3d45fbaba9ad8f7e
Christian Brabandt <cb@256bit.org>
parents:
8859
diff
changeset
|
1837 |
15369
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1838 func Test_write_to_deleted_buffer() |
17657
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17559
diff
changeset
|
1839 CheckExecutable echo |
18767
068337e86133
patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents:
17831
diff
changeset
|
1840 CheckFeature quickfix |
17657
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17559
diff
changeset
|
1841 |
15369
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1842 let job = job_start('echo hello', {'out_io': 'buffer', 'out_name': 'test_buffer', 'out_msg': 0}) |
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1843 let bufnr = bufnr('test_buffer') |
15371
cda564e7c111
patch 8.1.0693: channel test fails sometimes
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1844 call WaitForAssert({-> assert_equal(['hello'], getbufline(bufnr, 1, '$'))}) |
15369
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1845 call assert_equal('nofile', getbufvar(bufnr, '&buftype')) |
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1846 call assert_equal('hide', getbufvar(bufnr, '&bufhidden')) |
15371
cda564e7c111
patch 8.1.0693: channel test fails sometimes
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1847 |
15369
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1848 bdel test_buffer |
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1849 call assert_equal([], getbufline(bufnr, 1, '$')) |
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1850 |
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1851 let job = job_start('echo hello', {'out_io': 'buffer', 'out_name': 'test_buffer', 'out_msg': 0}) |
15371
cda564e7c111
patch 8.1.0693: channel test fails sometimes
Bram Moolenaar <Bram@vim.org>
parents:
15369
diff
changeset
|
1852 call WaitForAssert({-> assert_equal(['hello'], getbufline(bufnr, 1, '$'))}) |
15369
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1853 call assert_equal('nofile', getbufvar(bufnr, '&buftype')) |
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1854 call assert_equal('hide', getbufvar(bufnr, '&bufhidden')) |
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1855 |
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1856 bwipe! test_buffer |
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1857 endfunc |
c73f1fdfb27a
patch 8.1.0692: if a buffer was deleted a channel can't write to it
Bram Moolenaar <Bram@vim.org>
parents:
15162
diff
changeset
|
1858 |
12596
d177c142d086
patch 8.0.1176: job_start() does not handle quote and backslash correctly
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1859 func Test_cmd_parsing() |
20923
a9516192b1db
patch 8.2.1013: channel tests can be a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
1860 CheckUnix |
a9516192b1db
patch 8.2.1013: channel tests can be a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
1861 |
12596
d177c142d086
patch 8.0.1176: job_start() does not handle quote and backslash correctly
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1862 call assert_false(filereadable("file with space")) |
d177c142d086
patch 8.0.1176: job_start() does not handle quote and backslash correctly
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1863 let job = job_start('touch "file with space"') |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1864 call WaitForAssert({-> assert_true(filereadable("file with space"))}) |
12596
d177c142d086
patch 8.0.1176: job_start() does not handle quote and backslash correctly
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1865 call delete("file with space") |
d177c142d086
patch 8.0.1176: job_start() does not handle quote and backslash correctly
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1866 |
d177c142d086
patch 8.0.1176: job_start() does not handle quote and backslash correctly
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1867 let job = job_start('touch file\ with\ space') |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1868 call WaitForAssert({-> assert_true(filereadable("file with space"))}) |
12596
d177c142d086
patch 8.0.1176: job_start() does not handle quote and backslash correctly
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1869 call delete("file with space") |
d177c142d086
patch 8.0.1176: job_start() does not handle quote and backslash correctly
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1870 endfunc |
d177c142d086
patch 8.0.1176: job_start() does not handle quote and backslash correctly
Christian Brabandt <cb@256bit.org>
parents:
12096
diff
changeset
|
1871 |
9994
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1872 func Test_raw_passes_nul() |
17657
0da9bc55c31a
patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents:
17559
diff
changeset
|
1873 CheckExecutable cat |
9994
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1874 |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1875 " Test lines from the job containing NUL are stored correctly in a buffer. |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1876 new |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1877 call setline(1, ["asdf\nasdf", "xxx\n", "\nyyy"]) |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1878 w! Xtestread |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1879 bwipe! |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1880 split testout |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1881 1,$delete |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1882 call job_start('cat Xtestread', {'out_io': 'buffer', 'out_name': 'testout'}) |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1883 call WaitFor('line("$") > 2') |
10147
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
1884 call assert_equal("asdf\nasdf", getline(1)) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
1885 call assert_equal("xxx\n", getline(2)) |
65afd399ffa7
commit https://github.com/vim/vim/commit/169ebb080454357279ad5ad21ac532deaec605e8
Christian Brabandt <cb@256bit.org>
parents:
10090
diff
changeset
|
1886 call assert_equal("\nyyy", getline(3)) |
9994
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1887 |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1888 call delete('Xtestread') |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1889 bwipe! |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1890 |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1891 " Test lines from a buffer with NUL bytes are written correctly to the job. |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1892 new mybuffer |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1893 call setline(1, ["asdf\nasdf", "xxx\n", "\nyyy"]) |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1894 let g:Ch_job = job_start('cat', {'in_io': 'buffer', 'in_name': 'mybuffer', 'out_io': 'file', 'out_name': 'Xtestwrite'}) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1895 call WaitForAssert({-> assert_equal("dead", job_status(g:Ch_job))}) |
9994
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1896 bwipe! |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1897 split Xtestwrite |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1898 call assert_equal("asdf\nasdf", getline(1)) |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1899 call assert_equal("xxx\n", getline(2)) |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1900 call assert_equal("\nyyy", getline(3)) |
13357
179586a64f53
patch 8.0.1552: may leak file descriptors when executing job
Christian Brabandt <cb@256bit.org>
parents:
13010
diff
changeset
|
1901 call assert_equal(-1, match(s:get_resources(), '\(^\|/\)Xtestwrite$')) |
9994
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1902 |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1903 call delete('Xtestwrite') |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1904 bwipe! |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1905 endfunc |
ee8b8a670a5c
commit https://github.com/vim/vim/commit/821179809d9b0f65177360b53584be2b4039dd46
Christian Brabandt <cb@256bit.org>
parents:
9973
diff
changeset
|
1906 |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
1907 func Test_read_nonl_line() |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
1908 let g:linecount = 0 |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
1909 let arg = 'import sys;sys.stdout.write("1\n2\n3")' |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1910 call job_start([s:python, '-c', arg], {'callback': {-> execute('let g:linecount += 1')}}) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1911 call WaitForAssert({-> assert_equal(3, g:linecount)}) |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1912 unlet g:linecount |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1913 endfunc |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1914 |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1915 func Test_read_nonl_in_close_cb() |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1916 func s:close_cb(ch) |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1917 while ch_status(a:ch) == 'buffered' |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1918 let g:out .= ch_read(a:ch) |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1919 endwhile |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1920 endfunc |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1921 |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1922 let g:out = '' |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1923 let arg = 'import sys;sys.stdout.write("1\n2\n3")' |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1924 call job_start([s:python, '-c', arg], {'close_cb': function('s:close_cb')}) |
20156
49694eceaa55
patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents:
20120
diff
changeset
|
1925 call test_garbagecollect_now() |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1926 call WaitForAssert({-> assert_equal('123', g:out)}) |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1927 unlet g:out |
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1928 delfunc s:close_cb |
10249
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
1929 endfunc |
920c73a27dda
commit https://github.com/vim/vim/commit/ec68a99464055029c01082762517e97245ddae0c
Christian Brabandt <cb@256bit.org>
parents:
10233
diff
changeset
|
1930 |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10249
diff
changeset
|
1931 func Test_read_from_terminated_job() |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10249
diff
changeset
|
1932 let g:linecount = 0 |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
1933 let arg = 'import os,sys;os.close(1);sys.stderr.write("test\n")' |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1934 call job_start([s:python, '-c', arg], {'callback': {-> execute('let g:linecount += 1')}}) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1935 call WaitForAssert({-> assert_equal(1, g:linecount)}) |
20156
49694eceaa55
patch 8.2.0633: crash when using null partial in filter()
Bram Moolenaar <Bram@vim.org>
parents:
20120
diff
changeset
|
1936 call test_garbagecollect_now() |
15975
915ed7ca92fa
patch 8.1.0993: ch_read() may return garbage if terminating NL is missing
Bram Moolenaar <Bram@vim.org>
parents:
15780
diff
changeset
|
1937 unlet g:linecount |
10259
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10249
diff
changeset
|
1938 endfunc |
a09db7a4afe0
commit https://github.com/vim/vim/commit/dc0ccaee68ca24d10050117fbec757ad33590a17
Christian Brabandt <cb@256bit.org>
parents:
10249
diff
changeset
|
1939 |
14905
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1940 func Test_job_start_windows() |
17557
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
1941 CheckMSWindows |
14905
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1942 |
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1943 " Check that backslash in $COMSPEC is handled properly. |
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1944 let g:echostr = '' |
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1945 let cmd = $COMSPEC . ' /c echo 123' |
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1946 let job = job_start(cmd, {'callback': {ch,msg -> execute(":let g:echostr .= msg")}}) |
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1947 let info = job_info(job) |
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1948 call assert_equal([$COMSPEC, '/c', 'echo', '123'], info.cmd) |
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1949 |
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1950 call WaitForAssert({-> assert_equal("123", g:echostr)}) |
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1951 unlet g:echostr |
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1952 endfunc |
c1e94bb0f004
patch 8.1.0464: MS-Windows: job_info() has cmd without backslashes
Bram Moolenaar <Bram@vim.org>
parents:
14675
diff
changeset
|
1953 |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1954 func Test_env() |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
1955 let g:envstr = '' |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1956 if has('win32') |
13598
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13587
diff
changeset
|
1957 let cmd = ['cmd', '/c', 'echo %FOO%'] |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1958 else |
13598
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13587
diff
changeset
|
1959 let cmd = [&shell, &shellcmdflag, 'echo $FOO'] |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1960 endif |
13598
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13587
diff
changeset
|
1961 call assert_fails('call job_start(cmd, {"env": 1})', 'E475:') |
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13587
diff
changeset
|
1962 call job_start(cmd, {'callback': {ch,msg -> execute(":let g:envstr .= msg")}, 'env': {'FOO': 'bar'}}) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1963 call WaitForAssert({-> assert_equal("bar", g:envstr)}) |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
1964 unlet g:envstr |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1965 endfunc |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1966 |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1967 func Test_cwd() |
25969
a5a772dace5b
patch 8.2.3518: Test_xrestore sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
25891
diff
changeset
|
1968 let g:test_is_flaky = 1 |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
1969 let g:envstr = '' |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1970 if has('win32') |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1971 let expect = $TEMP |
13598
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13587
diff
changeset
|
1972 let cmd = ['cmd', '/c', 'echo %CD%'] |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1973 else |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1974 let expect = $HOME |
13598
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13587
diff
changeset
|
1975 let cmd = ['pwd'] |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1976 endif |
13598
8723e4496dd1
patch 8.0.1671: crash when passing non-dict argument as env to job_start()
Christian Brabandt <cb@256bit.org>
parents:
13587
diff
changeset
|
1977 let job = job_start(cmd, {'callback': {ch,msg -> execute(":let g:envstr .= msg")}, 'cwd': expect}) |
12979
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
1978 try |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
1979 call WaitForAssert({-> assert_notequal("", g:envstr)}) |
12979
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
1980 let expect = substitute(expect, '[/\\]$', '', '') |
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
1981 let g:envstr = substitute(g:envstr, '[/\\]$', '', '') |
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
1982 if $CI != '' && stridx(g:envstr, '/private/') == 0 |
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
1983 let g:envstr = g:envstr[8:] |
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
1984 endif |
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
1985 call assert_equal(expect, g:envstr) |
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
1986 finally |
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
1987 call job_stop(job) |
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
1988 unlet g:envstr |
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
1989 endtry |
12043
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1990 endfunc |
2796a2c9fc17
patch 8.0.0902: cannot specify directory or environment for a job
Christian Brabandt <cb@256bit.org>
parents:
11666
diff
changeset
|
1991 |
9527
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1992 function Ch_test_close_lambda(port) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
1993 let handle = ch_open(s:address(a:port), s:chopt) |
9527
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1994 if ch_status(handle) == "fail" |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
10845
diff
changeset
|
1995 call assert_report("Can't open channel") |
9527
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1996 return |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1997 endif |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1998 let g:Ch_close_ret = '' |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
1999 call ch_setoptions(handle, {'close_cb': {ch -> execute("let g:Ch_close_ret = 'closed'")}}) |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
2000 call test_garbagecollect_now() |
9527
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
2001 |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
2002 call assert_equal('', ch_evalexpr(handle, 'close me')) |
13798
415185e2c970
patch 8.0.1771: in tests, when WaitFor() fails it doesn't say why
Christian Brabandt <cb@256bit.org>
parents:
13778
diff
changeset
|
2003 call WaitForAssert({-> assert_equal('closed', g:Ch_close_ret)}) |
9527
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
2004 endfunc |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
2005 |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
2006 func Test_close_lambda() |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
2007 call s:run_server('Ch_test_close_lambda') |
e8b3db8e2d30
commit https://github.com/vim/vim/commit/069c1e7fa9f45a665064f7f2c17da84d6a48f544
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
2008 endfunc |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2009 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
2010 func Test_close_lambda_ipv6() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
2011 CheckIPv6 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
2012 call Test_close_lambda() |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
2013 endfunc |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
19954
diff
changeset
|
2014 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
2015 func Test_close_lambda_unix() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
2016 CheckUnix |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
2017 call Test_close_lambda() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
2018 call delete('Xtestsocket') |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
2019 endfunc |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
2020 |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2021 func s:test_list_args(cmd, out, remove_lf) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2022 try |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2023 let g:out = '' |
12979
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
2024 let job = job_start([s:python, '-c', a:cmd], {'callback': {ch, msg -> execute('let g:out .= msg')}, 'out_mode': 'raw'}) |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2025 call WaitFor('"" != g:out') |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2026 if has('win32') |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2027 let g:out = substitute(g:out, '\r', '', 'g') |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2028 endif |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2029 if a:remove_lf |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2030 let g:out = substitute(g:out, '\n$', '', 'g') |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2031 endif |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2032 call assert_equal(a:out, g:out) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2033 finally |
12979
6cf6138b6484
patch 8.0.1365: when one channel test fails others fail as well
Christian Brabandt <cb@256bit.org>
parents:
12765
diff
changeset
|
2034 call job_stop(job) |
12096
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2035 unlet g:out |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2036 endtry |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2037 endfunc |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2038 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2039 func Test_list_args() |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2040 call s:test_list_args('import sys;sys.stdout.write("hello world")', "hello world", 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2041 call s:test_list_args('import sys;sys.stdout.write("hello\nworld")', "hello\nworld", 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2042 call s:test_list_args('import sys;sys.stdout.write(''hello\nworld'')', "hello\nworld", 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2043 call s:test_list_args('import sys;sys.stdout.write(''hello"world'')', "hello\"world", 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2044 call s:test_list_args('import sys;sys.stdout.write(''hello^world'')', "hello^world", 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2045 call s:test_list_args('import sys;sys.stdout.write("hello&&world")', "hello&&world", 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2046 call s:test_list_args('import sys;sys.stdout.write(''hello\\world'')', "hello\\world", 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2047 call s:test_list_args('import sys;sys.stdout.write(''hello\\\\world'')', "hello\\\\world", 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2048 call s:test_list_args('import sys;sys.stdout.write("hello\"world\"")', 'hello"world"', 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2049 call s:test_list_args('import sys;sys.stdout.write("h\"ello worl\"d")', 'h"ello worl"d', 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2050 call s:test_list_args('import sys;sys.stdout.write("h\"e\\\"llo wor\\\"l\"d")', 'h"e\"llo wor\"l"d', 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2051 call s:test_list_args('import sys;sys.stdout.write("h\"e\\\"llo world")', 'h"e\"llo world', 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2052 call s:test_list_args('import sys;sys.stdout.write("hello\tworld")', "hello\tworld", 0) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2053 |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2054 " tests which not contain spaces in the argument |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2055 call s:test_list_args('print("hello\nworld")', "hello\nworld", 1) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2056 call s:test_list_args('print(''hello\nworld'')', "hello\nworld", 1) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2057 call s:test_list_args('print(''hello"world'')', "hello\"world", 1) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2058 call s:test_list_args('print(''hello^world'')', "hello^world", 1) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2059 call s:test_list_args('print("hello&&world")', "hello&&world", 1) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2060 call s:test_list_args('print(''hello\\world'')', "hello\\world", 1) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2061 call s:test_list_args('print(''hello\\\\world'')', "hello\\\\world", 1) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2062 call s:test_list_args('print("hello\"world\"")', 'hello"world"', 1) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2063 call s:test_list_args('print("hello\tworld")', "hello\tworld", 1) |
0a61213afdd2
patch 8.0.0928: MS-Windows: passing arglist to job has escaping problems
Christian Brabandt <cb@256bit.org>
parents:
12043
diff
changeset
|
2064 endfunc |
13587
c0ebd15a0908
patch 8.0.1666: % argument in ch_log() causes trouble
Christian Brabandt <cb@256bit.org>
parents:
13357
diff
changeset
|
2065 |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
2066 func Test_keep_pty_open() |
20923
a9516192b1db
patch 8.2.1013: channel tests can be a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2067 CheckUnix |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
2068 |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
2069 let job = job_start(s:python . ' -c "import time;time.sleep(0.2)"', |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
2070 \ {'out_io': 'null', 'err_io': 'null', 'pty': 1}) |
13778
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
2071 let elapsed = WaitFor({-> job_status(job) ==# 'dead'}) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
2072 call assert_inrange(200, 1000, elapsed) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
2073 call job_stop(job) |
5f6c61a71c02
patch 8.0.1761: job in terminal window with no output channel is killed
Christian Brabandt <cb@256bit.org>
parents:
13740
diff
changeset
|
2074 endfunc |
15404
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2075 |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2076 func Test_job_start_in_timer() |
17557
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
2077 CheckFeature timers |
19653
5ec5427fcedf
patch 8.2.0383: wrong feature check causes test not to be run
Bram Moolenaar <Bram@vim.org>
parents:
19651
diff
changeset
|
2078 CheckFunction reltimefloat |
15404
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2079 |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2080 func OutCb(chan, msg) |
15583
3137345451a4
patch 8.1.0799: calling deleted function; test doesn't work on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
2081 let g:val += 1 |
15404
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2082 endfunc |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2083 |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2084 func ExitCb(job, status) |
15583
3137345451a4
patch 8.1.0799: calling deleted function; test doesn't work on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
2085 let g:val += 1 |
15404
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2086 call Resume() |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2087 endfunc |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2088 |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2089 func TimerCb(timer) |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2090 if has('win32') |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2091 let cmd = ['cmd', '/c', 'echo.'] |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2092 else |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2093 let cmd = ['echo'] |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2094 endif |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2095 let g:job = job_start(cmd, {'out_cb': 'OutCb', 'exit_cb': 'ExitCb'}) |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2096 call substitute(repeat('a', 100000), '.', '', 'g') |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2097 endfunc |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2098 |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2099 " We should be interrupted before 'updatetime' elapsed. |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2100 let g:val = 0 |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2101 call timer_start(1, 'TimerCb') |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2102 let elapsed = Standby(&ut) |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2103 call assert_inrange(1, &ut / 2, elapsed) |
15583
3137345451a4
patch 8.1.0799: calling deleted function; test doesn't work on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
2104 |
3137345451a4
patch 8.1.0799: calling deleted function; test doesn't work on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
2105 " Wait for both OutCb() and ExitCb() to have been called before deleting |
3137345451a4
patch 8.1.0799: calling deleted function; test doesn't work on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
2106 " them. |
3137345451a4
patch 8.1.0799: calling deleted function; test doesn't work on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15454
diff
changeset
|
2107 call WaitForAssert({-> assert_equal(2, g:val)}) |
15404
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2108 call job_stop(g:job) |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2109 |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2110 delfunc OutCb |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2111 delfunc ExitCb |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2112 delfunc TimerCb |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2113 unlet! g:val |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2114 unlet! g:job |
440e5071f3f8
patch 8.1.0710: when using timers may wait for job exit quite long
Bram Moolenaar <Bram@vim.org>
parents:
15371
diff
changeset
|
2115 endfunc |
15621
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15583
diff
changeset
|
2116 |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15583
diff
changeset
|
2117 func Test_raw_large_data() |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15583
diff
changeset
|
2118 try |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15583
diff
changeset
|
2119 let g:out = '' |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15583
diff
changeset
|
2120 let job = job_start(s:python . " test_channel_pipe.py", |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
2121 \ {'mode': 'raw', 'drop': 'never', 'noblock': 1, |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
2122 \ 'callback': {ch, msg -> execute('let g:out .= msg')}}) |
15621
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15583
diff
changeset
|
2123 |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
2124 let outlen = 79999 |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
2125 let want = repeat('X', outlen) . "\n" |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
2126 eval job->ch_sendraw(want) |
15625
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
2127 call WaitFor({-> len(g:out) >= outlen}, 10000) |
858bf9c80c93
patch 8.1.0820: test for sending large data over channel sometimes fails
Bram Moolenaar <Bram@vim.org>
parents:
15621
diff
changeset
|
2128 call WaitForAssert({-> assert_equal("dead", job_status(job))}) |
15621
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15583
diff
changeset
|
2129 call assert_equal(want, substitute(g:out, '\r', '', 'g')) |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15583
diff
changeset
|
2130 finally |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15583
diff
changeset
|
2131 call job_stop(job) |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15583
diff
changeset
|
2132 unlet g:out |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15583
diff
changeset
|
2133 endtry |
bfbdef46aa7d
patch 8.1.0818: MS-Windows: cannot send large data with ch_sendraw()
Bram Moolenaar <Bram@vim.org>
parents:
15583
diff
changeset
|
2134 endfunc |
15711
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2135 |
15764
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
2136 func Test_no_hang_windows() |
17557
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
2137 CheckMSWindows |
15764
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
2138 |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
2139 try |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
2140 let job = job_start(s:python . " test_channel_pipe.py busy", |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
2141 \ {'mode': 'raw', 'drop': 'never', 'noblock': 0}) |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
2142 call assert_fails('call ch_sendraw(job, repeat("X", 80000))', 'E631:') |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
2143 finally |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
2144 call job_stop(job) |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
2145 endtry |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
2146 endfunc |
208bf8b36075
patch 8.1.0889: MS-Windows: a channel write may hang
Bram Moolenaar <Bram@vim.org>
parents:
15711
diff
changeset
|
2147 |
15711
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2148 func Test_job_exitval_and_termsig() |
20923
a9516192b1db
patch 8.2.1013: channel tests can be a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2149 CheckUnix |
15711
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2150 |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2151 " Terminate job normally |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2152 let cmd = ['echo'] |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2153 let job = job_start(cmd) |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2154 call WaitForAssert({-> assert_equal("dead", job_status(job))}) |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2155 let info = job_info(job) |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2156 call assert_equal(0, info.exitval) |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2157 call assert_equal("", info.termsig) |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2158 |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2159 " Terminate job by signal |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2160 let cmd = ['sleep', '10'] |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2161 let job = job_start(cmd) |
18834
aaea9672a96d
patch 8.1.2404: channel test fails under valgrind
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
2162 " 10m usually works but 50m is needed when running Valgrind |
aaea9672a96d
patch 8.1.2404: channel test fails under valgrind
Bram Moolenaar <Bram@vim.org>
parents:
18767
diff
changeset
|
2163 sleep 50m |
15711
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2164 call job_stop(job) |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2165 call WaitForAssert({-> assert_equal("dead", job_status(job))}) |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2166 let info = job_info(job) |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2167 call assert_equal(-1, info.exitval) |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2168 call assert_equal("term", info.termsig) |
287104a1d51e
patch 8.1.0863: cannot see what signal caused a job to end
Bram Moolenaar <Bram@vim.org>
parents:
15677
diff
changeset
|
2169 endfunc |
15766
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2170 |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2171 func Test_job_tty_in_out() |
17557
4a22102fda8f
patch 8.1.1776: text added with a job isn't displayed
Bram Moolenaar <Bram@vim.org>
parents:
16965
diff
changeset
|
2172 CheckUnix |
15766
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2173 |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2174 call writefile(['test'], 'Xtestin') |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2175 let in_opts = [{}, |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2176 \ {'in_io': 'null'}, |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2177 \ {'in_io': 'file', 'in_name': 'Xtestin'}] |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2178 let out_opts = [{}, |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2179 \ {'out_io': 'null'}, |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2180 \ {'out_io': 'file', 'out_name': 'Xtestout'}] |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2181 let err_opts = [{}, |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2182 \ {'err_io': 'null'}, |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2183 \ {'err_io': 'file', 'err_name': 'Xtesterr'}, |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2184 \ {'err_io': 'out'}] |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2185 let opts = [] |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2186 |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2187 for in_opt in in_opts |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2188 let x = copy(in_opt) |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2189 for out_opt in out_opts |
15780
5b6c3c7feba8
patch 8.1.0897: can modify a:000 when using a reference
Bram Moolenaar <Bram@vim.org>
parents:
15766
diff
changeset
|
2190 let x = extend(copy(x), out_opt) |
15766
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2191 for err_opt in err_opts |
15780
5b6c3c7feba8
patch 8.1.0897: can modify a:000 when using a reference
Bram Moolenaar <Bram@vim.org>
parents:
15766
diff
changeset
|
2192 let x = extend(copy(x), err_opt) |
15766
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2193 let opts += [extend({'pty': 1}, x)] |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2194 endfor |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2195 endfor |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2196 endfor |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2197 |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2198 for opt in opts |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2199 let job = job_start('echo', opt) |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2200 let info = job_info(job) |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2201 let msg = printf('option={"in_io": "%s", "out_io": "%s", "err_io": "%s"}', |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2202 \ get(opt, 'in_io', 'tty'), |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2203 \ get(opt, 'out_io', 'tty'), |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2204 \ get(opt, 'err_io', 'tty')) |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2205 |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2206 if !has_key(opt, 'in_io') || !has_key(opt, 'out_io') || !has_key(opt, 'err_io') |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2207 call assert_notequal('', info.tty_in, msg) |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2208 else |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2209 call assert_equal('', info.tty_in, msg) |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2210 endif |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2211 call assert_equal(info.tty_in, info.tty_out, msg) |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2212 |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2213 call WaitForAssert({-> assert_equal('dead', job_status(job))}) |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2214 endfor |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2215 |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2216 call delete('Xtestin') |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2217 call delete('Xtestout') |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2218 call delete('Xtesterr') |
9d18e8457209
patch 8.1.0890: pty allocation wrong if using file for out channel
Bram Moolenaar <Bram@vim.org>
parents:
15764
diff
changeset
|
2219 endfunc |
17559
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2220 |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2221 " Do this last, it stops any channel log. |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2222 func Test_zz_nl_err_to_out_pipe() |
20923
a9516192b1db
patch 8.2.1013: channel tests can be a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2223 |
17831
4ab97fdf7ff7
patch 8.1.1912: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17657
diff
changeset
|
2224 eval 'Xlog'->ch_logfile() |
17559
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2225 call ch_log('Test_zz_nl_err_to_out_pipe()') |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2226 let job = job_start(s:python . " test_channel_pipe.py", {'err_io': 'out'}) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2227 call assert_equal("run", job_status(job)) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2228 try |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2229 let handle = job_getchannel(job) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2230 call ch_sendraw(handle, "echo something\n") |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2231 call assert_equal("something", ch_readraw(handle)) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2232 |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2233 call ch_sendraw(handle, "echoerr wrong\n") |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2234 call assert_equal("wrong", ch_readraw(handle)) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2235 finally |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2236 call job_stop(job) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2237 call ch_logfile('') |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2238 let loglines = readfile('Xlog') |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2239 call assert_true(len(loglines) > 10) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2240 let found_test = 0 |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2241 let found_send = 0 |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2242 let found_recv = 0 |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2243 let found_stop = 0 |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2244 for l in loglines |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2245 if l =~ 'Test_zz_nl_err_to_out_pipe' |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2246 let found_test = 1 |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2247 endif |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2248 if l =~ 'SEND on.*echo something' |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2249 let found_send = 1 |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2250 endif |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2251 if l =~ 'RECV on.*something' |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2252 let found_recv = 1 |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2253 endif |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2254 if l =~ 'Stopping job with' |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2255 let found_stop = 1 |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2256 endif |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2257 endfor |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2258 call assert_equal(1, found_test) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2259 call assert_equal(1, found_send) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2260 call assert_equal(1, found_recv) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2261 call assert_equal(1, found_stop) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2262 " On MS-Windows need to sleep for a moment to be able to delete the file. |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2263 sleep 10m |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2264 call delete('Xlog') |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2265 endtry |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2266 endfunc |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2267 |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2268 " Do this last, it stops any channel log. |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2269 func Test_zz_ch_log() |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2270 call ch_logfile('Xlog', 'w') |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2271 call ch_log('hello there') |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2272 call ch_log('%s%s') |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2273 call ch_logfile('') |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2274 let text = readfile('Xlog') |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2275 call assert_match("hello there", text[1]) |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2276 call assert_match("%s%s", text[2]) |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2277 call mkdir("Xdir1") |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2278 call assert_fails("call ch_logfile('Xdir1')", 'E484:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2279 cal delete("Xdir1", 'd') |
17559
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2280 call delete('Xlog') |
0ba896d48a56
patch 8.1.1777: useless checks for job feature in channel test
Bram Moolenaar <Bram@vim.org>
parents:
17557
diff
changeset
|
2281 endfunc |
19157
f2c8bc90f3c8
patch 8.2.0138: memory leak when starting a job fails
Bram Moolenaar <Bram@vim.org>
parents:
18943
diff
changeset
|
2282 |
19360
16d538568dc8
patch 8.2.0238: MS-Windows: job_stop() results in exit value zero
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
2283 func Test_issue_5150() |
19611
db60620b7afb
patch 8.2.0362: MS-Windows: channel test fails if grep is not available
Bram Moolenaar <Bram@vim.org>
parents:
19441
diff
changeset
|
2284 if has('win32') |
db60620b7afb
patch 8.2.0362: MS-Windows: channel test fails if grep is not available
Bram Moolenaar <Bram@vim.org>
parents:
19441
diff
changeset
|
2285 let cmd = 'cmd /c pause' |
db60620b7afb
patch 8.2.0362: MS-Windows: channel test fails if grep is not available
Bram Moolenaar <Bram@vim.org>
parents:
19441
diff
changeset
|
2286 else |
db60620b7afb
patch 8.2.0362: MS-Windows: channel test fails if grep is not available
Bram Moolenaar <Bram@vim.org>
parents:
19441
diff
changeset
|
2287 let cmd = 'grep foo' |
db60620b7afb
patch 8.2.0362: MS-Windows: channel test fails if grep is not available
Bram Moolenaar <Bram@vim.org>
parents:
19441
diff
changeset
|
2288 endif |
22969
dcb59b1cc0c1
patch 8.2.2031: some tests fail when run under valgrind
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2289 |
19611
db60620b7afb
patch 8.2.0362: MS-Windows: channel test fails if grep is not available
Bram Moolenaar <Bram@vim.org>
parents:
19441
diff
changeset
|
2290 let g:job = job_start(cmd, {}) |
22969
dcb59b1cc0c1
patch 8.2.2031: some tests fail when run under valgrind
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2291 sleep 50m " give the job time to start |
19360
16d538568dc8
patch 8.2.0238: MS-Windows: job_stop() results in exit value zero
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
2292 call job_stop(g:job) |
22969
dcb59b1cc0c1
patch 8.2.2031: some tests fail when run under valgrind
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2293 call WaitForAssert({-> assert_equal(-1, job_info(g:job).exitval)}) |
dcb59b1cc0c1
patch 8.2.2031: some tests fail when run under valgrind
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2294 |
dcb59b1cc0c1
patch 8.2.2031: some tests fail when run under valgrind
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2295 let g:job = job_start(cmd, {}) |
19651
283c8bc6a8e2
patch 8.2.0382: some tests fail when run under valgrind
Bram Moolenaar <Bram@vim.org>
parents:
19611
diff
changeset
|
2296 sleep 50m |
19360
16d538568dc8
patch 8.2.0238: MS-Windows: job_stop() results in exit value zero
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
2297 call job_stop(g:job, 'term') |
22969
dcb59b1cc0c1
patch 8.2.2031: some tests fail when run under valgrind
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2298 call WaitForAssert({-> assert_equal(-1, job_info(g:job).exitval)}) |
dcb59b1cc0c1
patch 8.2.2031: some tests fail when run under valgrind
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2299 |
19611
db60620b7afb
patch 8.2.0362: MS-Windows: channel test fails if grep is not available
Bram Moolenaar <Bram@vim.org>
parents:
19441
diff
changeset
|
2300 let g:job = job_start(cmd, {}) |
22969
dcb59b1cc0c1
patch 8.2.2031: some tests fail when run under valgrind
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2301 sleep 50m |
19360
16d538568dc8
patch 8.2.0238: MS-Windows: job_stop() results in exit value zero
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
2302 call job_stop(g:job, 'kill') |
22969
dcb59b1cc0c1
patch 8.2.2031: some tests fail when run under valgrind
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
2303 call WaitForAssert({-> assert_equal(-1, job_info(g:job).exitval)}) |
19360
16d538568dc8
patch 8.2.0238: MS-Windows: job_stop() results in exit value zero
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
2304 endfunc |
19362
7894f20668b1
patch 8.2.0239: MS-Windows: 'env' job option does not override existing vars
Bram Moolenaar <Bram@vim.org>
parents:
19360
diff
changeset
|
2305 |
7894f20668b1
patch 8.2.0239: MS-Windows: 'env' job option does not override existing vars
Bram Moolenaar <Bram@vim.org>
parents:
19360
diff
changeset
|
2306 func Test_issue_5485() |
7894f20668b1
patch 8.2.0239: MS-Windows: 'env' job option does not override existing vars
Bram Moolenaar <Bram@vim.org>
parents:
19360
diff
changeset
|
2307 let $VAR1 = 'global' |
7894f20668b1
patch 8.2.0239: MS-Windows: 'env' job option does not override existing vars
Bram Moolenaar <Bram@vim.org>
parents:
19360
diff
changeset
|
2308 let g:Ch_reply = "" |
7894f20668b1
patch 8.2.0239: MS-Windows: 'env' job option does not override existing vars
Bram Moolenaar <Bram@vim.org>
parents:
19360
diff
changeset
|
2309 let l:job = job_start([&shell, &shellcmdflag, has('win32') ? 'echo %VAR1% %VAR2%' : 'echo $VAR1 $VAR2'], {'env': {'VAR1': 'local', 'VAR2': 'local'}, 'callback': 'Ch_handler'}) |
7894f20668b1
patch 8.2.0239: MS-Windows: 'env' job option does not override existing vars
Bram Moolenaar <Bram@vim.org>
parents:
19360
diff
changeset
|
2310 let g:Ch_job = l:job |
7894f20668b1
patch 8.2.0239: MS-Windows: 'env' job option does not override existing vars
Bram Moolenaar <Bram@vim.org>
parents:
19360
diff
changeset
|
2311 call WaitForAssert({-> assert_equal("local local", trim(g:Ch_reply))}) |
7894f20668b1
patch 8.2.0239: MS-Windows: 'env' job option does not override existing vars
Bram Moolenaar <Bram@vim.org>
parents:
19360
diff
changeset
|
2312 unlet $VAR1 |
7894f20668b1
patch 8.2.0239: MS-Windows: 'env' job option does not override existing vars
Bram Moolenaar <Bram@vim.org>
parents:
19360
diff
changeset
|
2313 endfunc |
19724
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19715
diff
changeset
|
2314 |
19793
607e5d7968b9
patch 8.2.0453: trailing space in job_start() command causes empty argument
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
2315 func Test_job_trailing_space_unix() |
607e5d7968b9
patch 8.2.0453: trailing space in job_start() command causes empty argument
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
2316 CheckUnix |
607e5d7968b9
patch 8.2.0453: trailing space in job_start() command causes empty argument
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
2317 CheckExecutable cat |
20923
a9516192b1db
patch 8.2.1013: channel tests can be a bit flaky
Bram Moolenaar <Bram@vim.org>
parents:
20213
diff
changeset
|
2318 |
19793
607e5d7968b9
patch 8.2.0453: trailing space in job_start() command causes empty argument
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
2319 let job = job_start("cat ", #{in_io: 'null'}) |
607e5d7968b9
patch 8.2.0453: trailing space in job_start() command causes empty argument
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
2320 call WaitForAssert({-> assert_equal("dead", job_status(job))}) |
607e5d7968b9
patch 8.2.0453: trailing space in job_start() command causes empty argument
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
2321 call assert_equal(0, job_info(job).exitval) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
2322 |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
28244
diff
changeset
|
2323 call delete('Xtestsocket') |
19793
607e5d7968b9
patch 8.2.0453: trailing space in job_start() command causes empty argument
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
2324 endfunc |
607e5d7968b9
patch 8.2.0453: trailing space in job_start() command causes empty argument
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
2325 |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2326 func Test_ch_getbufnr() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2327 let ch = test_null_channel() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2328 call assert_equal(-1, ch_getbufnr(ch, 'in')) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2329 call assert_equal(-1, ch_getbufnr(ch, 'out')) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2330 call assert_equal(-1, ch_getbufnr(ch, 'err')) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2331 call assert_equal(-1, ch_getbufnr(ch, '')) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2332 endfunc |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2333 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2334 " Test for unsupported options passed to ch_status() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2335 func Test_invalid_job_chan_options() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2336 let ch = test_null_channel() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2337 let invalid_opts = [ |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2338 \ {'in_io' : 'null'}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2339 \ {'out_io' : 'null'}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2340 \ {'err_io' : 'null'}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2341 \ {'mode' : 'json'}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2342 \ {'out_mode' : 'json'}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2343 \ {'err_mode' : 'json'}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2344 \ {'noblock' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2345 \ {'in_name' : '/a/b'}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2346 \ {'pty' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2347 \ {'in_buf' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2348 \ {'out_buf' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2349 \ {'err_buf' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2350 \ {'out_modifiable' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2351 \ {'err_modifiable' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2352 \ {'out_msg' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2353 \ {'err_msg' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2354 \ {'in_top' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2355 \ {'in_bot' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2356 \ {'channel' : ch}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2357 \ {'callback' : ''}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2358 \ {'out_cb' : ''}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2359 \ {'err_cb' : ''}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2360 \ {'close_cb' : ''}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2361 \ {'exit_cb' : ''}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2362 \ {'term_opencmd' : ''}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2363 \ {'eof_chars' : ''}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2364 \ {'term_rows' : 10}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2365 \ {'term_cols' : 10}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2366 \ {'vertical' : 0}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2367 \ {'curwin' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2368 \ {'bufnr' : 1}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2369 \ {'hidden' : 0}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2370 \ {'norestore' : 0}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2371 \ {'term_kill' : 'kill'}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2372 \ {'tty_type' : ''}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2373 \ {'term_highlight' : ''}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2374 \ {'env' : {}}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2375 \ {'cwd' : ''}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2376 \ {'timeout' : 0}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2377 \ {'out_timeout' : 0}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2378 \ {'err_timeout' : 0}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2379 \ {'id' : 0}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2380 \ {'stoponexit' : ''}, |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2381 \ {'block_write' : 1} |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2382 \ ] |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2383 if has('gui') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2384 call add(invalid_opts, {'ansi_colors' : []}) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2385 endif |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2386 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2387 for opt in invalid_opts |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2388 call assert_fails("let x = ch_status(ch, opt)", 'E475:') |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2389 endfor |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
20031
diff
changeset
|
2390 call assert_equal('fail', ch_status(ch, test_null_dict())) |
19852
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2391 endfunc |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2392 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2393 " Test for passing the command and the arguments as List on MS-Windows |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2394 func Test_job_with_list_args() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2395 CheckMSWindows |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2396 |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2397 enew! |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2398 let bnum = bufnr() |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2399 let job = job_start(['cmd', '/c', 'echo', 'Hello', 'World'], {'out_io' : 'buffer', 'out_buf' : bnum}) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2400 call WaitForAssert({-> assert_equal("dead", job_status(job))}) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2401 call assert_equal('Hello World', getline(1)) |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2402 %bw! |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2403 endfunc |
12518b40c161
patch 8.2.0482: channel and sandbox code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19838
diff
changeset
|
2404 |
20213
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2405 func ExitCb_cb_with_input(job, status) |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2406 call feedkeys(":\<C-u>echo input('', 'default')\<CR>\<CR>", 'nx') |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2407 call assert_equal('default', Screenline(&lines)) |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2408 let g:wait_exit_cb = 0 |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2409 endfunc |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2410 |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2411 func Test_cb_with_input() |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2412 let g:wait_exit_cb = 1 |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2413 |
22977
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
2414 if has('win32') |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
2415 let cmd = 'cmd /c echo "Vim''s test"' |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
2416 else |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
2417 let cmd = 'echo "Vim''s test"' |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
2418 endif |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
2419 |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
2420 let job = job_start(cmd, {'out_cb': 'ExitCb_cb_with_input'}) |
515d1651c6c6
patch 8.2.2035: MS-Windows: some tests may fail
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
2421 call WaitFor({-> job_status(job) == "dead"}) |
20213
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2422 call WaitForAssert({-> assert_equal(0, g:wait_exit_cb)}) |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2423 |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2424 unlet g:wait_exit_cb |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2425 endfunc |
8d9229c4781a
patch 8.2.0662: cannot use input() in a channel callback
Bram Moolenaar <Bram@vim.org>
parents:
20178
diff
changeset
|
2426 |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2427 function s:HandleBufEnter() abort |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2428 let queue = [] |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2429 let job = job_start(['date'], {'callback': { j, d -> add(queue, d) }}) |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2430 while empty(queue) |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2431 sleep! 10m |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2432 endwhile |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2433 endfunction |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2434 |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2435 func Test_parse_messages_in_autocmd() |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2436 CheckUnix |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2437 |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2438 " Check that in the BufEnter autocommand events are being handled |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2439 augroup bufenterjob |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2440 autocmd! |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2441 autocmd BufEnter Xbufenterjob call s:HandleBufEnter() |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2442 augroup END |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2443 |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2444 only |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2445 split Xbufenterjob |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2446 wincmd p |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2447 redraw |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2448 |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2449 close |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2450 augroup bufenterjob |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2451 autocmd! |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2452 augroup END |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2453 endfunc |
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2454 |
25891
58b1c9d96ec6
patch 8.2.3479: crash when calling job_start with an invalid argument
Bram Moolenaar <Bram@vim.org>
parents:
25686
diff
changeset
|
2455 func Test_job_start_with_invalid_argument() |
58b1c9d96ec6
patch 8.2.3479: crash when calling job_start with an invalid argument
Bram Moolenaar <Bram@vim.org>
parents:
25686
diff
changeset
|
2456 call assert_fails('call job_start([0zff])', 'E976:') |
58b1c9d96ec6
patch 8.2.3479: crash when calling job_start with an invalid argument
Bram Moolenaar <Bram@vim.org>
parents:
25686
diff
changeset
|
2457 endfunc |
58b1c9d96ec6
patch 8.2.3479: crash when calling job_start with an invalid argument
Bram Moolenaar <Bram@vim.org>
parents:
25686
diff
changeset
|
2458 |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2459 " Test for the 'lsp' channel mode |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2460 func LspCb(chan, msg) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2461 call add(g:lspNotif, a:msg) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2462 endfunc |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2463 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2464 func LspOtCb(chan, msg) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2465 call add(g:lspOtMsgs, a:msg) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2466 endfunc |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2467 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2468 func LspTests(port) |
28528
6b1da12297e5
patch 8.2.4788: large payload for LSP message not tested
Bram Moolenaar <Bram@vim.org>
parents:
28511
diff
changeset
|
2469 " call ch_logfile('Xlspclient.log', 'w') |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2470 let ch = ch_open(s:localhost .. a:port, #{mode: 'lsp', callback: 'LspCb'}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2471 if ch_status(ch) == "fail" |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2472 call assert_report("Can't open the lsp channel") |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2473 return |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2474 endif |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2475 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2476 " check for channel information |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2477 let info = ch_info(ch) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2478 call assert_equal('LSP', info.sock_mode) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2479 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2480 " Evaluate an expression |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2481 let resp = ch_evalexpr(ch, #{method: 'simple-rpc', params: [10, 20]}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2482 call assert_false(empty(resp)) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2483 call assert_equal(#{id: 1, jsonrpc: '2.0', result: 'simple-rpc'}, resp) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2484 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2485 " Evaluate an expression. While waiting for the response, a notification |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2486 " message is delivered. |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2487 let g:lspNotif = [] |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2488 let resp = ch_evalexpr(ch, #{method: 'rpc-with-notif', params: {'v': 10}}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2489 call assert_false(empty(resp)) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2490 call assert_equal(#{id: 2, jsonrpc: '2.0', result: 'rpc-with-notif-resp'}, |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2491 \ resp) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2492 call assert_equal([#{jsonrpc: '2.0', result: 'rpc-with-notif-notif'}], |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2493 \ g:lspNotif) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2494 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2495 " Wrong payload notification test |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2496 let g:lspNotif = [] |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2497 let r = ch_sendexpr(ch, #{method: 'wrong-payload', params: {}}) |
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2498 call assert_equal({}, r) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2499 " Send a ping to wait for all the notification messages to arrive |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2500 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2501 call assert_equal([#{jsonrpc: '2.0', result: 'wrong-payload'}], g:lspNotif) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2502 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2503 " Test for receiving a response with incorrect 'id' and additional |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2504 " notification messages while evaluating an expression. |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2505 let g:lspNotif = [] |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2506 let resp = ch_evalexpr(ch, #{method: 'rpc-resp-incorrect-id', |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2507 \ params: {'a': [1, 2]}}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2508 call assert_false(empty(resp)) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2509 call assert_equal(#{id: 4, jsonrpc: '2.0', |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2510 \ result: 'rpc-resp-incorrect-id-4'}, resp) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2511 call assert_equal([#{jsonrpc: '2.0', result: 'rpc-resp-incorrect-id-1'}, |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2512 \ #{jsonrpc: '2.0', result: 'rpc-resp-incorrect-id-2'}, |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2513 \ #{jsonrpc: '2.0', id: 1, result: 'rpc-resp-incorrect-id-3'}], |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2514 \ g:lspNotif) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2515 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2516 " simple notification test |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2517 let g:lspNotif = [] |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2518 call ch_sendexpr(ch, #{method: 'simple-notif', params: [#{a: 10, b: []}]}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2519 " Send a ping to wait for all the notification messages to arrive |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2520 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2521 call assert_equal([#{jsonrpc: '2.0', result: 'simple-notif'}], g:lspNotif) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2522 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2523 " multiple notifications test |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2524 let g:lspNotif = [] |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2525 call ch_sendexpr(ch, #{method: 'multi-notif', params: [#{a: {}, b: {}}]}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2526 " Send a ping to wait for all the notification messages to arrive |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2527 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2528 call assert_equal([#{jsonrpc: '2.0', result: 'multi-notif1'}, |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2529 \ #{jsonrpc: '2.0', result: 'multi-notif2'}], g:lspNotif) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2530 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2531 " Test for sending a message with an identifier. |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2532 let g:lspNotif = [] |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2533 call ch_sendexpr(ch, #{method: 'msg-with-id', id: 93, params: #{s: 'str'}}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2534 " Send a ping to wait for all the notification messages to arrive |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2535 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2536 call assert_equal([#{jsonrpc: '2.0', id: 93, result: 'msg-with-id'}], |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2537 \ g:lspNotif) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2538 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2539 " Test for setting the 'id' value in a request message |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2540 let resp = ch_evalexpr(ch, #{method: 'ping', id: 1, params: {}}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2541 call assert_equal(#{id: 8, jsonrpc: '2.0', result: 'alive'}, resp) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2542 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2543 " Test for using a one time callback function to process a response |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2544 let g:lspOtMsgs = [] |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2545 let r = ch_sendexpr(ch, #{method: 'msg-specifc-cb', params: {}}, |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2546 \ #{callback: 'LspOtCb'}) |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2547 call assert_equal(9, r.id) |
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2548 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2549 call assert_equal([#{id: 9, jsonrpc: '2.0', result: 'msg-specifc-cb'}], |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2550 \ g:lspOtMsgs) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2551 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2552 " Test for generating a request message from the other end (server) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2553 let g:lspNotif = [] |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2554 call ch_sendexpr(ch, #{method: 'server-req', params: #{}}) |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2555 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2556 call assert_equal([{'id': 201, 'jsonrpc': '2.0', |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2557 \ 'result': {'method': 'checkhealth', 'params': {'a': 20}}}], |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2558 \ g:lspNotif) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2559 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2560 " Test for sending a message without an id |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2561 let g:lspNotif = [] |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2562 call ch_sendexpr(ch, #{method: 'echo', params: #{s: 'msg-without-id'}}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2563 " Send a ping to wait for all the notification messages to arrive |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2564 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2565 call assert_equal([#{jsonrpc: '2.0', result: |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2566 \ #{method: 'echo', jsonrpc: '2.0', params: #{s: 'msg-without-id'}}}], |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2567 \ g:lspNotif) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2568 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2569 " Test for sending a notification message with an id |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2570 let g:lspNotif = [] |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2571 call ch_sendexpr(ch, #{method: 'echo', id: 110, params: #{s: 'msg-with-id'}}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2572 " Send a ping to wait for all the notification messages to arrive |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2573 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2574 call assert_equal([#{jsonrpc: '2.0', result: |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2575 \ #{method: 'echo', jsonrpc: '2.0', id: 110, |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2576 \ params: #{s: 'msg-with-id'}}}], g:lspNotif) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2577 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2578 " Test for processing the extra fields in the HTTP header |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2579 let resp = ch_evalexpr(ch, #{method: 'extra-hdr-fields', params: {}}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2580 call assert_equal({'id': 14, 'jsonrpc': '2.0', 'result': 'extra-hdr-fields'}, |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2581 \ resp) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2582 |
28511
d7ca583e5772
patch 8.2.4780: parsing an LSP message fails when it is split
Bram Moolenaar <Bram@vim.org>
parents:
28467
diff
changeset
|
2583 " Test for processing delayed payload |
d7ca583e5772
patch 8.2.4780: parsing an LSP message fails when it is split
Bram Moolenaar <Bram@vim.org>
parents:
28467
diff
changeset
|
2584 let resp = ch_evalexpr(ch, #{method: 'delayed-payload', params: {}}) |
d7ca583e5772
patch 8.2.4780: parsing an LSP message fails when it is split
Bram Moolenaar <Bram@vim.org>
parents:
28467
diff
changeset
|
2585 call assert_equal({'id': 15, 'jsonrpc': '2.0', 'result': 'delayed-payload'}, |
d7ca583e5772
patch 8.2.4780: parsing an LSP message fails when it is split
Bram Moolenaar <Bram@vim.org>
parents:
28467
diff
changeset
|
2586 \ resp) |
d7ca583e5772
patch 8.2.4780: parsing an LSP message fails when it is split
Bram Moolenaar <Bram@vim.org>
parents:
28467
diff
changeset
|
2587 |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2588 " Test for processing a HTTP header without the Content-Length field |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2589 let resp = ch_evalexpr(ch, #{method: 'hdr-without-len', params: {}}, |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2590 \ #{timeout: 200}) |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2591 call assert_equal({}, resp) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2592 " send a ping to make sure communication still works |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2593 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2594 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2595 " Test for processing a HTTP header with wrong length |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2596 let resp = ch_evalexpr(ch, #{method: 'hdr-with-wrong-len', params: {}}, |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2597 \ #{timeout: 200}) |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2598 call assert_equal({}, resp) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2599 " send a ping to make sure communication still works |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2600 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2601 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2602 " Test for processing a HTTP header with negative length |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2603 let resp = ch_evalexpr(ch, #{method: 'hdr-with-negative-len', params: {}}, |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2604 \ #{timeout: 200}) |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2605 call assert_equal({}, resp) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2606 " send a ping to make sure communication still works |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2607 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2608 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2609 " Test for an empty header |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2610 let resp = ch_evalexpr(ch, #{method: 'empty-header', params: {}}, |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2611 \ #{timeout: 200}) |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2612 call assert_equal({}, resp) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2613 " send a ping to make sure communication still works |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2614 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2615 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2616 " Test for an empty payload |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2617 let resp = ch_evalexpr(ch, #{method: 'empty-payload', params: {}}, |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2618 \ #{timeout: 200}) |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2619 call assert_equal({}, resp) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2620 " send a ping to make sure communication still works |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2621 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2622 |
28528
6b1da12297e5
patch 8.2.4788: large payload for LSP message not tested
Bram Moolenaar <Bram@vim.org>
parents:
28511
diff
changeset
|
2623 " Test for a large payload |
6b1da12297e5
patch 8.2.4788: large payload for LSP message not tested
Bram Moolenaar <Bram@vim.org>
parents:
28511
diff
changeset
|
2624 let content = repeat('abcdef', 11000) |
6b1da12297e5
patch 8.2.4788: large payload for LSP message not tested
Bram Moolenaar <Bram@vim.org>
parents:
28511
diff
changeset
|
2625 let resp = ch_evalexpr(ch, #{method: 'large-payload', |
6b1da12297e5
patch 8.2.4788: large payload for LSP message not tested
Bram Moolenaar <Bram@vim.org>
parents:
28511
diff
changeset
|
2626 \ params: #{text: content}}) |
6b1da12297e5
patch 8.2.4788: large payload for LSP message not tested
Bram Moolenaar <Bram@vim.org>
parents:
28511
diff
changeset
|
2627 call assert_equal(#{jsonrpc: '2.0', id: 26, result: |
6b1da12297e5
patch 8.2.4788: large payload for LSP message not tested
Bram Moolenaar <Bram@vim.org>
parents:
28511
diff
changeset
|
2628 \ #{method: 'large-payload', jsonrpc: '2.0', id: 26, |
6b1da12297e5
patch 8.2.4788: large payload for LSP message not tested
Bram Moolenaar <Bram@vim.org>
parents:
28511
diff
changeset
|
2629 \ params: #{text: content}}}, resp) |
6b1da12297e5
patch 8.2.4788: large payload for LSP message not tested
Bram Moolenaar <Bram@vim.org>
parents:
28511
diff
changeset
|
2630 " send a ping to make sure communication still works |
6b1da12297e5
patch 8.2.4788: large payload for LSP message not tested
Bram Moolenaar <Bram@vim.org>
parents:
28511
diff
changeset
|
2631 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
6b1da12297e5
patch 8.2.4788: large payload for LSP message not tested
Bram Moolenaar <Bram@vim.org>
parents:
28511
diff
changeset
|
2632 |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2633 " Test for invoking an unsupported method |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2634 let resp = ch_evalexpr(ch, #{method: 'xyz', params: {}}, #{timeout: 200}) |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2635 call assert_equal({}, resp) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2636 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2637 " Test for sending a message without a callback function. Notification |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2638 " message should be dropped but RPC response should not be dropped. |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2639 call ch_setoptions(ch, #{callback: ''}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2640 let g:lspNotif = [] |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2641 call ch_sendexpr(ch, #{method: 'echo', params: #{s: 'no-callback'}}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2642 " Send a ping to wait for all the notification messages to arrive |
28467
3beb14b12bbd
patch 8.2.4758: when using an LSP channel want to get the message ID
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
2643 call assert_equal('alive', ch_evalexpr(ch, #{method: 'ping'}).result) |
28244
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2644 call assert_equal([], g:lspNotif) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2645 " Restore the callback function |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2646 call ch_setoptions(ch, #{callback: 'LspCb'}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2647 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2648 " " Test for sending a raw message |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2649 " let g:lspNotif = [] |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2650 " let s = "Content-Length: 62\r\n" |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2651 " let s ..= "Content-Type: application/vim-jsonrpc; charset=utf-8\r\n" |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2652 " let s ..= "\r\n" |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2653 " let s ..= '{"method":"echo","jsonrpc":"2.0","params":{"m":"raw-message"}}' |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2654 " call ch_sendraw(ch, s) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2655 " call ch_evalexpr(ch, #{method: 'ping'}) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2656 " call assert_equal([{'jsonrpc': '2.0', |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2657 " \ 'result': {'method': 'echo', 'jsonrpc': '2.0', |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2658 " \ 'params': {'m': 'raw-message'}}}], g:lspNotif) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2659 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2660 " Invalid arguments to ch_evalexpr() and ch_sendexpr() |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2661 call assert_fails('call ch_sendexpr(ch, #{method: "cookie", id: "cookie"})', |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2662 \ 'E475:') |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2663 call assert_fails('call ch_evalexpr(ch, #{method: "ping", id: [{}]})', 'E475:') |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2664 call assert_fails('call ch_evalexpr(ch, [1, 2, 3])', 'E1206:') |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2665 call assert_fails('call ch_sendexpr(ch, "abc")', 'E1206:') |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2666 call assert_fails('call ch_evalexpr(ch, #{method: "ping"}, #{callback: "LspOtCb"})', 'E917:') |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2667 " call ch_logfile('', 'w') |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2668 endfunc |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2669 |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2670 func Test_channel_lsp_mode() |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2671 call RunServer('test_channel_lsp.py', 'LspTests', []) |
85b07a942518
patch 8.2.4648: handling LSP messages is a bit slow
Bram Moolenaar <Bram@vim.org>
parents:
26610
diff
changeset
|
2672 endfunc |
25501
a1ed55c02e80
patch 8.2.3287: channel events not handled in BufEnter autocommand
Bram Moolenaar <Bram@vim.org>
parents:
25433
diff
changeset
|
2673 |
19724
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19715
diff
changeset
|
2674 " vim: shiftwidth=2 sts=2 expandtab |