[Lldb-commits] [lldb] [lldb] Refactoring JSONTransport into an abstract RPC Message Handler and transport layer. (PR #153121)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 18 05:01:56 PDT 2025


================
@@ -57,53 +157,84 @@ template <typename T> class JSONTransportTest : public PipePairTest {
                                      NativeFile::Unowned));
   }
 
-  template <typename P>
-  Expected<P>
-  RunOnce(std::chrono::milliseconds timeout = std::chrono::seconds(1)) {
-    std::promise<Expected<P>> promised_message;
-    std::future<Expected<P>> future_message = promised_message.get_future();
-    RunUntil<P>(
-        [&promised_message](Expected<P> message) mutable -> bool {
-          promised_message.set_value(std::move(message));
-          return /*keep_going*/ false;
-        },
-        timeout);
-    return future_message.get();
+  class MessageCollector final
----------------
labath wrote:

There isn't anything json-specific here is it? Could this be moved to unittest/TestingSupport/Host (as a template) to avoid redefining it in each file?

I'd also consider making this a mock (MOCK_METHOD1(OnEvent, void(const Evt &V))`. This essentially handrolls a mock object, but googlemock is more flexible (e.g. lets you match the order of events) and powerful (lets you check that a message was received through the right API), and probably does that in fewer LOC.

https://github.com/llvm/llvm-project/pull/153121


More information about the lldb-commits mailing list