From 7c823b698b760e00eb838962f66163c4d4b1c10a Mon Sep 17 00:00:00 2001 From: Dennis Hezel Date: Mon, 9 Dec 2024 10:20:29 +0100 Subject: [PATCH] test: Improve "unifex throw exception from request message factory" --- test/src/test_unifex_20.cpp | 6 +++--- test/utils/utils/execution_test.hpp | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/test/src/test_unifex_20.cpp b/test/src/test_unifex_20.cpp index 283145e8..28e87767 100644 --- a/test/src/test_unifex_20.cpp +++ b/test/src/test_unifex_20.cpp @@ -220,9 +220,9 @@ TEST_CASE_FIXTURE(test::ExecutionRpcHandlerTest, eptr = ep; return unifex::just(); }); - run(unifex::sequence(make_client_unary_request_sender(test::ten_milliseconds_from_now()), - make_client_unary_request_sender(test::ten_milliseconds_from_now())), - std::move(rpc_handler)); + run(unifex::stop_when(unifex::sequence(make_client_unary_request_sender(test::five_seconds_from_now()), + make_client_unary_request_sender(test::five_seconds_from_now())), + std::move(rpc_handler))); CHECK_THROWS_AS(std::rethrow_exception(eptr), test::Exception); } diff --git a/test/utils/utils/execution_test.hpp b/test/utils/utils/execution_test.hpp index e0d36bd1..49824665 100644 --- a/test/utils/utils/execution_test.hpp +++ b/test/utils/utils/execution_test.hpp @@ -68,7 +68,20 @@ struct ExecutionRpcHandlerTest : test::ExecutionTestMixin + template + decltype(auto) maybe_unstoppable(Sender&& sender) + { + if constexpr (IsUnstoppable) + { + return test::unstoppable(std::forward(sender)); + } + else + { + return std::forward(sender); + } + } + + template auto make_client_unary_request_sender(std::chrono::system_clock::time_point deadline, OnRequestDone on_request_done = {}) { @@ -82,8 +95,8 @@ struct ExecutionRpcHandlerTest : test::ExecutionTestMixin(test::UnaryClientRPC::request( + grpc_context, *stub, client_context, request, response, agrpc::use_sender)), [&context, on_request_done](const grpc::Status& status) { auto& [client_context, request, response] = *context;