File: system-include-extractor.test

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,388 kB
  • sloc: cpp: 4,167,636; ansic: 714,256; asm: 457,610; python: 155,927; objc: 65,094; sh: 42,856; lisp: 26,908; perl: 7,786; pascal: 7,722; makefile: 6,881; ml: 5,581; awk: 3,648; cs: 2,027; xml: 888; javascript: 381; ruby: 156
file content (51 lines) | stat: -rw-r--r-- 2,071 bytes parent folder | download | duplicates (2)
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
# RUN: rm -rf %t.dir && mkdir -p %t.dir

# 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 "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"}