From 1bc528cd9a7a96f6c99c2c71d54ea66ac5d14ef2 Mon Sep 17 00:00:00 2001 From: Jan Korous Date: Mon, 23 Apr 2018 15:58:42 +0000 Subject: [PATCH] [clangd][tests] Fix delimiter handling Empty line shouldn't be considered a delimiter Differential Revision: https://reviews.llvm.org/D45764 llvm-svn: 330609 --- clang-tools-extra/clangd/JSONRPCDispatcher.cpp | 2 +- .../test/clangd/spaces-in-delimited-input.test | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 clang-tools-extra/test/clangd/spaces-in-delimited-input.test diff --git a/clang-tools-extra/clangd/JSONRPCDispatcher.cpp b/clang-tools-extra/clangd/JSONRPCDispatcher.cpp index 1e0f5bce7387..e86b09da4636 100644 --- a/clang-tools-extra/clangd/JSONRPCDispatcher.cpp +++ b/clang-tools-extra/clangd/JSONRPCDispatcher.cpp @@ -278,7 +278,7 @@ static llvm::Optional readDelimitedMessage(std::istream &In, continue; // found a delimiter - if (LineRef.find_first_not_of('-') == llvm::StringRef::npos) + if (LineRef.rtrim() == "---") break; JSON += Line; diff --git a/clang-tools-extra/test/clangd/spaces-in-delimited-input.test b/clang-tools-extra/test/clangd/spaces-in-delimited-input.test new file mode 100644 index 000000000000..63e3e0b6f772 --- /dev/null +++ b/clang-tools-extra/test/clangd/spaces-in-delimited-input.test @@ -0,0 +1,13 @@ +# RUN: clangd -input-style=delimited -run-synchronously < %s 2>&1 | FileCheck %s +# RUN: clangd -lit-test -run-synchronously < %s 2>&1 | FileCheck %s +# +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} + +--- + +{"jsonrpc":"2.0","id":3,"method":"shutdown"} + +--- + +{"jsonrpc":"2.0","id":3,"method":"exit"} +# CHECK-NOT: JSON parse error