1 # We specify a custom path in XDG_CONFIG_HOME, which only works on some systems.
2 # UNSUPPORTED: system-windows
3 # UNSUPPORTED: system-darwin
6 # RUN: mkdir -p %t/clangd
8 # Create a config file that injects a flag we can observe, and has an error.
9 # RUN: echo 'Foo: bar' > %t/clangd/config.yaml
10 # RUN: echo 'CompileFlags: {Add: -DFOO=BAR}' >> %t/clangd/config.yaml
12 # RUN: env XDG_CONFIG_HOME=%t clangd -lit-test -enable-config < %s | FileCheck -strict-whitespace %s
14 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
16 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","text":"int x = FOO;"}}}
17 # First, the errors from the config file.
18 # CHECK: "method": "textDocument/publishDiagnostics",
19 # CHECK-NEXT: "params": {
20 # CHECK-NEXT: "diagnostics": [
22 # CHECK-NEXT: "message": "Unknown Config key 'Foo'",
23 # CHECK-NEXT: "range": {
24 # CHECK-NEXT: "end": {
25 # CHECK-NEXT: "character": 3,
26 # CHECK-NEXT: "line": 0
28 # CHECK-NEXT: "start": {
29 # CHECK-NEXT: "character": 0,
30 # CHECK-NEXT: "line": 0
33 # CHECK-NEXT: "severity": 2,
34 # CHECK-NEXT: "source": "clangd-config"
37 # CHECK-NEXT: "uri": "file://{{.*}}/config.yaml"
39 # Next, the error from the main file. BAR rather than FOO means we used config.
40 # CHECK: "method": "textDocument/publishDiagnostics",
41 # CHECK-NEXT: "params": {
42 # CHECK-NEXT: "diagnostics": [
44 # CHECK-NEXT: "code": "undeclared_var_use",
45 # CHECK-NEXT: "message": "Use of undeclared identifier 'BAR'",
46 # CHECK-NEXT: "range": {
47 # CHECK-NEXT: "end": {
48 # CHECK-NEXT: "character": 11,
49 # CHECK-NEXT: "line": 0
51 # CHECK-NEXT: "start": {
52 # CHECK-NEXT: "character": 8,
53 # CHECK-NEXT: "line": 0
56 # CHECK-NEXT: "severity": 1,
57 # CHECK-NEXT: "source": "clang"
60 # CHECK-NEXT: "uri": "file://{{.*}}/foo.c",
61 # CHECK-NEXT: "version": 0
64 {"jsonrpc":"2.0","id":4,"method":"shutdown"}
66 {"jsonrpc":"2.0","method":"exit"}