Skip to content

Commit

Permalink
Remove include gtest_prod.h (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
autopear authored Jun 4, 2024
1 parent 34996ed commit 16ae3fa
Show file tree
Hide file tree
Showing 39 changed files with 110 additions and 83 deletions.
2 changes: 1 addition & 1 deletion flare/base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ cc_library(
srcs = [],
deps = [
'//flare/base/internal:logging',
'//thirdparty/googletest:gtest_prod',
'//flare/base/internal:test_prod',
],
visibility = 'PUBLIC',
)
Expand Down
2 changes: 1 addition & 1 deletion flare/base/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
"//flare/base/internal:logging",
"//thirdparty/googletest:gtest_prod",
"//flare/base/internal:test_prod",
],
)

Expand Down
6 changes: 6 additions & 0 deletions flare/base/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,9 @@ cc_library(
hdrs = 'meta.h',
visibility = ['//flare/...'],
)

cc_library(
name = 'test_prod',
hdrs = 'test_prod.h',
visibility = ['//flare/...'],
)
6 changes: 6 additions & 0 deletions flare/base/internal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -498,3 +498,9 @@ cc_library(
hdrs = ["meta.h"],
visibility = ["//flare:__subpackages__"],
)

cc_library(
name = "test_prod",
hdrs = ["test_prod.h"],
visibility = ["//flare:__subpackages__"],
)
23 changes: 23 additions & 0 deletions flare/base/internal/test_prod.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the BSD 3-Clause License (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the
// License at
//
// https://opensource.org/licenses/BSD-3-Clause
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.

#ifndef FLARE_BASE_INTERNAL_TEST_PROD_H_
#define FLARE_BASE_INTERNAL_TEST_PROD_H_

#ifndef FLARE_FRIEND_TEST
#define FLARE_FRIEND_TEST(test_case_name, test_name) \
friend class test_case_name##_##test_name##_Test
#endif // !FLARE_FRIEND_TEST

#endif // FLARE_BASE_INTERNAL_TEST_PROD_H_
5 changes: 2 additions & 3 deletions flare/base/maybe_owning.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
#include <memory>
#include <utility>

#include "gtest/gtest_prod.h"

#include "flare/base/internal/logging.h"
#include "flare/base/internal/test_prod.h"

namespace flare {

Expand Down Expand Up @@ -143,7 +142,7 @@ class MaybeOwning {
// This is dangerous as we could not check for `Owning()` at compile time.

private:
FRIEND_TEST(MaybeOwning, Reset);
FLARE_FRIEND_TEST(MaybeOwning, Reset);

// Reset the pointer we have.
//
Expand Down
2 changes: 1 addition & 1 deletion flare/base/write_mostly/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ cc_library(
'//flare/base:align',
'//flare/base:chrono',
'//flare/base/internal:time_keeper',
'//flare/base/internal:test_prod',
'//flare/base/thread:spinlock',
'//thirdparty/googletest:gtest_prod',
],
visibility = ['//flare/base:write_mostly'],
)
Expand Down
2 changes: 1 addition & 1 deletion flare/base/write_mostly/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ cc_library(
"//flare/base:align",
"//flare/base:chrono",
"//flare/base/internal:time_keeper",
"//flare/base/internal:test_prod",
"//flare/base/thread:spinlock",
"//thirdparty/googletest:gtest_prod",
],
)

Expand Down
5 changes: 2 additions & 3 deletions flare/base/write_mostly/metrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
#include <utility>
#include <vector>

#include "gtest/gtest_prod.h"

#include "flare/base/align.h"
#include "flare/base/chrono.h"
#include "flare/base/internal/test_prod.h"
#include "flare/base/internal/time_keeper.h"
#include "flare/base/thread/spinlock.h"
#include "flare/base/write_mostly/write_mostly.h"
Expand Down Expand Up @@ -101,7 +100,7 @@ class WriteMostlyMetrics {
}

private:
FRIEND_TEST(MetricsTest, Get);
FLARE_FRIEND_TEST(MetricsTest, Get);
void Purge() {
auto entry = std::make_unique<write_mostly::detail::MetricsStats<T>>();
std::scoped_lock _(records_lock_);
Expand Down
2 changes: 1 addition & 1 deletion flare/io/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ cc_library(
'//flare/base:string',
'//flare/base:tsc',
'//flare/base/internal:memory_barrier',
'//flare/base/internal:test_prod',
'//flare/base/net:endpoint',
'//flare/base/thread:latch',
'//flare/fiber:fiber',
Expand All @@ -77,7 +78,6 @@ cc_library(
'//flare/io/util:socket',
'//flare/io/util:stream_io',
'//thirdparty/gflags:gflags',
'//thirdparty/googletest:gtest_prod',
],
visibility = 'PUBLIC',
)
Expand Down
2 changes: 1 addition & 1 deletion flare/io/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ cc_library(
"//flare/base:string",
"//flare/base:tsc",
"//flare/base/internal:memory_barrier",
"//flare/base/internal:test_prod",
"//flare/base/net:endpoint",
"//flare/base/thread:latch",
"//flare/fiber",
Expand All @@ -77,7 +78,6 @@ cc_library(
"//flare/io/util:rate_limiter",
"//flare/io/util:socket",
"//flare/io/util:stream_io",
"//thirdparty/googletest:gtest_prod",
"@com_github_gflags_gflags//:gflags",
],
)
Expand Down
5 changes: 2 additions & 3 deletions flare/io/descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
#include <memory>
#include <string>

#include "gtest/gtest_prod.h"

#include "flare/base/align.h"
#include "flare/base/enum.h"
#include "flare/base/handle.h"
#include "flare/base/internal/test_prod.h"
#include "flare/base/ref_ptr.h"
#include "flare/fiber/mutex.h"

Expand Down Expand Up @@ -122,7 +121,7 @@ class alignas(hardware_destructive_interference_size) Descriptor
void WaitForCleanup();

private:
FRIEND_TEST(Descriptor, ConcurrentRestartRead);
FLARE_FRIEND_TEST(Descriptor, ConcurrentRestartRead);
friend class EventLoop;
struct SeldomlyUsed;

Expand Down
2 changes: 1 addition & 1 deletion flare/io/detail/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ cc_library(
'//flare/base:likely',
'//flare/base:object_pool',
'//flare/base/internal:annotation',
'//flare/base/internal:test_prod',
'//flare/io/util:stream_io',
'//thirdparty/googletest:gtest_prod',
],
visibility = ['//flare/...'],
)
Expand Down
2 changes: 1 addition & 1 deletion flare/io/detail/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ cc_library(
"//flare/base:likely",
"//flare/base:object_pool",
"//flare/base/internal:annotation",
"//flare/base/internal:test_prod",
"//flare/io/util:stream_io",
"//thirdparty/googletest:gtest_prod",
],
)

Expand Down
5 changes: 2 additions & 3 deletions flare/io/detail/writing_buffer_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@

#include <vector>

#include "gtest/gtest_prod.h"

#include "flare/base/align.h"
#include "flare/base/buffer.h"
#include "flare/base/internal/test_prod.h"
#include "flare/io/util/stream_io.h"

namespace flare {
Expand Down Expand Up @@ -71,7 +70,7 @@ class alignas(hardware_destructive_interference_size) WritingBufferList {
bool Append(NoncontiguousBuffer buffer, std::uintptr_t ctx);

private:
FRIEND_TEST(WritingBufferList, Torture);
FLARE_FRIEND_TEST(WritingBufferList, Torture);

struct Node {
std::atomic<Node*> next;
Expand Down
8 changes: 4 additions & 4 deletions flare/net/hbase/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ cc_library(
'//flare/base:buffer',
'//flare/base:logging',
'//flare/base/internal:time_view',
'//flare/base/internal:test_prod',
'//flare/base/net:endpoint',
'//flare/net/hbase/proto:constants',
'//flare/net/hbase/proto:rpc_proto',
'//thirdparty/googletest:gtest_prod',
'//thirdparty/protobuf:protobuf',
]
)
Expand Down Expand Up @@ -184,7 +184,7 @@ cc_library(
deps = [
':hbase_controller_common',
'//flare/base/internal:early_init',
'//thirdparty/googletest:gtest_prod',
'//flare/base/internal:test_prod',
],
visibility = 'PUBLIC',
)
Expand All @@ -211,11 +211,11 @@ cc_library(
'//flare/base:endian',
'//flare/base:logging',
'//flare/base/buffer:zero_copy_stream',
'//flare/base/internal:test_prod',
'//flare/net/hbase/proto:rpc_proto',
'//flare/rpc/protocol:controller',
'//flare/rpc/protocol:message',
'//flare/rpc/protocol:stream_protocol',
'//thirdparty/googletest:gtest_prod',
]
)

Expand All @@ -232,10 +232,10 @@ cc_library(
'//flare/base:down_cast',
'//flare/base:endian',
'//flare/base/buffer:zero_copy_stream',
'//flare/base/internal:test_prod',
'//flare/net/hbase/proto:rpc_proto',
'//flare/rpc/protocol:message',
'//flare/rpc/protocol:stream_protocol',
'//thirdparty/googletest:gtest_prod',
]
)

Expand Down
8 changes: 4 additions & 4 deletions flare/net/hbase/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ cc_library(
"//flare/base:buffer",
"//flare/base:logging",
"//flare/base/internal:time_view",
"//flare/base/internal:test_prod",
"//flare/base/net:endpoint",
"//flare/net/hbase/proto:constants",
"//flare/net/hbase/proto:rpc_cc_proto",
"//thirdparty/googletest:gtest_prod",
],
)

Expand Down Expand Up @@ -185,7 +185,7 @@ cc_library(
deps = [
":hbase_controller_common",
"//flare/base/internal:early_init",
"//thirdparty/googletest:gtest_prod",
"//flare/base/internal:test_prod",
],
)

Expand All @@ -211,11 +211,11 @@ cc_library(
"//flare/base:endian",
"//flare/base:logging",
"//flare/base/buffer:zero_copy_stream",
"//flare/base/internal:test_prod",
"//flare/net/hbase/proto:rpc_cc_proto",
"//flare/rpc/protocol:controller",
"//flare/rpc/protocol:message",
"//flare/rpc/protocol:stream_protocol",
"//thirdparty/googletest:gtest_prod",
],
)

Expand All @@ -232,10 +232,10 @@ cc_library(
"//flare/base:endian",
"//flare/base:logging",
"//flare/base/buffer:zero_copy_stream",
"//flare/base/internal:test_prod",
"//flare/net/hbase/proto:rpc_cc_proto",
"//flare/rpc/protocol:message",
"//flare/rpc/protocol:stream_protocol",
"//thirdparty/googletest:gtest_prod",
],
)

Expand Down
7 changes: 3 additions & 4 deletions flare/net/hbase/hbase_client_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

#include <memory>

#include "gtest/gtest_prod.h"

#include "flare/base/internal/test_prod.h"
#include "flare/net/hbase/proto/rpc.pb.h"
#include "flare/rpc/protocol/stream_protocol.h"

Expand All @@ -44,8 +43,8 @@ class HbaseClientProtocol : public StreamProtocol {
Controller* controller) override;

private:
FRIEND_TEST(HbaseProtocol, ClientToServer);
FRIEND_TEST(HbaseProtocol, ServerToClient);
FLARE_FRIEND_TEST(HbaseProtocol, ClientToServer);
FLARE_FRIEND_TEST(HbaseProtocol, ServerToClient);

// TODO(luobogao): It would be better if the framework itself supports
// handshaking. That way we won't need this special flag.
Expand Down
8 changes: 4 additions & 4 deletions flare/net/hbase/hbase_controller_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include <string>

#include "google/protobuf/service.h"
#include "gtest/gtest_prod.h"

#include "flare/base/buffer.h"
#include "flare/base/internal/test_prod.h"
#include "flare/base/internal/time_view.h"
#include "flare/base/net/endpoint.h"
#include "flare/net/hbase/proto/rpc.pb.h"
Expand Down Expand Up @@ -79,9 +79,9 @@ class HbaseControllerCommon : public google::protobuf::RpcController {
void Reset() override;

protected:
FRIEND_TEST(HbaseControllerCommon, RemotePeer);
FRIEND_TEST(HbaseControllerCommon, RequestCellBlock);
FRIEND_TEST(HbaseControllerCommon, ResponseCellBlock);
FLARE_FRIEND_TEST(HbaseControllerCommon, RemotePeer);
FLARE_FRIEND_TEST(HbaseControllerCommon, RequestCellBlock);
FLARE_FRIEND_TEST(HbaseControllerCommon, ResponseCellBlock);
friend struct testing::detail::HbaseControllerMaster;

// Set local & remote peer address.
Expand Down
5 changes: 2 additions & 3 deletions flare/net/hbase/hbase_server_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

#include <string>

#include "gtest/gtest_prod.h"

#include "flare/base/internal/test_prod.h"
#include "flare/net/hbase/hbase_controller_common.h"

namespace flare {
Expand Down Expand Up @@ -48,7 +47,7 @@ class HbaseServerController : public hbase::HbaseControllerCommon {
void Reset() override;

private:
FRIEND_TEST(HbaseServerController, ConnectionHeader);
FLARE_FRIEND_TEST(HbaseServerController, ConnectionHeader);
friend class HbaseService;

// Only pointer (not value) is saved.
Expand Down
6 changes: 3 additions & 3 deletions flare/net/hbase/hbase_server_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <unordered_map>

#include "google/protobuf/service.h"
#include "gtest/gtest_prod.h"

#include "flare/base/internal/test_prod.h"
#include "flare/net/hbase/proto/rpc.pb.h"
#include "flare/rpc/protocol/stream_protocol.h"

Expand Down Expand Up @@ -53,8 +53,8 @@ class HbaseServerProtocol : public StreamProtocol {
MessageCutStatus TryCompleteHandshake(NoncontiguousBuffer* buffer);

private:
FRIEND_TEST(HbaseProtocol, ClientToServer);
FRIEND_TEST(HbaseProtocol, ServerToClient);
FLARE_FRIEND_TEST(HbaseProtocol, ClientToServer);
FLARE_FRIEND_TEST(HbaseProtocol, ServerToClient);

struct ServiceDesc;
struct MethodDesc;
Expand Down
Loading

0 comments on commit 16ae3fa

Please sign in to comment.