Skip to content

Commit 9a49523

Browse files
committed
neorados/test: Simplify copy prevention by using GtestNonCopyable
Updates the test framework to use GoogleTest's simplified copy prevention mechanism by inheriting from `::testing::internal::GtestNonCopyable` instead of custom macros. This change: - Replaces deprecated GTEST_DISALLOW_* macros that were removed in GoogleTest (google/googletest@bf66935) - Aligns with GoogleTest's current approach for preventing test suite copying, See google/googletest@93f08be - Enables updating the GoogleTest submodule to silence CMake warnings - Improves compatibility with recent distro-packaged GoogleTest versions - add the minimal required GTest version when finding this package, this change should have no impact to our packaging. as both deb and rpm packagings are using bundled googletest submodule. and googletest 1.14 has been included by recent stable releases of popular distros, like fedora 41 and ubuntu 24.04. While `GtestNonCopyable` is technically an internal helper, we already use other helpers from the `::testing::internal` namespace, so this change maintains consistency with our existing approach. Signed-off-by: Kefu Chai <[email protected]>
1 parent 21f67af commit 9a49523

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ add_subdirectory(erasure-code)
764764
if(WITH_TESTS)
765765
option(WITH_SYSTEM_GTEST "require and build with system gtest and gmock" OFF)
766766
if(WITH_SYSTEM_GTEST)
767-
find_package(GTest REQUIRED)
767+
find_package(GTest 1.13.0 REQUIRED)
768768
find_package(GMock REQUIRED)
769769
else()
770770
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)

src/test/neorados/common_tests.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,14 +396,11 @@ class NeoRadosECTest : public NeoRadosTestBase {
396396
"test_suite_name must not be empty"); \
397397
static_assert(sizeof(GTEST_STRINGIFY_(test_name)) > 1, \
398398
"test_name must not be empty"); \
399-
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) : public fixture { \
399+
class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
400+
: public fixture, private ::testing::internal::GTestNonCopyable { \
400401
public: \
401402
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() = default; \
402403
~GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() override = default; \
403-
GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
404-
test_name)); \
405-
GTEST_DISALLOW_MOVE_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
406-
test_name)); \
407404
\
408405
private: \
409406
boost::asio::awaitable<void> CoTestBody() override; \

0 commit comments

Comments
 (0)