Mercurial > vim
annotate src/testdir/test_channel.py @ 21644:7d3ba70a03f1 v8.2.1372
patch 8.2.1372: Vim9: no error for missing white space around operator
Commit: https://github.com/vim/vim/commit/fdac71c5075062f97f77044e9619fa5c907e0327
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 5 12:44:41 2020 +0200
patch 8.2.1372: Vim9: no error for missing white space around operator
Problem: Vim9: no error for missing white space around operator.
Solution: Check for white space around ? and :.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 05 Aug 2020 12:45:04 +0200 |
parents | 235be779549f |
children | 73503bafb3bf |
rev | line source |
---|---|
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
13351
diff
changeset
|
1 #!/usr/bin/env python |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 # |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 # Server that will accept connections from a Vim channel. |
8041
c6443e78cf2d
commit https://github.com/vim/vim/commit/7707344ddec9069b495b2a5ed41f2104466fc88b
Christian Brabandt <cb@256bit.org>
parents:
8009
diff
changeset
|
4 # Used by test_channel.vim. |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 # |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 # This requires Python 2.6 or later. |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 from __future__ import print_function |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 import json |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 import socket |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 import sys |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
12 import time |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 import threading |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 try: |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 # Python 3 |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 import socketserver |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 except ImportError: |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 # Python 2 |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 import SocketServer as socketserver |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler): |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 |
20464
235be779549f
patch 8.2.0786: channel test is flaky on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20003
diff
changeset
|
24 def setup(self): |
235be779549f
patch 8.2.0786: channel test is flaky on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20003
diff
changeset
|
25 self.request.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) |
235be779549f
patch 8.2.0786: channel test is flaky on FreeBSD
Bram Moolenaar <Bram@vim.org>
parents:
20003
diff
changeset
|
26 |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 def handle(self): |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 print("=== socket opened ===") |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 while True: |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 try: |
7914
35973ce58c84
commit https://github.com/vim/vim/commit/608a8919cae982cb38e38725a843df47b234dae6
Christian Brabandt <cb@256bit.org>
parents:
7912
diff
changeset
|
31 received = self.request.recv(4096).decode('utf-8') |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 except socket.error: |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 print("=== socket error ===") |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 break |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 except IOError: |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 print("=== socket closed ===") |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 break |
7914
35973ce58c84
commit https://github.com/vim/vim/commit/608a8919cae982cb38e38725a843df47b234dae6
Christian Brabandt <cb@256bit.org>
parents:
7912
diff
changeset
|
38 if received == '': |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 print("=== socket closed ===") |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 break |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
41 print("received: {0}".format(received)) |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
42 |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
43 # We may receive two messages at once. Take the part up to the |
9969
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
8746
diff
changeset
|
44 # newline, which should be after the matching "]". |
7914
35973ce58c84
commit https://github.com/vim/vim/commit/608a8919cae982cb38e38725a843df47b234dae6
Christian Brabandt <cb@256bit.org>
parents:
7912
diff
changeset
|
45 todo = received |
35973ce58c84
commit https://github.com/vim/vim/commit/608a8919cae982cb38e38725a843df47b234dae6
Christian Brabandt <cb@256bit.org>
parents:
7912
diff
changeset
|
46 while todo != '': |
9969
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
8746
diff
changeset
|
47 splitidx = todo.find('\n') |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
48 if splitidx < 0: |
7914
35973ce58c84
commit https://github.com/vim/vim/commit/608a8919cae982cb38e38725a843df47b234dae6
Christian Brabandt <cb@256bit.org>
parents:
7912
diff
changeset
|
49 used = todo |
35973ce58c84
commit https://github.com/vim/vim/commit/608a8919cae982cb38e38725a843df47b234dae6
Christian Brabandt <cb@256bit.org>
parents:
7912
diff
changeset
|
50 todo = '' |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
51 else: |
9969
176e34b0d678
commit https://github.com/vim/vim/commit/f1f0792e55e72cdc7c833b30f565a9b02f18bb1e
Christian Brabandt <cb@256bit.org>
parents:
8746
diff
changeset
|
52 used = todo[:splitidx] |
7914
35973ce58c84
commit https://github.com/vim/vim/commit/608a8919cae982cb38e38725a843df47b234dae6
Christian Brabandt <cb@256bit.org>
parents:
7912
diff
changeset
|
53 todo = todo[splitidx + 1:] |
35973ce58c84
commit https://github.com/vim/vim/commit/608a8919cae982cb38e38725a843df47b234dae6
Christian Brabandt <cb@256bit.org>
parents:
7912
diff
changeset
|
54 if used != received: |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
55 print("using: {0}".format(used)) |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
56 |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
57 try: |
7914
35973ce58c84
commit https://github.com/vim/vim/commit/608a8919cae982cb38e38725a843df47b234dae6
Christian Brabandt <cb@256bit.org>
parents:
7912
diff
changeset
|
58 decoded = json.loads(used) |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
59 except ValueError: |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
60 print("json decoding failed") |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
61 decoded = [-1, ''] |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
63 # Send a response if the sequence number is positive. |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
64 if decoded[0] >= 0: |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
65 if decoded[1] == 'hello!': |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
66 # simply send back a string |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
67 response = "got it" |
13351
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
68 elif decoded[1] == 'malformed1': |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
69 cmd = '["ex",":"]wrong!["ex","smi"]' |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
70 print("sending: {0}".format(cmd)) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
71 self.request.sendall(cmd.encode('utf-8')) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
72 response = "ok" |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
73 # Need to wait for Vim to give up, otherwise it |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
74 # sometimes fails on OS X. |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
75 time.sleep(0.2) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
76 elif decoded[1] == 'malformed2': |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
77 cmd = '"unterminated string' |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
78 print("sending: {0}".format(cmd)) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
79 self.request.sendall(cmd.encode('utf-8')) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
80 response = "ok" |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
81 # Need to wait for Vim to give up, otherwise the double |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
82 # quote in the "ok" response terminates the string. |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
83 time.sleep(0.2) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
84 elif decoded[1] == 'malformed3': |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
85 cmd = '["ex","missing ]"' |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
86 print("sending: {0}".format(cmd)) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
87 self.request.sendall(cmd.encode('utf-8')) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
88 response = "ok" |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
89 # Need to wait for Vim to give up, otherwise the ] |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
90 # in the "ok" response terminates the list. |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
91 time.sleep(0.2) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
92 elif decoded[1] == 'split': |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
93 cmd = '["ex","let ' |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
94 print("sending: {0}".format(cmd)) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
95 self.request.sendall(cmd.encode('utf-8')) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
96 time.sleep(0.01) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
97 cmd = 'g:split = 123"]' |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
98 print("sending: {0}".format(cmd)) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
99 self.request.sendall(cmd.encode('utf-8')) |
33a2277b8d4d
patch 8.0.1549: various small problems in test files
Christian Brabandt <cb@256bit.org>
parents:
10458
diff
changeset
|
100 response = "ok" |
8382
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
101 elif decoded[1].startswith("echo "): |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
102 # send back the argument |
3dbe93a240d8
commit https://github.com/vim/vim/commit/d6547fc6471d9084f942bdc4ae3aedb39361751d
Christian Brabandt <cb@256bit.org>
parents:
8210
diff
changeset
|
103 response = decoded[1][5:] |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
104 elif decoded[1] == 'make change': |
7918
ce5a7a613867
commit https://github.com/vim/vim/commit/66624ff0d9e1de2fc5eb4f95f3a3a2ed70b10138
Christian Brabandt <cb@256bit.org>
parents:
7916
diff
changeset
|
105 # Send two ex commands at the same time, before |
ce5a7a613867
commit https://github.com/vim/vim/commit/66624ff0d9e1de2fc5eb4f95f3a3a2ed70b10138
Christian Brabandt <cb@256bit.org>
parents:
7916
diff
changeset
|
106 # replying to the request. |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
107 cmd = '["ex","call append(\\"$\\",\\"added1\\")"]' |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
108 cmd += '["ex","call append(\\"$\\",\\"added2\\")"]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
109 print("sending: {0}".format(cmd)) |
7916
54602dcac207
commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents:
7914
diff
changeset
|
110 self.request.sendall(cmd.encode('utf-8')) |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
111 response = "ok" |
8746
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8744
diff
changeset
|
112 elif decoded[1] == 'bad command': |
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8744
diff
changeset
|
113 cmd = '["ex","foo bar"]' |
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8744
diff
changeset
|
114 print("sending: {0}".format(cmd)) |
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8744
diff
changeset
|
115 self.request.sendall(cmd.encode('utf-8')) |
4c38a4733578
commit https://github.com/vim/vim/commit/c4dcd60c76666bf113719f929709ad6120eb6528
Christian Brabandt <cb@256bit.org>
parents:
8744
diff
changeset
|
116 response = "ok" |
7939
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
117 elif decoded[1] == 'do normal': |
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
118 # Send a normal command. |
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
119 cmd = '["normal","G$s more\u001b"]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
120 print("sending: {0}".format(cmd)) |
7939
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
121 self.request.sendall(cmd.encode('utf-8')) |
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
122 response = "ok" |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
123 elif decoded[1] == 'eval-works': |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
124 # Send an eval request. We ignore the response. |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8153
diff
changeset
|
125 cmd = '["expr","\\"foo\\" . 123", -1]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
126 print("sending: {0}".format(cmd)) |
7916
54602dcac207
commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents:
7914
diff
changeset
|
127 self.request.sendall(cmd.encode('utf-8')) |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
128 response = "ok" |
8744
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
129 elif decoded[1] == 'eval-special': |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
130 # Send an eval request. We ignore the response. |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
131 cmd = '["expr","\\"foo\x7f\x10\x01bar\\"", -2]' |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
132 print("sending: {0}".format(cmd)) |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
133 self.request.sendall(cmd.encode('utf-8')) |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
134 response = "ok" |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
135 elif decoded[1] == 'eval-getline': |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
136 # Send an eval request. We ignore the response. |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
137 cmd = '["expr","getline(3)", -3]' |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
138 print("sending: {0}".format(cmd)) |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
139 self.request.sendall(cmd.encode('utf-8')) |
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
140 response = "ok" |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
141 elif decoded[1] == 'eval-fails': |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
142 # Send an eval request that will fail. |
8744
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
143 cmd = '["expr","xxx", -4]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
144 print("sending: {0}".format(cmd)) |
7916
54602dcac207
commit https://github.com/vim/vim/commit/3b05b135e3ee4cfd59983fd63461e8f7642c1713
Christian Brabandt <cb@256bit.org>
parents:
7914
diff
changeset
|
145 self.request.sendall(cmd.encode('utf-8')) |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
146 response = "ok" |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7939
diff
changeset
|
147 elif decoded[1] == 'eval-error': |
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7939
diff
changeset
|
148 # Send an eval request that works but the result can't |
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7939
diff
changeset
|
149 # be encoded. |
8744
ff9973bbbfcb
commit https://github.com/vim/vim/commit/fa8b2e173dd5f6c4a5cfd326abdcf68b8eebf90d
Christian Brabandt <cb@256bit.org>
parents:
8663
diff
changeset
|
150 cmd = '["expr","function(\\"tr\\")", -5]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
151 print("sending: {0}".format(cmd)) |
7965
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7939
diff
changeset
|
152 self.request.sendall(cmd.encode('utf-8')) |
646d5148fee2
commit https://github.com/vim/vim/commit/55fab439a6f3bba6dbe780ac034b84d5822a1a96
Christian Brabandt <cb@256bit.org>
parents:
7939
diff
changeset
|
153 response = "ok" |
7918
ce5a7a613867
commit https://github.com/vim/vim/commit/66624ff0d9e1de2fc5eb4f95f3a3a2ed70b10138
Christian Brabandt <cb@256bit.org>
parents:
7916
diff
changeset
|
154 elif decoded[1] == 'eval-bad': |
ce5a7a613867
commit https://github.com/vim/vim/commit/66624ff0d9e1de2fc5eb4f95f3a3a2ed70b10138
Christian Brabandt <cb@256bit.org>
parents:
7916
diff
changeset
|
155 # Send an eval request missing the third argument. |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8153
diff
changeset
|
156 cmd = '["expr","xxx"]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
157 print("sending: {0}".format(cmd)) |
7918
ce5a7a613867
commit https://github.com/vim/vim/commit/66624ff0d9e1de2fc5eb4f95f3a3a2ed70b10138
Christian Brabandt <cb@256bit.org>
parents:
7916
diff
changeset
|
158 self.request.sendall(cmd.encode('utf-8')) |
ce5a7a613867
commit https://github.com/vim/vim/commit/66624ff0d9e1de2fc5eb4f95f3a3a2ed70b10138
Christian Brabandt <cb@256bit.org>
parents:
7916
diff
changeset
|
159 response = "ok" |
7939
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
160 elif decoded[1] == 'an expr': |
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
161 # Send an expr request. |
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
162 cmd = '["expr","setline(\\"$\\", [\\"one\\",\\"two\\",\\"three\\"])"]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
163 print("sending: {0}".format(cmd)) |
7939
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
164 self.request.sendall(cmd.encode('utf-8')) |
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
165 response = "ok" |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8153
diff
changeset
|
166 elif decoded[1] == 'call-func': |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8153
diff
changeset
|
167 cmd = '["call","MyFunction",[1,2,3], 0]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
168 print("sending: {0}".format(cmd)) |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8153
diff
changeset
|
169 self.request.sendall(cmd.encode('utf-8')) |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8153
diff
changeset
|
170 response = "ok" |
7939
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
171 elif decoded[1] == 'redraw': |
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
172 cmd = '["redraw",""]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
173 print("sending: {0}".format(cmd)) |
7939
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
174 self.request.sendall(cmd.encode('utf-8')) |
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
175 response = "ok" |
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
176 elif decoded[1] == 'redraw!': |
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
177 cmd = '["redraw","force"]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
178 print("sending: {0}".format(cmd)) |
7939
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
179 self.request.sendall(cmd.encode('utf-8')) |
dcc0bd6b1574
commit https://github.com/vim/vim/commit/f416086f264c1d998863b2e600f4c14f799d0d99
Christian Brabandt <cb@256bit.org>
parents:
7937
diff
changeset
|
180 response = "ok" |
7937
2e905dfc6999
commit https://github.com/vim/vim/commit/6076fe1986255d32b7a078a28bf9e7bea19d6f30
Christian Brabandt <cb@256bit.org>
parents:
7920
diff
changeset
|
181 elif decoded[1] == 'empty-request': |
2e905dfc6999
commit https://github.com/vim/vim/commit/6076fe1986255d32b7a078a28bf9e7bea19d6f30
Christian Brabandt <cb@256bit.org>
parents:
7920
diff
changeset
|
182 cmd = '[]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
183 print("sending: {0}".format(cmd)) |
7937
2e905dfc6999
commit https://github.com/vim/vim/commit/6076fe1986255d32b7a078a28bf9e7bea19d6f30
Christian Brabandt <cb@256bit.org>
parents:
7920
diff
changeset
|
184 self.request.sendall(cmd.encode('utf-8')) |
2e905dfc6999
commit https://github.com/vim/vim/commit/6076fe1986255d32b7a078a28bf9e7bea19d6f30
Christian Brabandt <cb@256bit.org>
parents:
7920
diff
changeset
|
185 response = "ok" |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
186 elif decoded[1] == 'eval-result': |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
187 # Send back the last received eval result. |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
188 response = last_eval |
8009
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
189 elif decoded[1] == 'call me': |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
190 cmd = '[0,"we called you"]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
191 print("sending: {0}".format(cmd)) |
8009
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
192 self.request.sendall(cmd.encode('utf-8')) |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
193 response = "ok" |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
194 elif decoded[1] == 'call me again': |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
195 cmd = '[0,"we did call you"]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
196 print("sending: {0}".format(cmd)) |
8009
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
197 self.request.sendall(cmd.encode('utf-8')) |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
198 response = "" |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
199 elif decoded[1] == 'send zero': |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
200 cmd = '[0,"zero index"]' |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
201 print("sending: {0}".format(cmd)) |
8404
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
202 self.request.sendall(cmd.encode('utf-8')) |
8894d595b786
commit https://github.com/vim/vim/commit/5983ad0b038fa689653246cb304fd43e8ae39a78
Christian Brabandt <cb@256bit.org>
parents:
8382
diff
changeset
|
203 response = "sent zero" |
8210
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
204 elif decoded[1] == 'close me': |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
205 print("closing") |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
206 self.request.close() |
b717dae2f26d
commit https://github.com/vim/vim/commit/4e221c99e85ed40c98892068a01270b9e7492d98
Christian Brabandt <cb@256bit.org>
parents:
8159
diff
changeset
|
207 response = "" |
8159
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8153
diff
changeset
|
208 elif decoded[1] == 'wait a bit': |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8153
diff
changeset
|
209 time.sleep(0.2) |
d0958e22d9ff
commit https://github.com/vim/vim/commit/ece61b06ef4726515177c9b293e1c20d2122a73f
Christian Brabandt <cb@256bit.org>
parents:
8153
diff
changeset
|
210 response = "waited" |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
211 elif decoded[1] == '!quit!': |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
212 # we're done |
7920
1ebc7be4dbbf
commit https://github.com/vim/vim/commit/b3e2f00f39d6edafda6e5508a926ebd244997a0f
Christian Brabandt <cb@256bit.org>
parents:
7918
diff
changeset
|
213 self.server.shutdown() |
7993
0756eab66b71
commit https://github.com/vim/vim/commit/b92abad0c58de36d0b0afdcd4ec05261fa1fa84c
Christian Brabandt <cb@256bit.org>
parents:
7965
diff
changeset
|
214 return |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
215 elif decoded[1] == '!crash!': |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
216 # Crash! |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
217 42 / 0 |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
218 else: |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
219 response = "what?" |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
220 |
8009
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
221 if response == "": |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
222 print("no response") |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
223 else: |
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
224 encoded = json.dumps([decoded[0], response]) |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
225 print("sending: {0}".format(encoded)) |
8009
b2cfa3416ba0
commit https://github.com/vim/vim/commit/f6157284de71d8881f3b89fbd79d1ecbf842929f
Christian Brabandt <cb@256bit.org>
parents:
7993
diff
changeset
|
226 self.request.sendall(encoded.encode('utf-8')) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
227 |
7912
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
228 # Negative numbers are used for "eval" responses. |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
229 elif decoded[0] < 0: |
1c6ef9113556
commit https://github.com/vim/vim/commit/e7bed627c89ed80bc4b2d96f542819029adf6e76
Christian Brabandt <cb@256bit.org>
parents:
7906
diff
changeset
|
230 last_eval = decoded |
7906
ea1fd8d750a6
commit https://github.com/vim/vim/commit/fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383
Christian Brabandt <cb@256bit.org>
parents:
7902
diff
changeset
|
231 |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
232 class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer): |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
233 pass |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
234 |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
235 def writePortInFile(port): |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
236 # Write the port number in Xportnr, so that the test knows it. |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
237 f = open("Xportnr", "w") |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
238 f.write("{0}".format(port)) |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
239 f.close() |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
240 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
13351
diff
changeset
|
241 def main(host, port, server_class=ThreadedTCPServer): |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
242 # Wait half a second before opening the port to test waittime in ch_open(). |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
243 # We do want to get the port number, get that first. We cannot open the |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
244 # socket, guess a port is free. |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
245 if len(sys.argv) >= 2 and sys.argv[1] == 'delay': |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
13351
diff
changeset
|
246 port = 13684 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
13351
diff
changeset
|
247 writePortInFile(port) |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
248 |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
249 print("Wait for it...") |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
250 time.sleep(0.5) |
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
251 |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
13351
diff
changeset
|
252 server = server_class((host, port), ThreadedTCPRequestHandler) |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
13351
diff
changeset
|
253 ip, port = server.server_address[0:2] |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
254 |
7937
2e905dfc6999
commit https://github.com/vim/vim/commit/6076fe1986255d32b7a078a28bf9e7bea19d6f30
Christian Brabandt <cb@256bit.org>
parents:
7920
diff
changeset
|
255 # Start a thread with the server. That thread will then start a new thread |
2e905dfc6999
commit https://github.com/vim/vim/commit/6076fe1986255d32b7a078a28bf9e7bea19d6f30
Christian Brabandt <cb@256bit.org>
parents:
7920
diff
changeset
|
256 # for each connection. |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
257 server_thread = threading.Thread(target=server.serve_forever) |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
258 server_thread.start() |
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
259 |
8114
4aea0b0aa714
commit https://github.com/vim/vim/commit/81661fb86801e6d6e5194b43dfd27d73fcc016ec
Christian Brabandt <cb@256bit.org>
parents:
8041
diff
changeset
|
260 writePortInFile(port) |
7899
93c61501c2cf
commit https://github.com/vim/vim/commit/d7ece1008ee6173afda6d173bed486ae79c1c38a
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
261 |
8663
b2a48aabe21f
commit https://github.com/vim/vim/commit/a63cdb5ed685181c377ee89f1d1de6a97dfeb151
Christian Brabandt <cb@256bit.org>
parents:
8655
diff
changeset
|
262 print("Listening on port {0}".format(port)) |
7920
1ebc7be4dbbf
commit https://github.com/vim/vim/commit/b3e2f00f39d6edafda6e5508a926ebd244997a0f
Christian Brabandt <cb@256bit.org>
parents:
7918
diff
changeset
|
263 |
1ebc7be4dbbf
commit https://github.com/vim/vim/commit/b3e2f00f39d6edafda6e5508a926ebd244997a0f
Christian Brabandt <cb@256bit.org>
parents:
7918
diff
changeset
|
264 # Main thread terminates, but the server continues running |
1ebc7be4dbbf
commit https://github.com/vim/vim/commit/b3e2f00f39d6edafda6e5508a926ebd244997a0f
Christian Brabandt <cb@256bit.org>
parents:
7918
diff
changeset
|
265 # until server.shutdown() is called. |
8153
240deebfadde
commit https://github.com/vim/vim/commit/ddbe7d26b10c4374f406b807ae161826cf2096e1
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
266 try: |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
13351
diff
changeset
|
267 while server_thread.is_alive(): |
8153
240deebfadde
commit https://github.com/vim/vim/commit/ddbe7d26b10c4374f406b807ae161826cf2096e1
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
268 server_thread.join(1) |
240deebfadde
commit https://github.com/vim/vim/commit/ddbe7d26b10c4374f406b807ae161826cf2096e1
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
269 except (KeyboardInterrupt, SystemExit): |
240deebfadde
commit https://github.com/vim/vim/commit/ddbe7d26b10c4374f406b807ae161826cf2096e1
Christian Brabandt <cb@256bit.org>
parents:
8114
diff
changeset
|
270 server.shutdown() |
20003
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
13351
diff
changeset
|
271 |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
13351
diff
changeset
|
272 if __name__ == "__main__": |
e373843e2980
patch 8.2.0557: no IPv6 support for channels
Bram Moolenaar <Bram@vim.org>
parents:
13351
diff
changeset
|
273 main("localhost", 0) |