diff --git a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp --- a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp +++ b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp @@ -8,19 +8,38 @@ #include "Annotations.h" #include "ClangdLSPServer.h" +#include "ClangdServer.h" +#include "ConfigProvider.h" +#include "Diagnostics.h" +#include "FeatureModule.h" +#include "LSPBinder.h" #include "LSPClient.h" -#include "Protocol.h" #include "TestFS.h" +#include "support/Function.h" #include "support/Logger.h" #include "support/TestTracer.h" +#include "support/Threading.h" +#include "clang/Basic/Diagnostic.h" +#include "clang/Basic/LLVM.h" +#include "llvm/ADT/FunctionExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" +#include "llvm/Support/FormatVariadic.h" #include "llvm/Support/JSON.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Testing/Support/Error.h" #include "llvm/Testing/Support/SupportHelpers.h" #include "gmock/gmock.h" #include "gtest/gtest.h" +#include +#include +#include +#include +#include +#include #include +#include +#include namespace clang { namespace clangd { @@ -358,7 +377,7 @@ Client.notify("increment", nullptr); Client.notify("increment", nullptr); Client.notify("increment", nullptr); - EXPECT_THAT_EXPECTED(Client.call("sync", nullptr).take(), Succeeded()); + Client.sync(); EXPECT_EQ(3, FeatureModules.get()->getSync()); // Throw some work on the queue to make sure shutdown blocks on it. Client.notify("increment", nullptr); diff --git a/clang-tools-extra/clangd/unittests/LSPClient.h b/clang-tools-extra/clangd/unittests/LSPClient.h --- a/clang-tools-extra/clangd/unittests/LSPClient.h +++ b/clang-tools-extra/clangd/unittests/LSPClient.h @@ -9,12 +9,14 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_LSPCLIENT_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_LSPCLIENT_H +#include "llvm/ADT/StringRef.h" +#include #include #include -#include -#include +#include #include #include +#include namespace clang { namespace clangd { @@ -32,7 +34,8 @@ class CallResult { public: ~CallResult(); - // Blocks up to 10 seconds for the result to be ready. + // Blocks up to \p TimeoutSeconds seconds for the result to be ready. If \p + // TimeoutSeconds is zero, blocks indefinitely. // Records a test failure if there was no reply. llvm::Expected take(); // Like take(), but records a test failure if the result was an error. diff --git a/clang-tools-extra/clangd/unittests/LSPClient.cpp b/clang-tools-extra/clangd/unittests/LSPClient.cpp --- a/clang-tools-extra/clangd/unittests/LSPClient.cpp +++ b/clang-tools-extra/clangd/unittests/LSPClient.cpp @@ -12,19 +12,32 @@ #include "Transport.h" #include "support/Logger.h" #include "support/Threading.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/JSON.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" #include +#include +#include +#include +#include +#include #include #include +#include +#include +#include namespace clang { namespace clangd { llvm::Expected clang::clangd::LSPClient::CallResult::take() { std::unique_lock Lock(Mu); - if (!clangd::wait(Lock, CV, timeoutSeconds(10), + if (!clangd::wait(Lock, CV, timeoutSeconds(60), [this] { return Value.has_value(); })) { ADD_FAILURE() << "No result from call after 10 seconds!"; return llvm::json::Value(nullptr);