summaryrefslogtreecommitdiffstats
path: root/googletest
diff options
context:
space:
mode:
authorChris Johnson <chrisjohnsonmail@gmail.com>2023-06-22 17:01:48 (GMT)
committerGitHub <noreply@github.com>2023-06-22 17:01:48 (GMT)
commitb2a2d36f3a28921af8ccbed92c47fbfe8570173c (patch)
treec7a7268259498bd3a4c7137c0889178af3c7c2b4 /googletest
parente3d405f62b61a228e5359208b1fa933e03eadc65 (diff)
parentec4fed93217bc2830959bb8e86798c1d86956949 (diff)
downloadgoogletest-b2a2d36f3a28921af8ccbed92c47fbfe8570173c.zip
googletest-b2a2d36f3a28921af8ccbed92c47fbfe8570173c.tar.gz
googletest-b2a2d36f3a28921af8ccbed92c47fbfe8570173c.tar.bz2
Merge branch 'google:main' into feat/qn9090refs/pull/4301/head
Diffstat (limited to 'googletest')
-rw-r--r--googletest/CMakeLists.txt28
-rw-r--r--googletest/README.md6
-rw-r--r--googletest/cmake/internal_utils.cmake90
-rw-r--r--googletest/include/gtest/gtest.h5
-rw-r--r--googletest/src/gtest-death-test.cc2
-rw-r--r--googletest/src/gtest-internal-inl.h4
-rw-r--r--googletest/src/gtest.cc9
-rw-r--r--googletest/test/googletest-output-test-golden-lin.txt16
-rw-r--r--googletest/test/googletest-output-test_.cc6
-rw-r--r--googletest/test/gtest_unittest.cc2
10 files changed, 70 insertions, 98 deletions
diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt
index 95bfa44..caafa8c 100644
--- a/googletest/CMakeLists.txt
+++ b/googletest/CMakeLists.txt
@@ -46,14 +46,9 @@ endif()
# Project version:
-cmake_minimum_required(VERSION 3.5)
-cmake_policy(SET CMP0048 NEW)
+cmake_minimum_required(VERSION 3.13)
project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
-if (POLICY CMP0063) # Visibility
- cmake_policy(SET CMP0063 NEW)
-endif (POLICY CMP0063)
-
if (COMMAND set_up_hermetic_build)
set_up_hermetic_build()
endif()
@@ -100,12 +95,14 @@ if (INSTALL_GTEST)
set(version_file "${generated_dir}/${cmake_package_name}ConfigVersion.cmake")
write_basic_package_version_file(${version_file} VERSION ${GOOGLETEST_VERSION} COMPATIBILITY AnyNewerVersion)
install(EXPORT ${targets_export_name}
+ COMPONENT "${PROJECT_NAME}"
NAMESPACE ${cmake_package_name}::
DESTINATION ${cmake_files_install_dir})
set(config_file "${generated_dir}/${cmake_package_name}Config.cmake")
configure_package_config_file("${gtest_SOURCE_DIR}/cmake/Config.cmake.in"
"${config_file}" INSTALL_DESTINATION ${cmake_files_install_dir})
install(FILES ${version_file} ${config_file}
+ COMPONENT "${PROJECT_NAME}"
DESTINATION ${cmake_files_install_dir})
endif()
@@ -143,18 +140,13 @@ if(GTEST_HAS_ABSL)
endif()
cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
set_target_properties(gtest_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
-# If the CMake version supports it, attach header directory information
-# to the targets for when we are part of a parent build (ie being pulled
-# in via add_subdirectory() rather than being a standalone build).
-if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
- string(REPLACE ";" "$<SEMICOLON>" dirs "${gtest_build_include_dirs}")
- target_include_directories(gtest SYSTEM INTERFACE
- "$<BUILD_INTERFACE:${dirs}>"
- "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
- target_include_directories(gtest_main SYSTEM INTERFACE
- "$<BUILD_INTERFACE:${dirs}>"
- "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
-endif()
+string(REPLACE ";" "$<SEMICOLON>" dirs "${gtest_build_include_dirs}")
+target_include_directories(gtest SYSTEM INTERFACE
+ "$<BUILD_INTERFACE:${dirs}>"
+ "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
+target_include_directories(gtest_main SYSTEM INTERFACE
+ "$<BUILD_INTERFACE:${dirs}>"
+ "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
if(CMAKE_SYSTEM_NAME MATCHES "QNX")
target_link_libraries(gtest PUBLIC regex)
endif()
diff --git a/googletest/README.md b/googletest/README.md
index 4cad12f..6bbd7f8 100644
--- a/googletest/README.md
+++ b/googletest/README.md
@@ -124,10 +124,10 @@ match the project in which it is included.
#### C++ Standard Version
-An environment that supports C++11 is required in order to successfully build
+An environment that supports C++14 is required in order to successfully build
GoogleTest. One way to ensure this is to specify the standard in the top-level
-project, for example by using the `set(CMAKE_CXX_STANDARD 11)` command along
-with `set(CMAKE_CXX_STANDARD_REQUIRED ON). If this is not feasible, for example
+project, for example by using the `set(CMAKE_CXX_STANDARD 14)` command along
+with `set(CMAKE_CXX_STANDARD_REQUIRED ON)`. If this is not feasible, for example
in a C project using GoogleTest for validation, then it can be specified by
adding it to the options for cmake via the`-DCMAKE_CXX_FLAGS` option.
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index a3fb3ca..64fa340 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -12,14 +12,6 @@
# Test and Google Mock's option() definitions, and thus must be
# called *after* the options have been defined.
-if (POLICY CMP0054)
- cmake_policy(SET CMP0054 NEW)
-endif (POLICY CMP0054)
-
-if (POLICY CMP0069)
- cmake_policy(SET CMP0069 NEW)
-endif (POLICY CMP0069)
-
# Tweaks CMake's default compiler/linker settings to suit Google Test's needs.
#
# This must be a macro(), as inside a function string() can only
@@ -196,23 +188,14 @@ function(cxx_library_with_type name type cxx_flags)
set_target_properties(${name}
PROPERTIES
COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
- if (NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
- target_compile_definitions(${name} INTERFACE
- $<INSTALL_INTERFACE:GTEST_LINKED_AS_SHARED_LIBRARY=1>)
- endif()
+ target_compile_definitions(${name} INTERFACE
+ $<INSTALL_INTERFACE:GTEST_LINKED_AS_SHARED_LIBRARY=1>)
endif()
if (DEFINED GTEST_HAS_PTHREAD)
- if ("${CMAKE_VERSION}" VERSION_LESS "3.1.0")
- set(threads_spec ${CMAKE_THREAD_LIBS_INIT})
- else()
- set(threads_spec Threads::Threads)
- endif()
- target_link_libraries(${name} PUBLIC ${threads_spec})
+ target_link_libraries(${name} PUBLIC Threads::Threads)
endif()
- if (NOT "${CMAKE_VERSION}" VERSION_LESS "3.8")
- target_compile_features(${name} PUBLIC cxx_std_14)
- endif()
+ target_compile_features(${name} PUBLIC cxx_std_14)
endfunction()
########################################################################
@@ -264,22 +247,7 @@ function(cxx_executable name dir libs)
${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
endfunction()
-# CMP0094 policy enables finding a Python executable in the LOCATION order, as
-# specified by the PATH environment variable.
-if (POLICY CMP0094)
- cmake_policy(SET CMP0094 NEW)
-endif()
-
-# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE.
-if ("${CMAKE_VERSION}" VERSION_LESS "3.12.0")
- find_package(PythonInterp)
- set(PYTHONINTERP_FOUND ${PYTHONINTERP_FOUND} CACHE INTERNAL "")
- set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE INTERNAL "")
-else()
- find_package(Python COMPONENTS Interpreter)
- set(PYTHONINTERP_FOUND ${Python_Interpreter_FOUND} CACHE INTERNAL "")
- set(PYTHON_EXECUTABLE ${Python_EXECUTABLE} CACHE INTERNAL "")
-endif()
+find_package(Python3)
# cxx_test_with_flags(name cxx_flags libs srcs...)
#
@@ -305,34 +273,22 @@ endfunction()
# creates a Python test with the given name whose main module is in
# test/name.py. It does nothing if Python is not installed.
function(py_test name)
- if (PYTHONINTERP_FOUND)
- if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 3.1)
- if (CMAKE_CONFIGURATION_TYPES)
- # Multi-configuration build generators as for Visual Studio save
- # output in a subdirectory of CMAKE_CURRENT_BINARY_DIR (Debug,
- # Release etc.), so we have to provide it here.
- add_test(NAME ${name}
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
- --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG> ${ARGN})
- else (CMAKE_CONFIGURATION_TYPES)
- # Single-configuration build generators like Makefile generators
- # don't have subdirs below CMAKE_CURRENT_BINARY_DIR.
- add_test(NAME ${name}
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
- --build_dir=${CMAKE_CURRENT_BINARY_DIR} ${ARGN})
- endif (CMAKE_CONFIGURATION_TYPES)
- else()
- # ${CMAKE_CURRENT_BINARY_DIR} is known at configuration time, so we can
- # directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known
- # only at ctest runtime (by calling ctest -c <Configuration>), so
- # we have to escape $ to delay variable substitution here.
- add_test(NAME ${name}
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
- --build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE} ${ARGN})
- endif()
- # Make the Python import path consistent between Bazel and CMake.
- set_tests_properties(${name} PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_SOURCE_DIR})
- endif(PYTHONINTERP_FOUND)
+ if (NOT Python3_Interpreter_FOUND)
+ return()
+ endif()
+
+ get_cmake_property(is_multi "GENERATOR_IS_MULTI_CONFIG")
+ set(build_dir "${CMAKE_CURRENT_BINARY_DIR}")
+ if (is_multi)
+ set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
+ endif()
+
+ add_test(NAME ${name}
+ COMMAND Python3::Interpreter ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
+ --build_dir=${build_dir} ${ARGN})
+
+ # Make the Python import path consistent between Bazel and CMake.
+ set_tests_properties(${name} PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_SOURCE_DIR})
endfunction()
# install_project(targets...)
@@ -341,10 +297,12 @@ endfunction()
function(install_project)
if(INSTALL_GTEST)
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/"
+ COMPONENT "${PROJECT_NAME}"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
# Install the project targets.
install(TARGETS ${ARGN}
EXPORT ${targets_export_name}
+ COMPONENT "${PROJECT_NAME}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
@@ -356,6 +314,7 @@ function(install_project)
get_target_property(t_pdb_output_directory ${t} PDB_OUTPUT_DIRECTORY)
install(FILES
"${t_pdb_output_directory}/\${CMAKE_INSTALL_CONFIG_NAME}/$<$<CONFIG:Debug>:${t_pdb_name_debug}>$<$<NOT:$<CONFIG:Debug>>:${t_pdb_name}>.pdb"
+ COMPONENT "${PROJECT_NAME}"
DESTINATION ${CMAKE_INSTALL_LIBDIR}
OPTIONAL)
endforeach()
@@ -366,6 +325,7 @@ function(install_project)
configure_file("${PROJECT_SOURCE_DIR}/cmake/${t}.pc.in"
"${configured_pc}" @ONLY)
install(FILES "${configured_pc}"
+ COMPONENT "${PROJECT_NAME}"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endforeach()
endif()
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 8412503..86777c8 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -1055,6 +1055,10 @@ class GTEST_API_ TestEventListeners {
return default_xml_generator_;
}
+ // Controls whether events will be forwarded by the repeater to the
+ // listeners in the list.
+ void SuppressEventForwarding(bool);
+
private:
friend class TestSuite;
friend class TestInfo;
@@ -1084,7 +1088,6 @@ class GTEST_API_ TestEventListeners {
// Controls whether events will be forwarded by the repeater to the
// listeners in the list.
bool EventForwardingEnabled() const;
- void SuppressEventForwarding();
// The actual list of listeners.
internal::TestEventRepeater* repeater_;
diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index 4cf78e7..0eb6e38 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -1128,7 +1128,7 @@ DeathTest::TestRole NoExecDeathTest::AssumeRole() {
LogToStderr();
// Event forwarding to the listeners of event listener API mush be shut
// down in death test subprocesses.
- GetUnitTestImpl()->listeners()->SuppressEventForwarding();
+ GetUnitTestImpl()->listeners()->SuppressEventForwarding(true);
g_in_fast_death_test_child = true;
return EXECUTE_TEST;
} else {
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 5ba557f..be82166 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -672,7 +672,7 @@ class GTEST_API_ UnitTestImpl {
void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc,
internal::TearDownTestSuiteFunc tear_down_tc,
TestInfo* test_info) {
-#ifdef GTEST_HAS_DEATH_TEST
+#ifdef GTEST_HAS_FILE_SYSTEM
// In order to support thread-safe death tests, we need to
// remember the original working directory when the test program
// was first invoked. We cannot do this in RUN_ALL_TESTS(), as
@@ -685,7 +685,7 @@ class GTEST_API_ UnitTestImpl {
GTEST_CHECK_(!original_working_dir_.IsEmpty())
<< "Failed to get the current working directory.";
}
-#endif // GTEST_HAS_DEATH_TEST
+#endif // GTEST_HAS_FILE_SYSTEM
GetTestSuite(test_info->test_suite_name(), test_info->type_param(),
set_up_tc, tear_down_tc)
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index fb7512c..d9fd277 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -3019,7 +3019,8 @@ void TestSuite::Run() {
internal::HandleExceptionsInMethodIfSupported(
this, &TestSuite::RunSetUpTestSuite, "SetUpTestSuite()");
- const bool skip_all = ad_hoc_test_result().Failed();
+ const bool skip_all =
+ ad_hoc_test_result().Failed() || ad_hoc_test_result().Skipped();
start_timestamp_ = internal::GetTimeInMillis();
internal::Timer timer;
@@ -5155,8 +5156,8 @@ bool TestEventListeners::EventForwardingEnabled() const {
return repeater_->forwarding_enabled();
}
-void TestEventListeners::SuppressEventForwarding() {
- repeater_->set_forwarding_enabled(false);
+void TestEventListeners::SuppressEventForwarding(bool suppress) {
+ repeater_->set_forwarding_enabled(!suppress);
}
// class UnitTest
@@ -5634,7 +5635,7 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
// subprocess. Must not be called before InitGoogleTest.
void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
if (internal_run_death_test_flag_ != nullptr)
- listeners()->SuppressEventForwarding();
+ listeners()->SuppressEventForwarding(true);
}
#endif // GTEST_HAS_DEATH_TEST
diff --git a/googletest/test/googletest-output-test-golden-lin.txt b/googletest/test/googletest-output-test-golden-lin.txt
index 1f24fb7..6ddf822 100644
--- a/googletest/test/googletest-output-test-golden-lin.txt
+++ b/googletest/test/googletest-output-test-golden-lin.txt
@@ -12,7 +12,7 @@ Expected equality of these values:
3
Stack trace: (omitted)
-[==========] Running 89 tests from 42 test suites.
+[==========] Running 90 tests from 43 test suites.
[----------] Global test environment set-up.
FooEnvironment::SetUp() called.
BarEnvironment::SetUp() called.
@@ -967,6 +967,15 @@ Stack trace: (omitted)
googletest-output-test_.cc:#: Skipped
[ SKIPPED ] TestSuiteThatFailsToSetUp.ShouldNotRun
+[----------] 1 test from TestSuiteThatSkipsInSetUp
+googletest-output-test_.cc:#: Skipped
+Skip entire test suite
+Stack trace: (omitted)
+
+[ RUN ] TestSuiteThatSkipsInSetUp.ShouldNotRun
+googletest-output-test_.cc:#: Skipped
+
+[ SKIPPED ] TestSuiteThatSkipsInSetUp.ShouldNotRun
[----------] 1 test from PrintingFailingParams/FailingParamTest
[ RUN ] PrintingFailingParams/FailingParamTest.Fails/0
googletest-output-test_.cc:#: Failure
@@ -1043,10 +1052,11 @@ Failed
Expected fatal failure.
Stack trace: (omitted)
-[==========] 89 tests from 42 test suites ran.
+[==========] 90 tests from 43 test suites ran.
[ PASSED ] 31 tests.
-[ SKIPPED ] 1 test, listed below:
+[ SKIPPED ] 2 tests, listed below:
[ SKIPPED ] TestSuiteThatFailsToSetUp.ShouldNotRun
+[ SKIPPED ] TestSuiteThatSkipsInSetUp.ShouldNotRun
[ FAILED ] 57 tests, listed below:
[ FAILED ] NonfatalFailureTest.EscapesStringOperands
[ FAILED ] NonfatalFailureTest.DiffForLongStrings
diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc
index f1facf5..e3560c0 100644
--- a/googletest/test/googletest-output-test_.cc
+++ b/googletest/test/googletest-output-test_.cc
@@ -1007,6 +1007,12 @@ class TestSuiteThatFailsToSetUp : public testing::Test {
};
TEST_F(TestSuiteThatFailsToSetUp, ShouldNotRun) { std::abort(); }
+class TestSuiteThatSkipsInSetUp : public testing::Test {
+ public:
+ static void SetUpTestSuite() { GTEST_SKIP() << "Skip entire test suite"; }
+};
+TEST_F(TestSuiteThatSkipsInSetUp, ShouldNotRun) { std::abort(); }
+
// The main function.
//
// The idea is to use Google Test to run all the tests we have defined (some
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 77d968a..dd049a0 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -173,7 +173,7 @@ class TestEventListenersAccessor {
}
static void SuppressEventForwarding(TestEventListeners* listeners) {
- listeners->SuppressEventForwarding();
+ listeners->SuppressEventForwarding(true);
}
};