system-include-extractor.test
2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# RUN: rm -rf %t.dir && mkdir -p %t.dir
# The mock driver below is a shell script:
# REQUIRES: shell
# Generate a mock-driver that will print %temp_dir%/my/dir and
# %temp_dir%/my/dir2 as include search paths.
# RUN: echo '#!/bin/bash' >> %t.dir/my_driver.sh
# RUN: echo '[ "$0" = "%t.dir/my_driver.sh" ] || exit' >> %t.dir/my_driver.sh
# RUN: echo 'echo line to ignore >&2' >> %t.dir/my_driver.sh
# RUN: echo 'echo -e "#include <...> search starts here:\r" >&2' >> %t.dir/my_driver.sh
# RUN: echo 'echo %t.dir/my/dir/ >&2' >> %t.dir/my_driver.sh
# RUN: echo 'echo %t.dir/my/dir2/ >&2' >> %t.dir/my_driver.sh
# RUN: echo 'echo -e "End of search list.\r" >&2' >> %t.dir/my_driver.sh
# RUN: chmod +x %t.dir/my_driver.sh
# Create header files my/dir/a.h and my/dir2/b.h
# RUN: mkdir -p %t.dir/my/dir
# RUN: touch %t.dir/my/dir/a.h
# RUN: mkdir -p %t.dir/my/dir2
# RUN: touch %t.dir/my/dir2/b.h
# Generate a compile_commands.json that will query the mock driver we've
# created. Which should add a.h and b.h into include search path.
# RUN: echo '[{"directory": "%/t.dir", "command": "%/t.dir/my_driver.sh the-file.cpp", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
# RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1
# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
# (with the extra slash in the front), so we add it here.
# RUN: sed -E -e "s|file://([A-Z]):/|file:///\1:/|g" %t.test.1 > %t.test
# Bless the mock driver we've just created so that clangd can execute it.
# RUN: clangd -lit-test -query-driver="**.test,**.sh" < %t.test | FileCheck -strict-whitespace %t.test
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{}}
---
{
"jsonrpc":"2.0",
"method":"textDocument/didOpen",
"params": {
"textDocument": {
"uri": "file://INPUT_DIR/the-file.cpp",
"languageId":"cpp",
"version":1,
"text":"#include <a.h>\n#include <b.h>"
}
}
}
# CHECK: "method": "textDocument/publishDiagnostics",
# CHECK-NEXT: "params": {
# CHECK-NEXT: "diagnostics": [],
---
{"jsonrpc":"2.0","id":10000,"method":"shutdown"}
---
{"jsonrpc":"2.0","method":"exit"}