From 1b55b27aeee4881c2192e92eb8719e813b4ad3ce Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 10 Mar 2020 15:52:46 +0100 Subject: [PATCH] clangd with a cmake test --- debian/qualify-clang.sh | 48 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/debian/qualify-clang.sh b/debian/qualify-clang.sh index 0133379c..04b6e0a9 100755 --- a/debian/qualify-clang.sh +++ b/debian/qualify-clang.sh @@ -118,6 +118,48 @@ if ! grep -q '"insertText": "func_with_args(${1:int a}, ${2:int b})",' foo.log; exit 1 fi +echo 'namespace mozilla { +namespace dom { +void foo(); + +int fonction_avec_args(int a, float b); +int main() { +fonction_avec_args +} + +} +} +' > foo.cpp +content=$(sed ':a;N;$!ba;s/\n/\\n/g' foo.cpp) +echo '{ + "jsonrpc": "2.0", + "id": 0, + "method": "initialize", + "params": { + "processId": 123, + "rootPath": "clangd-10", + "capabilities": { + "textDocument": { + "completion": { + "completionItem": { + "snippetSupport": true + } + } + } + }, + "trace": "off" + } +} +--- +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///'$(pwd)'/cmaketest/foo.cpp","languageId":"cpp","version":1,"text":"'$content'"}}} +--- +{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///'$(pwd)'/cmaketest/foo.cpp"},"position":{"line":6,"character":18}}} +--- +{"jsonrpc":"2.0","id":4,"method":"shutdown"} +--- +{"jsonrpc":"2.0","method":"exit"} +' > a.json + rm -rf cmaketest && mkdir cmaketest cat > cmaketest/CMakeLists.txt < /dev/null # TODO this test is useless as it doesn't leverage foo.cpp or the compiledb clangd-$VERSION -lit-test -pch-storage=memory < a.json &> foo.log -if ! grep -q '"insertText": "func_with_args(${1:int a}, ${2:int b})",' foo.log; then +if ! grep -q '"insertText": "fonction_avec_args(${1:int a}, ${2:float b})",' foo.log; then echo "clangd didn't export what we were expecting" cat foo.log exit 1 @@ -143,10 +185,6 @@ cd - rm -rf cmaketest - - - - echo "Testing clang-$VERSION ..." rm -f foo.log