From b6c2ae2e79e12a5f2f3221513f88806d4c082f5a Mon Sep 17 00:00:00 2001 From: Dennis Hezel Date: Thu, 29 Dec 2022 13:09:16 +0100 Subject: [PATCH] chore: Adjust natvis after changing member variable suffix. Address some clang-tidy issues in test utility code --- .clang-tidy | 1 + asio-grpc.natvis | 76 +++++++++++++------------- test/src/test_grpc_context_17.cpp | 7 ++- test/utils/utils/asio_utils.hpp | 23 +++----- test/utils/utils/free_port.cpp | 2 +- test/utils/utils/grpc_context_test.cpp | 2 +- test/utils/utils/grpc_context_test.hpp | 2 +- test/utils/utils/high_level_client.hpp | 5 +- test/utils/utils/rpc.cpp | 10 ++-- test/utils/utils/rpc.hpp | 10 ++-- 10 files changed, 66 insertions(+), 72 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index f0ba16a2..117baf2d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -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 diff --git a/asio-grpc.natvis b/asio-grpc.natvis index bf080120..c3fbb268 100644 --- a/asio-grpc.natvis +++ b/asio-grpc.natvis @@ -39,75 +39,75 @@ - {impl.impl.first_} + {impl_.impl_.first_} - impl.impl.first_->context - impl.impl.first_->request_ - impl.impl.first_->responder_ + impl_.impl_.first_->context_ + impl_.impl_.first_->request_ + impl_.impl_.first_->responder_ - {impl.impl.first_} + {impl_.impl_.first_} - impl.impl.first_->context - impl.impl.first_->request_ - impl.impl.first_->responder_ + impl_.impl_.first_->context_ + impl_.impl_.first_->request_ + impl_.impl_.first_->responder_ - {this->impl} + {this->impl_} - this->impl.first_ - this->impl.second_ + this->impl_.first_ + this->impl_.second_ - {this->impl} + {this->impl_} - this->impl.first_ - this->impl.second_ + this->impl_.first_ + this->impl_.second_ - {this->impl} + {this->impl_} - this->impl.first_ - this->impl.second_ + this->impl_.first_ + this->impl_.second_ - {impl.first_} + {impl_.first_} - impl.first_ - impl.second_ + impl_.first_ + impl_.second_ - {impl.first_} + {impl_.first_} - impl.first_ - impl.second_ + impl_.first_ + impl_.second_ - {*($T1 *)(ptr & PTR_MASK)} + {*($T1 *)(ptr_ & PTR_MASK)} - *($T1 *)(ptr & PTR_MASK) + *($T1 *)(ptr_ & PTR_MASK) - {*($T1 *)(ptr & PTR_MASK)} + {*($T1 *)(ptr_ & PTR_MASK)} - *($T1 *)(ptr & PTR_MASK) + *($T1 *)(ptr_ & PTR_MASK) - {*($T1 *)(ptr & PTR_MASK)} + {*($T1 *)(ptr_ & PTR_MASK)} - *($T1 *)(ptr & PTR_MASK) + *($T1 *)(ptr_ & PTR_MASK) @@ -115,27 +115,27 @@ {this->status_} this->status_ - this->executor - this->client_context.context - this->responder_ + this->executor_ + this->client_context_.context_ + this->responder_ {this->status_} this->status_ - this->executor - this->client_context.context - this->responder_ + this->executor_ + this->client_context_.context_ + this->responder_ {this->status_} this->status_ - this->executor - this->client_context.context - this->responder_ + this->executor_ + this->client_context_.context_ + this->responder_ \ No newline at end of file diff --git a/test/src/test_grpc_context_17.cpp b/test/src/test_grpc_context_17.cpp index 9bc80360..678fbedf 100644 --- a/test/src/test_grpc_context_17.cpp +++ b/test/src/test_grpc_context_17.cpp @@ -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; @@ -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; }); @@ -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 diff --git a/test/utils/utils/asio_utils.hpp b/test/utils/utils/asio_utils.hpp index 9edd52c5..63b66fff 100644 --- a/test/utils/utils/asio_utils.hpp +++ b/test/utils/utils/asio_utils.hpp @@ -44,7 +44,7 @@ struct NoOp struct RethrowFirstArg { - void operator()(std::exception_ptr ep) + void operator()(const std::exception_ptr& ep) { if (ep) { @@ -105,27 +105,22 @@ struct FunctionAsStatefulReceiver : public test::FunctionAsReceiver 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 {} @@ -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(t))); }; }(function)...) .async_wait(cancellation_condition, std::forward(token)); diff --git a/test/utils/utils/free_port.cpp b/test/utils/utils/free_port.cpp index 7a52688a..8996702f 100644 --- a/test/utils/utils/free_port.cpp +++ b/test/utils/utils/free_port.cpp @@ -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; } diff --git a/test/utils/utils/grpc_context_test.cpp b/test/utils/utils/grpc_context_test.cpp index 29745d46..5e3ddfd6 100644 --- a/test/utils/utils/grpc_context_test.cpp +++ b/test/utils/utils/grpc_context_test.cpp @@ -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 diff --git a/test/utils/utils/grpc_context_test.hpp b/test/utils/utils/grpc_context_test.hpp index 5ab2d2cc..cc981993 100644 --- a/test/utils/utils/grpc_context_test.hpp +++ b/test/utils/utils/grpc_context_test.hpp @@ -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; diff --git a/test/utils/utils/high_level_client.hpp b/test/utils/utils/high_level_client.hpp index 9e77e481..ae0117c6 100644 --- a/test/utils/utils/high_level_client.hpp +++ b/test/utils/utils/high_level_client.hpp @@ -168,10 +168,7 @@ struct HighLevelClientTest : test::GrpcClientServerTest return IntrospectRPC::request(this->get_executor(), *stub, generic_stub, client_context, request, response, token); } - else - { - return request_rpc(token); - } + return request_rpc(token); } template diff --git a/test/utils/utils/rpc.cpp b/test/utils/utils/rpc.cpp index 91d31500..1fd4a503 100644 --- a/test/utils/utils/rpc.cpp +++ b/test/utils/utils/rpc.cpp @@ -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); @@ -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; @@ -50,7 +50,7 @@ namespace { template 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)); @@ -82,7 +82,7 @@ void client_perform_client_streaming_success_impl(test::msg::Response& response, void client_perform_client_streaming_success(test::msg::Response& response, grpc::ClientAsyncWriter& writer, - asio::yield_context yield, + const asio::yield_context& yield, test::PerformClientStreamingSuccessOptions options) { test::client_perform_client_streaming_success_impl(response, writer, yield, options); @@ -90,7 +90,7 @@ void client_perform_client_streaming_success(test::msg::Response& response, void client_perform_client_streaming_success(test::msg::Response& response, grpc::ClientAsyncWriterInterface& writer, - asio::yield_context yield, + const asio::yield_context& yield, test::PerformClientStreamingSuccessOptions options) { test::client_perform_client_streaming_success_impl(response, writer, yield, options); diff --git a/test/utils/utils/rpc.hpp b/test/utils/utils/rpc.hpp index 85edd3c5..196ee02c 100644 --- a/test/utils/utils/rpc.hpp +++ b/test/utils/utils/rpc.hpp @@ -68,7 +68,7 @@ struct PerformUnarySuccessOptions }; template -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(); @@ -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 @@ -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& 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& writer, - asio::yield_context yield, + const asio::yield_context& yield, test::PerformClientStreamingSuccessOptions options = {}); }