Skip to content

Commit

Permalink
test: Improve "unifex throw exception from request message factory"
Browse files Browse the repository at this point in the history
  • Loading branch information
Tradias committed Dec 9, 2024
1 parent 4f1ee9c commit 7c823b6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
6 changes: 3 additions & 3 deletions test/src/test_unifex_20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<false>(test::five_seconds_from_now()),
make_client_unary_request_sender<false>(test::five_seconds_from_now())),
std::move(rpc_handler)));
CHECK_THROWS_AS(std::rethrow_exception(eptr), test::Exception);
}

Expand Down
19 changes: 16 additions & 3 deletions test/utils/utils/execution_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,20 @@ struct ExecutionRpcHandlerTest : test::ExecutionTestMixin<test::GrpcClientServer
test::msg::Response response;
};

template <class OnRequestDone = test::NoOp>
template <bool IsUnstoppable, class Sender>
decltype(auto) maybe_unstoppable(Sender&& sender)
{
if constexpr (IsUnstoppable)
{
return test::unstoppable(std::forward<Sender>(sender));
}
else
{
return std::forward<Sender>(sender);
}
}

template <bool IsUnstoppable = true, class OnRequestDone = test::NoOp>
auto make_client_unary_request_sender(std::chrono::system_clock::time_point deadline,
OnRequestDone on_request_done = {})
{
Expand All @@ -82,8 +95,8 @@ struct ExecutionRpcHandlerTest : test::ExecutionTestMixin<test::GrpcClientServer
{
auto& [client_context, request, response] = *context;
return stdexec::then(
test::unstoppable(test::UnaryClientRPC::request(grpc_context, *stub, client_context, request,
response, agrpc::use_sender)),
maybe_unstoppable<IsUnstoppable>(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;
Expand Down

0 comments on commit 7c823b6

Please sign in to comment.