[clang-tools-extra] r294294 - [clangd] Harden test against sed implementations that strip \r.
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 7 03:49:04 PST 2017
Author: d0k
Date: Tue Feb 7 05:49:03 2017
New Revision: 294294
URL: http://llvm.org/viewvc/llvm-project?rev=294294&view=rev
Log:
[clangd] Harden test against sed implementations that strip \r.
Also clean up logging and don't print \0.
Modified:
clang-tools-extra/trunk/clangd/ClangDMain.cpp
clang-tools-extra/trunk/test/clangd/formatting.test
Modified: clang-tools-extra/trunk/clangd/ClangDMain.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangDMain.cpp?rev=294294&r1=294293&r2=294294&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangDMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangDMain.cpp Tue Feb 7 05:49:03 2017
@@ -68,18 +68,17 @@ int main(int argc, char *argv[]) {
// Now read the JSON. Insert a trailing null byte as required by the YAML
// parser.
- std::vector<char> JSON(Len + 1);
+ std::vector<char> JSON(Len + 1, '\0');
std::cin.read(JSON.data(), Len);
if (Len > 0) {
+ llvm::StringRef JSONRef(JSON.data(), Len);
// Log the message.
- Logs << "<-- ";
- Logs.write(JSON.data(), JSON.size());
- Logs << '\n';
+ Logs << "<-- " << JSONRef << '\n';
Logs.flush();
// Finally, execute the action for this JSON message.
- if (!Dispatcher.call(llvm::StringRef(JSON.data(), JSON.size() - 1)))
+ if (!Dispatcher.call(JSONRef))
Logs << "JSON dispatch failed!\n";
}
}
Modified: clang-tools-extra/trunk/test/clangd/formatting.test
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/formatting.test?rev=294294&r1=294293&r2=294294&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clangd/formatting.test (original)
+++ clang-tools-extra/trunk/test/clangd/formatting.test Tue Feb 7 05:49:03 2017
@@ -1,5 +1,4 @@
-# RUN: sed -e '/^#/d' %s | clangd | FileCheck %s
-# It is absolutely vital that this file has CRLF line endings.
+# RUN: sed -e '/^#/d' -e 's/\r*$/\r/' %s | clangd | FileCheck %s
#
Content-Length: 125
More information about the cfe-commits
mailing list