diff --git a/test/test_debugger.cpp b/test/test_debugger.cpp index 971413ad..fe89a5c1 100644 --- a/test/test_debugger.cpp +++ b/test/test_debugger.cpp @@ -23,6 +23,8 @@ #include "xeus_client.hpp" +#include "xeus-zmq/xzmq_context.hpp" + #include "pybind11/pybind11.h" #include @@ -1151,9 +1153,9 @@ TEST_SUITE("debugger") { start_kernel(); timer t; - xeus::xcontext context; + auto context_ptr = xeus::make_zmq_context(); { - debugger_client deb(context, KERNEL_JSON, "debugger_init.log"); + debugger_client deb(*context_ptr, KERNEL_JSON, "debugger_init.log"); deb.start(); bool res = deb.test_init(); deb.shutdown(); diff --git a/test/xeus_client.cpp b/test/xeus_client.cpp index db85ba75..53cb1ce2 100644 --- a/test/xeus_client.cpp +++ b/test/xeus_client.cpp @@ -127,12 +127,12 @@ std::size_t xeus_logger_client::iopub_queue_size() const nl::json xeus_logger_client::pop_iopub_message() { - optional msg_opt = p_client->pop_iopub_message(); + std::optional msg_opt = p_client->pop_iopub_message(); nl::json result = nl::json::object(); if (msg_opt.has_value()) { - xeus::xpub_xmessage msg = std::move(*msg_opt); + xeus::xpub_message msg = std::move(*msg_opt); result["topic"] = msg.topic(); result["header"] = msg.header(); result["parent_header"] = msg.parent_header(); @@ -143,6 +143,34 @@ nl::json xeus_logger_client::pop_iopub_message() return result; } +nl::json xeus_logger_client::wait_for_debug_event(const std::string& event) +{ + bool event_found = false; + nl::json msg; + while(!event_found) + { + std::size_t s = iopub_queue_size(); + if(s != 0) + { + msg = pop_iopub_message(); + if(msg["topic"] == "debug_event" && msg["content"]["event"] == event) + { + event_found = true; + } + } + else + { + std::unique_lock lk(m_notify_mutex); + if(iopub_queue_size()) + { + continue; + } + m_notify_cond.wait(lk); + } + } + return msg; +} + void xeus_logger_client::start() { p_client->start(); diff --git a/test/xeus_client.hpp b/test/xeus_client.hpp index 2b3c444d..b3dc31ce 100644 --- a/test/xeus_client.hpp +++ b/test/xeus_client.hpp @@ -45,19 +45,13 @@ class xeus_logger_client std::size_t iopub_queue_size() const; nl::json pop_iopub_message(); - // nl::json wait_for_debug_event(const std::string& event); + nl::json wait_for_debug_event(const std::string& event); void start(); void stop_channels(); void log_message(nl::json msg); private: - // void register_shell_listener(); - // void register_kernel_status_listener(); - - // void handle_shell_message(xeus::xmessage msg); - // void handle_kernel_status_message(bool status); - std::string m_user_name; std::string m_file_name; std::mutex m_file_mutex;