summaryrefslogtreecommitdiff
path: root/src/testdir/test_channel.py
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-02-03 21:32:46 +0100
committerBram Moolenaar <Bram@vim.org>2016-02-03 21:32:46 +0100
commitfcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383 (patch)
tree59135ca051bf4f7f2fb68792651e6421cafd5e5f /src/testdir/test_channel.py
parentf92591f7f9fc78d2aced99befe444cb423b26df8 (diff)
downloadvim-git-fcb1e3d16832ce06da0dc38ecb7ab9aaa3ee4383.tar.gz
patch 7.4.1249v7.4.1249
Problem: Crash when the process a channel is connected to exits. Solution: Use the file descriptor properly. Add a test. (Damien) Also add a test for eval().
Diffstat (limited to 'src/testdir/test_channel.py')
-rw-r--r--src/testdir/test_channel.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/testdir/test_channel.py b/src/testdir/test_channel.py
index 236449483..64546c020 100644
--- a/src/testdir/test_channel.py
+++ b/src/testdir/test_channel.py
@@ -52,7 +52,6 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
decoded = [-1, '']
# Send a response if the sequence number is positive.
- # Negative numbers are used for "eval" responses.
if decoded[0] >= 0:
if decoded[1] == 'hello!':
# simply send back a string
@@ -65,9 +64,27 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
print("sending: {}".format(cmd))
thesocket.sendall(cmd.encode('utf-8'))
response = "ok"
+ elif decoded[1] == 'eval-works':
+ # Send an eval request. We ignore the response.
+ cmd = '["eval","\\"foo\\" . 123", -1]'
+ print("sending: {}".format(cmd))
+ thesocket.sendall(cmd.encode('utf-8'))
+ response = "ok"
+ elif decoded[1] == 'eval-fails':
+ # Send an eval request that will fail.
+ cmd = '["eval","xxx", -2]'
+ print("sending: {}".format(cmd))
+ thesocket.sendall(cmd.encode('utf-8'))
+ response = "ok"
+ elif decoded[1] == 'eval-result':
+ # Send back the last received eval result.
+ response = last_eval
elif decoded[1] == '!quit!':
# we're done
sys.exit(0)
+ elif decoded[1] == '!crash!':
+ # Crash!
+ 42 / 0
else:
response = "what?"
@@ -75,6 +92,10 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
print("sending: {}".format(encoded))
thesocket.sendall(encoded.encode('utf-8'))
+ # Negative numbers are used for "eval" responses.
+ elif decoded[0] < 0:
+ last_eval = decoded
+
thesocket = None
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):