1 # RUN: not clangd -pretty -sync -enable-test-uri-scheme < %s | FileCheck -strict-whitespace %s
\r
2 # RUN: not clangd -pretty -sync -enable-test-uri-scheme < %s 2>&1 | FileCheck -check-prefix=STDERR %s
\r
3 # vim: fileformat=dos
\r
4 # It is absolutely vital that this file has CRLF line endings.
\r
6 # Note that we invert the test because we intent to let clangd exit prematurely.
\r
8 # Test protocol parsing
\r
10 Content-Type: application/vscode-jsonrpc; charset-utf-8
\r
12 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
\r
13 # Test message with Content-Type after Content-Length
\r
15 # CHECK: "jsonrpc": "2.0",
\r
16 # CHECK-NEXT: "result": {
\r
20 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"struct fake { int a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n fake f;\n f.\n}\n"}}}
\r
24 {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp"}}}
\r
26 Content-Type: application/vscode-jsonrpc; charset-utf-8
\r
29 {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}}
\r
30 # Test message with Content-Type before Content-Length
\r
33 # CHECK-NEXT: "jsonrpc": "2.0",
\r
34 # CHECK-NEXT: "result": {
\r
35 # CHECK-NEXT: "isIncomplete": false,
\r
36 # CHECK-NEXT: "items": [
\r
37 # CHECK: "filterText": "a",
\r
38 # CHECK-NEXT: "insertText": "a",
\r
39 # CHECK-NEXT: "insertTextFormat": 1,
\r
40 # CHECK-NEXT: "kind": 5,
\r
41 # CHECK-NEXT: "label": " a",
\r
42 # CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
\r
43 # CHECK-NEXT: "sortText": "{{.*}}"
\r
48 Content-Type: application/vscode-jsonrpc; charset-utf-8
\r
50 Content-Type: application/vscode-jsonrpc; charset-utf-8
\r
53 {"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}}
\r
55 Content-Type: application/vscode-jsonrpc; charset-utf-8
\r
59 {"jsonrpc":"2.0","id":3,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}}
\r
60 # Test message with duplicate Content-Length headers
\r
63 # CHECK-NEXT: "jsonrpc": "2.0",
\r
64 # CHECK-NEXT: "result": {
\r
65 # CHECK-NEXT: "isIncomplete": false,
\r
66 # CHECK-NEXT: "items": [
\r
67 # CHECK: "filterText": "a",
\r
68 # CHECK-NEXT: "insertText": "a",
\r
69 # CHECK-NEXT: "insertTextFormat": 1,
\r
70 # CHECK-NEXT: "kind": 5,
\r
71 # CHECK-NEXT: "label": " a",
\r
72 # CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
\r
73 # CHECK-NEXT: "sortText": "{{.*}}"
\r
76 # STDERR: Warning: Duplicate Content-Length header received. The previous value for this message (10) was ignored.
\r
78 Content-Type: application/vscode-jsonrpc; charset-utf-8
\r
81 {"jsonrpc":"2.0","id":4,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}}
\r
82 # Test message with malformed Content-Length
\r
84 # STDERR: JSON parse error
\r
85 # Ensure we recover by sending another (valid) message
\r
89 {"jsonrpc":"2.0","id":5,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}}
\r
90 # Test message with Content-Type before Content-Length
\r
93 # CHECK-NEXT: "jsonrpc": "2.0",
\r
94 # CHECK-NEXT: "result": {
\r
95 # CHECK-NEXT: "isIncomplete": false,
\r
96 # CHECK-NEXT: "items": [
\r
97 # CHECK: "filterText": "a",
\r
98 # CHECK-NEXT: "insertText": "a",
\r
99 # CHECK-NEXT: "insertTextFormat": 1,
\r
100 # CHECK-NEXT: "kind": 5,
\r
101 # CHECK-NEXT: "label": " a",
\r
102 # CHECK-NEXT: "score": {{[0-9]+.[0-9]+}},
\r
103 # CHECK-NEXT: "sortText": "{{.*}}"
\r
106 Content-Length: 1024
\r
108 {"jsonrpc":"2.0","id":5,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}}
\r
109 # Test message which reads beyond the end of the stream.
\r
111 # Ensure this is the last test in the file!
\r
112 # STDERR: Input was aborted. Read only {{[0-9]+}} bytes of expected {{[0-9]+}}.
\r