Mercurial > vim
annotate src/testdir/test_channel_unix.py @ 34148:8687845c326c v9.1.0035
patch 9.1.0035: i_CTRL-] triggers InsertCharPre
Commit: https://github.com/vim/vim/commit/7d711fe2092d0438d2df5054df735ec34926e2bc
Author: altermo <>
Date: Tue Jan 16 17:25:17 2024 +0100
patch 9.1.0035: i_CTRL-] triggers InsertCharPre
Problem: i_CTRL-] triggers InsertCharPre
Solution: Return if CTRL-] is received. InsertCharPre
is supposed to be only used for chars to be inserted
but i_CTRL-] triggers expansion and is not inserted
into the buffer (altermo)
closes: #13853
closes: #13864
Signed-off-by: altermo
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 16 Jan 2024 17:30:11 +0100 |
parents | cdd13ed3e5cb |
children |
rev | line source |
---|---|
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 # |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 # Server that will accept connections from a Vim channel. |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 # Used by test_channel.vim. |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 # |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 # This requires Python 2.6 or later. |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 from __future__ import print_function |
28329
cdd13ed3e5cb
patch 8.2.4690: channel tests fail on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
9 from test_channel import ThreadedTCPServer, TestingRequestHandler, \ |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 writePortInFile |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 import socket |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 import threading |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 import os |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 try: |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 FileNotFoundError |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 except NameError: |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 # Python 2 |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 FileNotFoundError = (IOError, OSError) |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 |
28329
cdd13ed3e5cb
patch 8.2.4690: channel tests fail on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
21 if not hasattr(socket, "AF_UNIX"): |
cdd13ed3e5cb
patch 8.2.4690: channel tests fail on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
22 raise NotImplementedError("Unix sockets are not supported on this platform") |
cdd13ed3e5cb
patch 8.2.4690: channel tests fail on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
23 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 class ThreadedUnixServer(ThreadedTCPServer): |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 address_family = socket.AF_UNIX |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 |
28329
cdd13ed3e5cb
patch 8.2.4690: channel tests fail on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
27 class ThreadedUnixRequestHandler(TestingRequestHandler): |
cdd13ed3e5cb
patch 8.2.4690: channel tests fail on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
28 pass |
cdd13ed3e5cb
patch 8.2.4690: channel tests fail on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
29 |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 def main(path): |
28329
cdd13ed3e5cb
patch 8.2.4690: channel tests fail on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
28317
diff
changeset
|
31 server = ThreadedUnixServer(path, ThreadedUnixRequestHandler) |
28317
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 # Start a thread with the server. That thread will then start a new thread |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 # for each connection. |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 server_thread = threading.Thread(target=server.serve_forever) |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 server_thread.start() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 # Signal the test harness we're ready, the port value has no meaning. |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 writePortInFile(1234) |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 print("Listening on {0}".format(server.server_address)) |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 # Main thread terminates, but the server continues running |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 # until server.shutdown() is called. |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 try: |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 while server_thread.is_alive(): |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 server_thread.join(1) |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 except (KeyboardInterrupt, SystemExit): |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 server.shutdown() |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 if __name__ == "__main__": |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 try: |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 os.remove("Xtestsocket") |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 except FileNotFoundError: |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 pass |
d32dc906dd2c
patch 8.2.4684: cannot open a channel on a Unix domain socket
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 main("Xtestsocket") |