annotate src/testdir/test_netbeans.py @ 35162:860a5fb8eaf2 default tip

Added tag v9.1.0407 for changeset 08f7c9428f8224d6b24c60f4da1fd12c6354e852
author Christian Brabandt <cb@256bit.org>
date Sat, 11 May 2024 11:45:04 +0200
parents 8492bbc9f533
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
20087
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
13 import re
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 try:
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 # Python 3
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 import socketserver
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 except ImportError:
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 # Python 2
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 import SocketServer as socketserver
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
20087
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
24 def process_msgs(self, msgbuf):
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
25 # Process all the received netbeans commands/responses/events from Vim.
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
26 # Each one is separated by a newline character. If a partial command
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
27 # is received, process it later after the rest of it is received.
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
28 while True:
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
29 (line, sep, rest) = msgbuf.partition('\n')
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
30 if sep == '':
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
31 # received partial line
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
32 return line
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
33 msgbuf = rest
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
34
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
35 # Process a command only after receiving a newline.
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
36 response = ''
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
37 if line.find('Xcmdbuf') > 0:
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
38 name = line.split('"')[1]
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
39 response = '1:putBufferNumber!15 "' + name + '"\n'
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
40 response += '1:startDocumentListen!16\n'
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
41 elif re.match('1:insert=.* "\\\\n"', line):
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
42 # extract the command from the previous line
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
43 cmd = re.search('.*"(.*)"', self.prev_line).group(1)
22788
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
44
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
45 # map of test names and the netbeans commands/functions
20087
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
46 testmap = {
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
47 'getCursor_Test' : '0:getCursor/30\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
48 'E627_Test' : '0 setReadOnly!31\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
49 'E628_Test' : '0:setReadOnly 32\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
50 'E632_Test' : '0:getLength/33\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
51 'E633_Test' : '0:getText/34\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
52 'E634_Test' : '0:remove/35 1 1\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
53 'E635_Test' : '0:insert/36 0 "line1\\n"\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
54 'E636_Test' : '0:create!37\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
55 'E637_Test' : '0:startDocumentListen!38\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
56 'E638_Test' : '0:stopDocumentListen!39\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
57 'E639_Test' : '0:setTitle!40 "Title"\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
58 'E640_Test' : '0:initDone!41\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
59 'E641_Test' : '0:putBufferNumber!42 "XSomeBuf"\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
60 'E642_Test' : '9:putBufferNumber!43 "XInvalidBuf"\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
61 'E643_Test' : '0:setFullName!44 "XSomeBuf"\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
62 'E644_Test' : '0:editFile!45 "Xfile3"\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
63 'E645_Test' : '0:setVisible!46 T\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
64 'E646_Test' : '0:setModified!47 T\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
65 'E647_Test' : '0:setDot!48 1/1\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
66 'E648_Test' : '0:close!49\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
67 'E650_Test' : '0:defineAnnoType!50 1 "abc" "a" "a" 1 1\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
68 'E651_Test' : '0:addAnno!51 1 1 1 1\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
69 'E652_Test' : '0:getAnno/52 8\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
70 'editFile_Test' : '2:editFile!53 "Xfile3"\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
71 'getLength_Test' : '2:getLength/54\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
72 'getModified_Test' : '2:getModified/55\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
73 'getText_Test' : '2:getText/56\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
74 'setDot_Test' : '2:setDot!57 3/6\n',
22788
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
75 'setDot2_Test' : '2:setDot!57 9\n',
20087
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
76 'startDocumentListen_Test' : '2:startDocumentListen!58\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
77 'stopDocumentListen_Test' : '2:stopDocumentListen!59\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
78 'define_anno_Test' : '2:defineAnnoType!60 1 "s1" "x" "=>" blue none\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
79 'E532_Test' : '2:defineAnnoType!61 1 "s1" "x" "=>" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa none\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
80 'add_anno_Test' : '2:addAnno!62 1 1 2/1 0\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
81 'get_anno_Test' : '2:getAnno/63 1\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
82 'remove_anno_Test' : '2:removeAnno!64 1\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
83 'getModifiedAll_Test' : '0:getModified/65\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
84 'create_Test' : '3:create!66\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
85 'setTitle_Test' : '3:setTitle!67 "Xfile4"\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
86 'setFullName_Test' : '3:setFullName!68 "Xfile4"\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
87 'initDone_Test' : '3:initDone!69\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
88 'setVisible_Test' : '3:setVisible!70 T\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
89 'setModtime_Test' : '3:setModtime!71 6\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
90 'insert_Test' : '3:insert/72 0 "line1\\nline2\\n"\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
91 'remove_Test' : '3:remove/73 3 4\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
92 'remove_invalid_offset_Test' : '3:remove/74 900 4\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
93 'remove_invalid_count_Test' : '3:remove/75 1 800\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
94 'guard_Test' : '3:guard!76 8 7\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
95 'setModified_Test' : '3:setModified!77 T\n',
22788
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
96 'setModifiedClear_Test' : '3:setModified!77 F\n',
20087
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
97 'insertDone_Test' : '3:insertDone!78 T F\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
98 'saveDone_Test' : '3:saveDone!79\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
99 'invalidcmd_Test' : '3:invalidcmd!80\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
100 'invalidfunc_Test' : '3:invalidfunc/81\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
101 'removeAnno_fail_Test' : '0:removeAnno/82 1\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
102 'guard_fail_Test' : '0:guard/83 1 1\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
103 'save_fail_Test' : '0:save/84\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
104 'netbeansBuffer_fail_Test' : '0:netbeansBuffer/85 T\n',
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
105 'setExitDelay_Test' : '0:setExitDelay!86 2\n',
22788
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
106 'setReadOnly_Test' : '3:setReadOnly!87 T\n',
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
107 'setReadOnlyClear_Test' : '3:setReadOnly!88 F\n',
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
108 'save_Test' : '3:save!89\n',
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
109 'close_Test' : '3:close!90\n',
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
110 'specialKeys_Test' : '0:specialKeys!91 "F12 F13 C-F13"\n',
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
111 'nbbufwrite_Test' : '4:editFile!92 "XnbBuffer"\n4:netbeansBuffer!93 T\n',
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
112 'startAtomic_Test' : '0:startAtomic!94\n',
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
113 'endAtomic_Test' : '0:endAtomic!95\n',
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
114 'AnnoScale_Test' : "".join(['2:defineAnnoType!60 ' + str(i) + ' "s' + str(i) + '" "x" "=>" blue none\n' for i in range(2, 26)]),
c8a4ad051d23 patch 8.2.1942: insufficient test coverage for the Netbeans interface
Bram Moolenaar <Bram@vim.org>
parents: 20625
diff changeset
115 'detach_Test' : '2:close!96\n1:close!97\nDETACH\n'
20087
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
116 }
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
117 # execute the specified test
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
118 if cmd not in testmap:
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
119 print("=== invalid command %s ===" % (cmd))
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
120 else:
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
121 response = testmap[cmd]
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
122 elif line.find('disconnect') > 0:
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
123 # we're done
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
124 self.server.shutdown()
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
125 return
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
126
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
127 # save the current line, this is used as the test to run after
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
128 # receiving a newline only line.
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
129 self.prev_line = line
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
130
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
131 if len(response) > 0:
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
132 self.request.sendall(response.encode('utf-8'))
20625
116c7bd5e980 patch 8.2.0866: not enough tests for buffer writing
Bram Moolenaar <Bram@vim.org>
parents: 20087
diff changeset
133 # Write the response into the file, so that the test can knows
20087
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
134 # the command was sent.
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
135 with open("Xnetbeans", "a") as myfile:
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
136 myfile.write('send: ' + response)
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
137 if self.debug:
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
138 with open("save_Xnetbeans", "a") as myfile:
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
139 myfile.write('send: ' + response)
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
140
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 def handle(self):
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 print("=== socket opened ===")
20087
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
143 # To preserve the Xnetbeans file as save_Xnetbeans, set debug to 1
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
144 self.debug = 0
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
145 self.prev_line = ''
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
146 msgbuf = ''
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 while True:
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 try:
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 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
150 except socket.error:
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 print("=== socket error ===")
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 break
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 except IOError:
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 print("=== socket closed ===")
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 break
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 if received == '':
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 print("=== socket closed ===")
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 break
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 print("received: {0}".format(received))
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 # 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
162 # what happened.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163 with open("Xnetbeans", "a") as myfile:
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 myfile.write(received)
20087
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
165 if self.debug:
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
166 with open("save_Xnetbeans", "a") as myfile:
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
167 myfile.write(received)
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168
20087
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
169 # Can receive more than one line in a response or a partial line.
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
170 # Accumulate all the received characters and process one line at
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
171 # a time.
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
172 msgbuf += received
b378f860d4ab patch 8.2.0599: Netbeans interface insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 15077
diff changeset
173 msgbuf = self.process_msgs(msgbuf)
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 pass
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 def writePortInFile(port):
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 # 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
180 f = open("Xportnr", "w")
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 f.write("{0}".format(port))
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 f.close()
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 if __name__ == "__main__":
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 HOST, PORT = "localhost", 0
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186
31665
8492bbc9f533 patch 9.0.1165: tests using IPv6 sometimes fail
Bram Moolenaar <Bram@vim.org>
parents: 22788
diff changeset
187 addrs = socket.getaddrinfo(HOST, PORT, 0, 0, socket.IPPROTO_TCP)
8492bbc9f533 patch 9.0.1165: tests using IPv6 sometimes fail
Bram Moolenaar <Bram@vim.org>
parents: 22788
diff changeset
188 # Each addr is a (family, type, proto, canonname, sockaddr) tuple
8492bbc9f533 patch 9.0.1165: tests using IPv6 sometimes fail
Bram Moolenaar <Bram@vim.org>
parents: 22788
diff changeset
189 sockaddr = addrs[0][4]
8492bbc9f533 patch 9.0.1165: tests using IPv6 sometimes fail
Bram Moolenaar <Bram@vim.org>
parents: 22788
diff changeset
190 ThreadedTCPServer.address_family = addrs[0][0]
8492bbc9f533 patch 9.0.1165: tests using IPv6 sometimes fail
Bram Moolenaar <Bram@vim.org>
parents: 22788
diff changeset
191
8492bbc9f533 patch 9.0.1165: tests using IPv6 sometimes fail
Bram Moolenaar <Bram@vim.org>
parents: 22788
diff changeset
192 server = ThreadedTCPServer(sockaddr[0:2], ThreadedTCPRequestHandler)
8492bbc9f533 patch 9.0.1165: tests using IPv6 sometimes fail
Bram Moolenaar <Bram@vim.org>
parents: 22788
diff changeset
193 ip, port = server.server_address[0:2]
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 # 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
196 # for each connection.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 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
198 server_thread.start()
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
199
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200 writePortInFile(port)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202 print("Listening on port {0}".format(port))
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204 # 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
205 # until server.shutdown() is called.
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206 try:
31665
8492bbc9f533 patch 9.0.1165: tests using IPv6 sometimes fail
Bram Moolenaar <Bram@vim.org>
parents: 22788
diff changeset
207 while server_thread.is_alive():
9517
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 server_thread.join(1)
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 except (KeyboardInterrupt, SystemExit):
9f8f03a44886 commit https://github.com/vim/vim/commit/321efdd77a7b9ac11ade90dd7634b5d37f4820fe
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 server.shutdown()