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 (https://github.com/google/googletest/commit/
bf66935e07825318ae519675d73d0f3e313b3ec6)
- Aligns with GoogleTest's current approach for preventing test suite
copying, See
https://github.com/google/googletest/commit/
93f08be653c36ddc6943e9513fc14c7292b4d007
- 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 <tchaikov@gmail.com>
if(WITH_TESTS)
option(WITH_SYSTEM_GTEST "require and build with system gtest and gmock" OFF)
if(WITH_SYSTEM_GTEST)
- find_package(GTest REQUIRED)
+ find_package(GTest 1.13.0 REQUIRED)
find_package(GMock REQUIRED)
else()
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
"test_suite_name must not be empty"); \
static_assert(sizeof(GTEST_STRINGIFY_(test_name)) > 1, \
"test_name must not be empty"); \
- class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) : public fixture { \
+ class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
+ : public fixture, private ::testing::internal::GTestNonCopyable { \
public: \
GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() = default; \
~GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() override = default; \
- GTEST_DISALLOW_COPY_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
- test_name)); \
- GTEST_DISALLOW_MOVE_AND_ASSIGN_(GTEST_TEST_CLASS_NAME_(test_suite_name, \
- test_name)); \
\
private: \
boost::asio::awaitable<void> CoTestBody() override; \