brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 79306a7 Raw
96 lines · plain
1# A smoke test to check that a simple dependency chain for modules can work.2#3# FIXME: The test fails on Windows; see comments on https://github.com/llvm/llvm-project/pull/1428284# UNSUPPORTED: system-windows5#6# RUN: rm -fr %t7# RUN: mkdir -p %t8# RUN: split-file %s %t9#10# RUN: sed -e "s|DIR|%/t|g" %t/compile_commands.json.tmpl > %t/compile_commands.json.tmp11# RUN: sed -e "s|CLANG_CC|%clang|g" %t/compile_commands.json.tmp > %t/compile_commands.json12# RUN: sed -e "s|DIR|%/t|g" %t/definition.jsonrpc.tmpl > %t/definition.jsonrpc.tmp13#14# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."15# (with the extra slash in the front), so we add it here.16# RUN: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' %/t/definition.jsonrpc.tmp > %/t/definition.jsonrpc17#18# RUN: clangd -experimental-modules-support -lit-test < %t/definition.jsonrpc \19# RUN:      | FileCheck -strict-whitespace %t/definition.jsonrpc20 21#--- A-frag.cppm22export module A:frag;23export void printA() {}24 25#--- A.cppm26export module A;27export import :frag;28 29#--- Use.cpp30import A;31void foo() {32    print33}34 35#--- compile_commands.json.tmpl36[37    {38      "directory": "DIR",39      "command": "CLANG_CC -fprebuilt-module-path=DIR -std=c++20 -o DIR/main.cpp.o -c DIR/Use.cpp",40      "file": "DIR/Use.cpp"41    },42    {43      "directory": "DIR",44      "command": "CLANG_CC -std=c++20 DIR/A.cppm --precompile -o DIR/A.pcm",45      "file": "DIR/A.cppm"46    },47    {48      "directory": "DIR",49      "command": "CLANG_CC -std=c++20 DIR/A-frag.cppm --precompile -o DIR/A-frag.pcm",50      "file": "DIR/A-frag.cppm"51    }52]53 54#--- definition.jsonrpc.tmpl55{56  "jsonrpc": "2.0",57  "id": 0,58  "method": "initialize",59  "params": {60    "processId": 123,61    "rootPath": "clangd",62    "capabilities": {63      "textDocument": {64        "completion": {65          "completionItem": {66            "snippetSupport": true67          }68        }69      }70    },71    "trace": "off"72  }73}74---75{76  "jsonrpc": "2.0",77  "method": "textDocument/didOpen",78  "params": {79    "textDocument": {80      "uri": "file://DIR/Use.cpp",81      "languageId": "cpp",82      "version": 1,83      "text": "import A;\nvoid foo() {\n    print\n}\n"84    }85  }86}87 88# CHECK: "message"{{.*}}printA{{.*}}(fix available)89 90---91{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file://DIR/Use.cpp"},"context":{"triggerKind":1},"position":{"line":2,"character":6}}}92---93{"jsonrpc":"2.0","id":2,"method":"shutdown"}94---95{"jsonrpc":"2.0","method":"exit"}96