Skip to content

Commit

Permalink
chore: Adjust natvis after changing member variable suffix. Address s…
Browse files Browse the repository at this point in the history
…ome clang-tidy issues in test utility code
  • Loading branch information
Tradias committed Dec 29, 2022
1 parent 22fbbac commit b6c2ae2
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 72 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
Checks: "clang-diagnostic-*,clang-analyzer-*,readability-*,modernize-*,performance-*,bugprone-*,cert-*,-readability-magic-numbers,-readability-identifier-length,-readability-named-parameter,-modernize-use-trailing-return-type,-modernize-avoid-c-arrays,-cert-dcl58-cpp,-bugprone-forwarding-reference-overload,-readability-uppercase-literal-suffix,-cert-dcl21-cpp"
HeaderFilterRegex: "agrpc/.*"
CheckOptions:
- key: readability-identifier-naming.NamespaceCase
value: lower_case
Expand Down
76 changes: 38 additions & 38 deletions asio-grpc.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -39,103 +39,103 @@
</Type>
<!-- RepeatedlyRequestContext -->
<Type Name="agrpc::b::RepeatedlyRequestContext&lt;*&gt;">
<DisplayString>{impl.impl.first_}</DisplayString>
<DisplayString>{impl_.impl_.first_}</DisplayString>
<Expand>
<Item Name="[server_context]">impl.impl.first_->context</Item>
<Item Name="[request]" Optional="true">impl.impl.first_->request_</Item>
<Item Name="[responder]">impl.impl.first_->responder_</Item>
<Item Name="[server_context]">impl_.impl_.first_->context_</Item>
<Item Name="[request]" Optional="true">impl_.impl_.first_->request_</Item>
<Item Name="[responder]">impl_.impl_.first_->responder_</Item>
</Expand>
</Type>
<Type Name="agrpc::s::RepeatedlyRequestContext&lt;*&gt;">
<DisplayString>{impl.impl.first_}</DisplayString>
<DisplayString>{impl_.impl_.first_}</DisplayString>
<Expand>
<Item Name="[server_context]">impl.impl.first_->context</Item>
<Item Name="[request]" Optional="true">impl.impl.first_->request_</Item>
<Item Name="[responder]">impl.impl.first_->responder_</Item>
<Item Name="[server_context_]">impl_.impl_.first_->context_</Item>
<Item Name="[request]" Optional="true">impl_.impl_.first_->request_</Item>
<Item Name="[responder]">impl_.impl_.first_->responder_</Item>
</Expand>
</Type>
<!-- BasicGrpcExecutor -->
<Type Name="agrpc::b::BasicGrpcExecutor&lt;*,*&gt;">
<DisplayString>{this->impl}</DisplayString>
<DisplayString>{this->impl_}</DisplayString>
<Expand>
<Item Name="[grpc_context]">this->impl.first_</Item>
<Item Name="[allocator]" Optional="true">this->impl.second_</Item>
<Item Name="[grpc_context]">this->impl_.first_</Item>
<Item Name="[allocator]" Optional="true">this->impl_.second_</Item>
</Expand>
</Type>
<Type Name="agrpc::s::BasicGrpcExecutor&lt;*,*&gt;">
<DisplayString>{this->impl}</DisplayString>
<DisplayString>{this->impl_}</DisplayString>
<Expand>
<Item Name="[grpc_context]">this->impl.first_</Item>
<Item Name="[allocator]" Optional="true">this->impl.second_</Item>
<Item Name="[grpc_context]">this->impl_.first_</Item>
<Item Name="[allocator]" Optional="true">this->impl_.second_</Item>
</Expand>
</Type>
<Type Name="agrpc::u::BasicGrpcExecutor&lt;*,*&gt;">
<DisplayString>{this->impl}</DisplayString>
<DisplayString>{this->impl_}</DisplayString>
<Expand>
<Item Name="[grpc_context]">this->impl.first_</Item>
<Item Name="[allocator]" Optional="true">this->impl.second_</Item>
<Item Name="[grpc_context]">this->impl_.first_</Item>
<Item Name="[allocator]" Optional="true">this->impl_.second_</Item>
</Expand>
</Type>
<!-- AllocatorBinder -->
<Type Name="agrpc::b::AllocatorBinder&lt;*,*&gt;">
<DisplayString>{impl.first_}</DisplayString>
<DisplayString>{impl_.first_}</DisplayString>
<Expand>
<Item Name="[target]">impl.first_</Item>
<Item Name="[allocator]" Optional="true">impl.second_</Item>
<Item Name="[target]">impl_.first_</Item>
<Item Name="[allocator]" Optional="true">impl_.second_</Item>
</Expand>
</Type>
<Type Name="agrpc::s::AllocatorBinder&lt;*,*&gt;">
<DisplayString>{impl.first_}</DisplayString>
<DisplayString>{impl_.first_}</DisplayString>
<Expand>
<Item Name="[target]">impl.first_</Item>
<Item Name="[allocator]" Optional="true">impl.second_</Item>
<Item Name="[target]">impl_.first_</Item>
<Item Name="[allocator]" Optional="true">impl_.second_</Item>
</Expand>
</Type>
<!-- TaggedPtr -->
<Type Name="agrpc::b::detail::TaggedPtr&lt;*&gt;">
<DisplayString>{*($T1 *)(ptr &amp; PTR_MASK)}</DisplayString>
<DisplayString>{*($T1 *)(ptr_ &amp; PTR_MASK)}</DisplayString>
<Expand>
<ExpandedItem>*($T1 *)(ptr &amp; PTR_MASK)</ExpandedItem>
<ExpandedItem>*($T1 *)(ptr_ &amp; PTR_MASK)</ExpandedItem>
</Expand>
</Type>
<Type Name="agrpc::s::detail::TaggedPtr&lt;*&gt;">
<DisplayString>{*($T1 *)(ptr &amp; PTR_MASK)}</DisplayString>
<DisplayString>{*($T1 *)(ptr_ &amp; PTR_MASK)}</DisplayString>
<Expand>
<ExpandedItem>*($T1 *)(ptr &amp; PTR_MASK)</ExpandedItem>
<ExpandedItem>*($T1 *)(ptr_ &amp; PTR_MASK)</ExpandedItem>
</Expand>
</Type>
<Type Name="agrpc::u::detail::TaggedPtr&lt;*&gt;">
<DisplayString>{*($T1 *)(ptr &amp; PTR_MASK)}</DisplayString>
<DisplayString>{*($T1 *)(ptr_ &amp; PTR_MASK)}</DisplayString>
<Expand>
<ExpandedItem>*($T1 *)(ptr &amp; PTR_MASK)</ExpandedItem>
<ExpandedItem>*($T1 *)(ptr_ &amp; PTR_MASK)</ExpandedItem>
</Expand>
</Type>
<!-- RPC -->
<Type Name="agrpc::b::RPC&lt;*,*,*&gt;">
<DisplayString>{this->status_}</DisplayString>
<Expand>
<Item Name="[status]">this->status_</Item>
<Item Name="[executor]">this->executor</Item>
<Item Name="[client_context]" Optional="true">this->client_context.context</Item>
<Item Name="[responder]" Optional="true">this->responder_</Item>
<Item Name="[executor]">this->executor_</Item>
<Item Name="[client_context]">this->client_context_.context_</Item>
<Item Name="[responder]">this->responder_</Item>
</Expand>
</Type>
<Type Name="agrpc::s::RPC&lt;*,*,*&gt;">
<DisplayString>{this->status_}</DisplayString>
<Expand>
<Item Name="[status]">this->status_</Item>
<Item Name="[executor]">this->executor</Item>
<Item Name="[client_context]" Optional="true">this->client_context.context</Item>
<Item Name="[responder]" Optional="true">this->responder_</Item>
<Item Name="[executor]">this->executor_</Item>
<Item Name="[client_context]">this->client_context_.context_</Item>
<Item Name="[responder]">this->responder_</Item>
</Expand>
</Type>
<Type Name="agrpc::u::RPC&lt;*,*,*&gt;">
<DisplayString>{this->status_}</DisplayString>
<Expand>
<Item Name="[status]">this->status_</Item>
<Item Name="[executor]">this->executor</Item>
<Item Name="[client_context]" Optional="true">this->client_context.context</Item>
<Item Name="[responder]" Optional="true">this->responder_</Item>
<Item Name="[executor]">this->executor_</Item>
<Item Name="[client_context]">this->client_context_.context_</Item>
<Item Name="[responder]">this->responder_</Item>
</Expand>
</Type>
</AutoVisualizer>
7 changes: 4 additions & 3 deletions test/src/test_grpc_context_17.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ TEST_CASE_FIXTURE(test::GrpcContextTest, "GrpcContext.run_while() runs until the
{
bool alarm1_finished{false};
grpc::Alarm alarm1;
wait(alarm1, test::two_hundred_milliseconds_from_now(),
wait(alarm1, test::one_second_from_now(),
[&](bool)
{
alarm1_finished = true;
Expand All @@ -736,7 +736,7 @@ TEST_CASE_FIXTURE(test::GrpcContextTest, "GrpcContext.run_while() runs until the
alarm2_finished = true;
});
grpc_context.run_while(
[&]()
[&]
{
return !alarm2_finished;
});
Expand All @@ -747,9 +747,10 @@ TEST_CASE_FIXTURE(test::GrpcContextTest, "GrpcContext.run_while() runs until the
sync_api();
CHECK_FALSE(alarm1_finished);
CHECK(alarm2_finished);
alarm1.Cancel();
});
CHECK(grpc_context.run());
CHECK(alarm2_finished);
CHECK(alarm1_finished);
}

#ifdef AGRPC_ASIO_HAS_SENDER_RECEIVER
Expand Down
23 changes: 9 additions & 14 deletions test/utils/utils/asio_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct NoOp

struct RethrowFirstArg
{
void operator()(std::exception_ptr ep)
void operator()(const std::exception_ptr& ep)
{
if (ep)
{
Expand Down Expand Up @@ -105,27 +105,22 @@ struct FunctionAsStatefulReceiver : public test::FunctionAsReceiver<Function, Al

void set_done() noexcept { state.was_done = true; }

void set_error(std::exception_ptr ptr) noexcept { state.exception = ptr; }
void set_error(const std::exception_ptr& ptr) noexcept { state.exception = ptr; }
};

template <bool IsNothrow>
struct ConditionallyNoexceptNoOpReceiver
{
ConditionallyNoexceptNoOpReceiver() noexcept(IsNothrow) {}
ConditionallyNoexceptNoOpReceiver() noexcept(IsNothrow) = default;

ConditionallyNoexceptNoOpReceiver(const ConditionallyNoexceptNoOpReceiver&) noexcept(IsNothrow) {}
ConditionallyNoexceptNoOpReceiver(const ConditionallyNoexceptNoOpReceiver&) noexcept(IsNothrow) = default;

ConditionallyNoexceptNoOpReceiver(ConditionallyNoexceptNoOpReceiver&&) noexcept(IsNothrow) {}
ConditionallyNoexceptNoOpReceiver(ConditionallyNoexceptNoOpReceiver&&) noexcept(IsNothrow) = default;

ConditionallyNoexceptNoOpReceiver& operator=(const ConditionallyNoexceptNoOpReceiver&) noexcept(IsNothrow)
{
return *this;
}
ConditionallyNoexceptNoOpReceiver& operator=(const ConditionallyNoexceptNoOpReceiver&) noexcept(IsNothrow) =
default;

ConditionallyNoexceptNoOpReceiver& operator=(ConditionallyNoexceptNoOpReceiver&&) noexcept(IsNothrow)
{
return *this;
}
ConditionallyNoexceptNoOpReceiver& operator=(ConditionallyNoexceptNoOpReceiver&&) noexcept(IsNothrow) = default;

void set_done() noexcept {}

Expand Down Expand Up @@ -234,7 +229,7 @@ auto parallel_group_bind_executor(const Executor& executor, CancellationConditio
{
return [&](auto&& t)
{
return f(asio::bind_executor(executor, std::move(t)));
return f(asio::bind_executor(executor, std::forward<decltype(t)>(t)));
};
}(function)...)
.async_wait(cancellation_condition, std::forward<CompletionToken>(token));
Expand Down
2 changes: 1 addition & 1 deletion test/utils/utils/free_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void recreate_if_old(const fs::path& port_file)

auto get_port_lock_file()
{
const auto port_file = fs::temp_directory_path() / (std::string(PORT_FILE_NAME) + ".lock");
auto port_file = fs::temp_directory_path() / (std::string(PORT_FILE_NAME) + ".lock");
std::ofstream file_stream{port_file.native()};
return port_file;
}
Expand Down
2 changes: 1 addition & 1 deletion test/utils/utils/grpc_context_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ agrpc::GrpcExecutor GrpcContextTest::get_executor() noexcept { return grpc_conte

test::TrackingAllocator<> GrpcContextTest::get_allocator() noexcept { return test::TrackingAllocator<>(resource); }

bool GrpcContextTest::allocator_has_been_used() noexcept { return resource.bytes_allocated > 0; }
bool GrpcContextTest::allocator_has_been_used() const noexcept { return resource.bytes_allocated > 0; }

#if defined(AGRPC_STANDALONE_ASIO) || defined(AGRPC_BOOST_ASIO)
GrpcContextTrackingAllocatorExecutor GrpcContextTest::get_tracking_allocator_executor() noexcept
Expand Down
2 changes: 1 addition & 1 deletion test/utils/utils/grpc_context_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct GrpcContextTest

auto use_sender() noexcept { return agrpc::use_sender(get_executor()); }

bool allocator_has_been_used() noexcept;
bool allocator_has_been_used() const noexcept;

#if defined(AGRPC_STANDALONE_ASIO) || defined(AGRPC_BOOST_ASIO)
GrpcContextTrackingAllocatorExecutor get_tracking_allocator_executor() noexcept;
Expand Down
5 changes: 1 addition & 4 deletions test/utils/utils/high_level_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,7 @@ struct HighLevelClientTest : test::GrpcClientServerTest
return IntrospectRPC<RPC>::request(this->get_executor(), *stub, generic_stub, client_context, request,
response, token);
}
else
{
return request_rpc(token);
}
return request_rpc(token);
}

template <class CompletionToken>
Expand Down
10 changes: 5 additions & 5 deletions test/utils/utils/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
namespace test
{
bool client_perform_unary_unchecked(agrpc::GrpcContext& grpc_context, test::v1::Test::Stub& stub,
asio::yield_context yield, std::chrono::system_clock::time_point deadline)
const asio::yield_context& yield, std::chrono::system_clock::time_point deadline)
{
const auto client_context = test::create_client_context(deadline);
const auto reader = agrpc::request(&test::v1::Test::Stub::AsyncUnary, stub, *client_context, {}, grpc_context);
Expand All @@ -35,7 +35,7 @@ bool client_perform_unary_unchecked(agrpc::GrpcContext& grpc_context, test::v1::
return agrpc::finish(*reader, response, status, yield);
}

void client_perform_client_streaming_success(test::v1::Test::Stub& stub, asio::yield_context yield,
void client_perform_client_streaming_success(test::v1::Test::Stub& stub, const asio::yield_context& yield,
test::PerformClientStreamingSuccessOptions options)
{
test::msg::Response response;
Expand All @@ -50,7 +50,7 @@ namespace
{
template <class Writer>
void client_perform_client_streaming_success_impl(test::msg::Response& response, Writer& writer,
asio::yield_context yield,
const asio::yield_context& yield,
test::PerformClientStreamingSuccessOptions options)
{
CHECK(agrpc::read_initial_metadata(writer, yield));
Expand Down Expand Up @@ -82,15 +82,15 @@ void client_perform_client_streaming_success_impl(test::msg::Response& response,

void client_perform_client_streaming_success(test::msg::Response& response,
grpc::ClientAsyncWriter<test::msg::Request>& writer,
asio::yield_context yield,
const asio::yield_context& yield,
test::PerformClientStreamingSuccessOptions options)
{
test::client_perform_client_streaming_success_impl(response, writer, yield, options);
}

void client_perform_client_streaming_success(test::msg::Response& response,
grpc::ClientAsyncWriterInterface<test::msg::Request>& writer,
asio::yield_context yield,
const asio::yield_context& yield,
test::PerformClientStreamingSuccessOptions options)
{
test::client_perform_client_streaming_success_impl(response, writer, yield, options);
Expand Down
10 changes: 5 additions & 5 deletions test/utils/utils/rpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct PerformUnarySuccessOptions
};

template <class Stub>
void client_perform_unary_success(agrpc::GrpcContext& grpc_context, Stub& stub, asio::yield_context yield,
void client_perform_unary_success(agrpc::GrpcContext& grpc_context, Stub& stub, const asio::yield_context& yield,
test::PerformUnarySuccessOptions options = {})
{
const auto client_context = test::create_client_context();
Expand All @@ -90,7 +90,7 @@ void client_perform_unary_success(agrpc::GrpcContext& grpc_context, Stub& stub,
}

bool client_perform_unary_unchecked(agrpc::GrpcContext& grpc_context, test::v1::Test::Stub& stub,
asio::yield_context yield,
const asio::yield_context& yield,
std::chrono::system_clock::time_point deadline = test::five_seconds_from_now());

struct PerformClientStreamingSuccessOptions
Expand All @@ -100,17 +100,17 @@ struct PerformClientStreamingSuccessOptions
int32_t request_payload{42};
};

void client_perform_client_streaming_success(test::v1::Test::Stub& stub, asio::yield_context yield,
void client_perform_client_streaming_success(test::v1::Test::Stub& stub, const asio::yield_context& yield,
test::PerformClientStreamingSuccessOptions options = {});

void client_perform_client_streaming_success(test::msg::Response& response,
grpc::ClientAsyncWriter<test::msg::Request>& writer,
asio::yield_context yield,
const asio::yield_context& yield,
test::PerformClientStreamingSuccessOptions options = {});

void client_perform_client_streaming_success(test::msg::Response& response,
grpc::ClientAsyncWriterInterface<test::msg::Request>& writer,
asio::yield_context yield,
const asio::yield_context& yield,
test::PerformClientStreamingSuccessOptions options = {});
}

Expand Down

0 comments on commit b6c2ae2

Please sign in to comment.