1# We specify a custom path in XDG_CONFIG_HOME, which only works on some systems. 2# UNSUPPORTED: system-windows 3# UNSUPPORTED: system-darwin 4 5# RUN: rm -rf %t 6# RUN: mkdir -p %t/clangd 7 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 11 12# RUN: env XDG_CONFIG_HOME=%t clangd -lit-test -enable-config < %s | FileCheck -strict-whitespace %s 13 14{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} 15--- 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": [ 21# CHECK-NEXT: { 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 27# CHECK-NEXT: }, 28# CHECK-NEXT: "start": { 29# CHECK-NEXT: "character": 0, 30# CHECK-NEXT: "line": 0 31# CHECK-NEXT: } 32# CHECK-NEXT: }, 33# CHECK-NEXT: "severity": 2, 34# CHECK-NEXT: "source": "clangd-config" 35# CHECK-NEXT: } 36# CHECK-NEXT: ], 37# CHECK-NEXT: "uri": "file://{{.*}}/config.yaml" 38# CHECK-NEXT: } 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": [ 43# CHECK-NEXT: { 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 50# CHECK-NEXT: }, 51# CHECK-NEXT: "start": { 52# CHECK-NEXT: "character": 8, 53# CHECK-NEXT: "line": 0 54# CHECK-NEXT: } 55# CHECK-NEXT: }, 56# CHECK-NEXT: "severity": 1, 57# CHECK-NEXT: "source": "clang" 58# CHECK-NEXT: } 59# CHECK-NEXT: ], 60# CHECK-NEXT: "uri": "file://{{.*}}/foo.c", 61# CHECK-NEXT: "version": 0 62# CHECK-NEXT: } 63--- 64{"jsonrpc":"2.0","id":4,"method":"shutdown"} 65--- 66{"jsonrpc":"2.0","method":"exit"} 67