Mercurial > vim
annotate src/testdir/test_netbeans.py @ 17684:e2bfdd281578 v8.1.1839
patch 8.1.1839: insufficient info when test fails because of screen size
commit https://github.com/vim/vim/commit/0b5dc644465c549ac54fe3c4ad232dd692000d26
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 11 22:56:15 2019 +0200
patch 8.1.1839: insufficient info when test fails because of screen size
Problem: Insufficient info when test fails because of screen size.
Solution: Report the detected screen size.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 11 Aug 2019 23:00:09 +0200 |
parents | cd6daebf47ae |
children | b378f860d4ab |
rev | line source |
---|---|
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 # |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 # Server that will communicate with Vim through the netbeans interface. |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 # Used by test_netbeans.vim. |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 # |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 # This requires Python 2.6 or later. |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 from __future__ import print_function |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 import socket |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 import sys |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 import time |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 import threading |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 try: |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 # Python 3 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 import socketserver |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 except ImportError: |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 # Python 2 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 import SocketServer as socketserver |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler): |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 def handle(self): |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 print("=== socket opened ===") |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 while True: |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 try: |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 received = self.request.recv(4096).decode('utf-8') |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 except socket.error: |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 print("=== socket error ===") |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 break |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 except IOError: |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 print("=== socket closed ===") |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 break |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 if received == '': |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 print("=== socket closed ===") |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 break |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 print("received: {0}".format(received)) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 # Write the received line into the file, so that the test can check |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 # what happened. |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 with open("Xnetbeans", "a") as myfile: |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 myfile.write(received) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 response = '' |
15077
cd6daebf47ae
patch 8.1.0549: netbeans test depends on README.txt contents
Bram Moolenaar <Bram@vim.org>
parents:
10209
diff
changeset
|
45 if received.find('XREADME.txt') > 0: |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 name = received.split('"')[1] |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 response = '5:putBufferNumber!33 "' + name + '"\n' |
10162
663ef672c4b9
commit https://github.com/vim/vim/commit/ff330ff2c4500dc5535631418d601194654e4536
Christian Brabandt <cb@256bit.org>
parents:
9517
diff
changeset
|
48 response += '5:setDot!1 3/19\n' |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 elif received.find('disconnect') > 0: |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 # we're done |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 self.server.shutdown() |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 return |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 if len(response) > 0: |
10209
3bb89aba6064
commit https://github.com/vim/vim/commit/3c4ebeba17399e4ef33d004c269e667f696f0eb6
Christian Brabandt <cb@256bit.org>
parents:
10162
diff
changeset
|
55 self.request.sendall(response.encode('utf-8')) |
9517
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 # Write the respoinse into the file, so that the test can knows |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 # the command was sent. |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 with open("Xnetbeans", "a") as myfile: |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 myfile.write('send: ' + response) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer): |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 pass |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 def writePortInFile(port): |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 # Write the port number in Xportnr, so that the test knows it. |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 f = open("Xportnr", "w") |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 f.write("{0}".format(port)) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 f.close() |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 if __name__ == "__main__": |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 HOST, PORT = "localhost", 0 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 server = ThreadedTCPServer((HOST, PORT), ThreadedTCPRequestHandler) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 ip, port = server.server_address |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 # Start a thread with the server. That thread will then start a new thread |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 # for each connection. |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 server_thread = threading.Thread(target=server.serve_forever) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 server_thread.start() |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 writePortInFile(port) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 print("Listening on port {0}".format(port)) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 # Main thread terminates, but the server continues running |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 # until server.shutdown() is called. |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 try: |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 while server_thread.isAlive(): |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 server_thread.join(1) |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 except (KeyboardInterrupt, SystemExit): |
9f8f03a44886
commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 server.shutdown() |