aboutsummaryrefslogtreecommitdiff
path: root/googletest
diff options
context:
space:
mode:
Diffstat (limited to 'googletest')
-rw-r--r--googletest/CMakeLists.txt28
-rw-r--r--googletest/cmake/Config.cmake.in4
-rw-r--r--googletest/cmake/internal_utils.cmake40
-rw-r--r--googletest/include/gtest/gtest-printers.h50
-rw-r--r--googletest/include/gtest/gtest.h1
-rw-r--r--googletest/include/gtest/internal/gtest-death-test-internal.h4
-rw-r--r--googletest/include/gtest/internal/gtest-internal.h2
-rw-r--r--googletest/include/gtest/internal/gtest-param-util.h4
-rw-r--r--googletest/include/gtest/internal/gtest-port.h23
-rw-r--r--googletest/src/gtest-port.cc15
-rw-r--r--googletest/src/gtest.cc26
-rw-r--r--googletest/test/googletest-output-test-golden-lin.txt1
-rw-r--r--googletest/test/googletest-port-test.cc4
-rwxr-xr-xgoogletest/test/gtest_xml_output_unittest.py15
14 files changed, 130 insertions, 87 deletions
diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt
index caafa8c7..dce6a7c9 100644
--- a/googletest/CMakeLists.txt
+++ b/googletest/CMakeLists.txt
@@ -5,7 +5,7 @@
# CMake build script for Google Test.
#
# To run the tests for Google Test itself on Linux, use 'make test' or
-# ctest. You can select which tests to run using 'ctest -R regex'.
+# ctest. You can select which tests to run using 'ctest -R regex'.
# For more options, run 'ctest --help'.
# When other libraries are using a shared version of runtime libraries,
@@ -35,7 +35,7 @@ endif()
########################################################################
#
-# Project-wide settings
+# Project-wide settings.
# Name of the project.
#
@@ -44,7 +44,7 @@ endif()
# ${gtest_BINARY_DIR}.
# Language "C" is required for find_package(Threads).
-# Project version:
+# Project version.
cmake_minimum_required(VERSION 3.13)
project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
@@ -53,7 +53,7 @@ if (COMMAND set_up_hermetic_build)
set_up_hermetic_build()
endif()
-# These commands only run if this is the main project
+# These commands only run if this is the main project.
if(CMAKE_PROJECT_NAME STREQUAL "gtest" OR CMAKE_PROJECT_NAME STREQUAL "googletest-distribution")
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
@@ -83,7 +83,7 @@ include(cmake/internal_utils.cmake)
config_compiler_and_linker() # Defined in internal_utils.cmake.
# Needed to set the namespace for both the export targets and the
-# alias libraries
+# alias libraries.
set(cmake_package_name GTest CACHE INTERNAL "")
# Create the CMake package file descriptors.
@@ -114,10 +114,10 @@ include_directories(${gtest_build_include_dirs})
########################################################################
#
-# Defines the gtest & gtest_main libraries. User tests should link
+# Defines the gtest & gtest_main libraries. User tests should link
# with one of them.
-# Google Test libraries. We build them using more strict warnings than what
+# Google Test libraries. We build them using more strict warnings than what
# are used for other targets, to ensure that gtest can be compiled by a user
# aggressive about warnings.
cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
@@ -147,22 +147,22 @@ target_include_directories(gtest SYSTEM INTERFACE
target_include_directories(gtest_main SYSTEM INTERFACE
"$<BUILD_INTERFACE:${dirs}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
-if(CMAKE_SYSTEM_NAME MATCHES "QNX")
+if(CMAKE_SYSTEM_NAME MATCHES "QNX" AND CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL 7.1)
target_link_libraries(gtest PUBLIC regex)
endif()
target_link_libraries(gtest_main PUBLIC gtest)
########################################################################
#
-# Install rules
+# Install rules.
install_project(gtest gtest_main)
########################################################################
#
# Samples on how to link user tests with gtest or gtest_main.
#
-# They are not built by default. To build them, set the
-# gtest_build_samples option to ON. You can do it by running ccmake
+# They are not built by default. To build them, set the
+# gtest_build_samples option to ON. You can do it by running ccmake
# or specifying the -Dgtest_build_samples=ON flag when running cmake.
if (gtest_build_samples)
@@ -185,8 +185,8 @@ endif()
# You can skip this section if you aren't interested in testing
# Google Test itself.
#
-# The tests are not built by default. To build them, set the
-# gtest_build_tests option to ON. You can do it by running ccmake
+# The tests are not built by default. To build them, set the
+# gtest_build_tests option to ON. You can do it by running ccmake
# or specifying the -Dgtest_build_tests=ON flag when running cmake.
if (gtest_build_tests)
@@ -268,7 +268,7 @@ if (gtest_build_tests)
py_test(gtest_skip_environment_check_output_test)
# Visual Studio .NET 2003 does not support STL with exceptions disabled.
- if (NOT MSVC OR MSVC_VERSION GREATER 1310) # 1310 is Visual Studio .NET 2003
+ if (NOT MSVC OR MSVC_VERSION GREATER 1310) # 1310 is Visual Studio .NET 2003
cxx_executable_with_flags(
googletest-catch-exceptions-no-ex-test_
"${cxx_no_exception}"
diff --git a/googletest/cmake/Config.cmake.in b/googletest/cmake/Config.cmake.in
index 12be4498..3f706612 100644
--- a/googletest/cmake/Config.cmake.in
+++ b/googletest/cmake/Config.cmake.in
@@ -4,6 +4,10 @@ if (@GTEST_HAS_PTHREAD@)
set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@)
find_dependency(Threads)
endif()
+if (@GTEST_HAS_ABSL@)
+ find_dependency(absl)
+ find_dependency(re2)
+endif()
include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
check_required_components("@project_name@")
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index d4f67f43..580ac1cb 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -29,7 +29,7 @@ macro(fix_default_compiler_settings_)
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if (NOT BUILD_SHARED_LIBS AND NOT gtest_force_shared_crt)
# When Google Test is built as a shared library, it should also use
- # shared runtime libraries. Otherwise, it may end up with multiple
+ # shared runtime libraries. Otherwise, it may end up with multiple
# copies of runtime library data in different modules, resulting in
# hard-to-find crashes. When it is built as a static library, it is
# preferable to use CRT as static libraries, as we don't have to rely
@@ -55,11 +55,11 @@ macro(fix_default_compiler_settings_)
endmacro()
# Defines the compiler/linker flags used to build Google Test and
-# Google Mock. You can tweak these definitions to suit your need. A
+# Google Mock. You can tweak these definitions to suit your need. A
# variable's value is empty before it's explicitly assigned to.
macro(config_compiler_and_linker)
# Note: pthreads on MinGW is not supported, even if available
- # instead, we use windows threading primitives
+ # instead, we use windows threading primitives.
unset(GTEST_HAS_PTHREAD)
if (NOT gtest_disable_pthreads AND NOT MINGW)
# Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.
@@ -79,7 +79,7 @@ macro(config_compiler_and_linker)
set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
set(cxx_no_exception_flags "-EHs-c- -D_HAS_EXCEPTIONS=0")
set(cxx_no_rtti_flags "-GR-")
- # Suppress "unreachable code" warning
+ # Suppress "unreachable code" warning,
# https://stackoverflow.com/questions/3232669 explains the issue.
set(cxx_base_flags "${cxx_base_flags} -wd4702")
# Ensure MSVC treats source files as UTF-8 encoded.
@@ -110,7 +110,7 @@ macro(config_compiler_and_linker)
set(cxx_exception_flags "-fexceptions")
set(cxx_no_exception_flags "-fno-exceptions")
# Until version 4.3.2, GCC doesn't define a macro to indicate
- # whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
+ # whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
# explicitly.
set(cxx_no_rtti_flags "-fno-rtti -DGTEST_HAS_RTTI=0")
set(cxx_strict_flags
@@ -127,7 +127,7 @@ macro(config_compiler_and_linker)
set(cxx_exception_flags "-qeh")
set(cxx_no_exception_flags "-qnoeh")
# Until version 9.0, Visual Age doesn't define a macro to indicate
- # whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
+ # whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
# explicitly.
set(cxx_no_rtti_flags "-qnortti -DGTEST_HAS_RTTI=0")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "HP")
@@ -157,7 +157,7 @@ macro(config_compiler_and_linker)
set(cxx_strict "${cxx_default} ${cxx_strict_flags}")
endmacro()
-# Defines the gtest & gtest_main libraries. User tests should link
+# Defines the gtest & gtest_main libraries. User tests should link
# with one of them.
function(cxx_library_with_type name type cxx_flags)
# type can be either STATIC or SHARED to denote a static or shared library.
@@ -167,7 +167,7 @@ function(cxx_library_with_type name type cxx_flags)
set_target_properties(${name}
PROPERTIES
COMPILE_FLAGS "${cxx_flags}")
- # Set the output directory for build artifacts
+ # Set the output directory for build artifacts.
set_target_properties(${name}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
@@ -175,7 +175,7 @@ function(cxx_library_with_type name type cxx_flags)
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
- # make PDBs match library name
+ # Make PDBs match library name.
get_target_property(pdb_debug_postfix ${name} DEBUG_POSTFIX)
set_target_properties(${name}
PROPERTIES
@@ -212,7 +212,7 @@ endfunction()
# cxx_executable_with_flags(name cxx_flags libs srcs...)
#
-# creates a named C++ executable that depends on the given libraries and
+# Creates a named C++ executable that depends on the given libraries and
# is built from the given source files with the given compiler flags.
function(cxx_executable_with_flags name cxx_flags libs)
add_executable(${name} ${ARGN})
@@ -239,19 +239,21 @@ endfunction()
# cxx_executable(name dir lib srcs...)
#
-# creates a named target that depends on the given libs and is built
-# from the given source files. dir/name.cc is implicitly included in
+# Creates a named target that depends on the given libs and is built
+# from the given source files. dir/name.cc is implicitly included in
# the source file list.
function(cxx_executable name dir libs)
cxx_executable_with_flags(
${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
endfunction()
-find_package(Python3)
+if(gtest_build_tests)
+ find_package(Python3)
+endif()
# cxx_test_with_flags(name cxx_flags libs srcs...)
#
-# creates a named C++ test that depends on the given libs and is built
+# Creates a named C++ test that depends on the given libs and is built
# from the given source files with the given compiler flags.
function(cxx_test_with_flags name cxx_flags libs)
cxx_executable_with_flags(${name} "${cxx_flags}" "${libs}" ${ARGN})
@@ -260,8 +262,8 @@ endfunction()
# cxx_test(name libs srcs...)
#
-# creates a named test target that depends on the given libs and is
-# built from the given source files. Unlike cxx_test_with_flags,
+# Creates a named test target that depends on the given libs and is
+# built from the given source files. Unlike cxx_test_with_flags,
# test/name.cc is already implicitly included in the source file list.
function(cxx_test name libs)
cxx_test_with_flags("${name}" "${cxx_default}" "${libs}"
@@ -270,8 +272,8 @@ endfunction()
# py_test(name)
#
-# creates a Python test with the given name whose main module is in
-# test/name.py. It does nothing if Python is not installed.
+# 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 (NOT Python3_Interpreter_FOUND)
return()
@@ -307,7 +309,7 @@ function(install_project)
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
- # Install PDBs
+ # Install PDBs.
foreach(t ${ARGN})
get_target_property(t_pdb_name ${t} COMPILE_PDB_NAME)
get_target_property(t_pdb_name_debug ${t} COMPILE_PDB_NAME_DEBUG)
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 59286815..fe82fa5d 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -124,7 +124,7 @@
#if GTEST_INTERNAL_HAS_STD_SPAN
#include <span> // NOLINT
-#endif // GTEST_INTERNAL_HAS_STD_SPAN
+#endif // GTEST_INTERNAL_HAS_STD_SPAN
namespace testing {
@@ -251,8 +251,8 @@ struct StreamPrinter {
// ADL (possibly involving implicit conversions).
// (Use SFINAE via return type, because it seems GCC < 12 doesn't handle name
// lookup properly when we do it in the template parameter list.)
- static auto PrintValue(const T& value, ::std::ostream* os)
- -> decltype((void)(*os << value)) {
+ static auto PrintValue(const T& value,
+ ::std::ostream* os) -> decltype((void)(*os << value)) {
// Call streaming operator found by ADL, possibly with implicit conversions
// of the arguments.
*os << value;
@@ -562,50 +562,56 @@ int AppropriateResolution(FloatType val) {
int full = std::numeric_limits<FloatType>::max_digits10;
if (val < 0) val = -val;
- // Android local change: do not warn about exact float comparison.
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal"
#endif
if (val < 1000000) {
FloatType mulfor6 = 1e10;
- if (val >= 100000.0) { // 100,000 to 999,999
+ // Without these static casts, the template instantiation for float would
+ // fail to compile when -Wdouble-promotion is enabled, as the arithmetic and
+ // comparison logic would promote floats to doubles.
+ if (val >= static_cast<FloatType>(100000.0)) { // 100,000 to 999,999
mulfor6 = 1.0;
- } else if (val >= 10000.0) {
+ } else if (val >= static_cast<FloatType>(10000.0)) {
mulfor6 = 1e1;
- } else if (val >= 1000.0) {
+ } else if (val >= static_cast<FloatType>(1000.0)) {
mulfor6 = 1e2;
- } else if (val >= 100.0) {
+ } else if (val >= static_cast<FloatType>(100.0)) {
mulfor6 = 1e3;
- } else if (val >= 10.0) {
+ } else if (val >= static_cast<FloatType>(10.0)) {
mulfor6 = 1e4;
- } else if (val >= 1.0) {
+ } else if (val >= static_cast<FloatType>(1.0)) {
mulfor6 = 1e5;
- } else if (val >= 0.1) {
+ } else if (val >= static_cast<FloatType>(0.1)) {
mulfor6 = 1e6;
- } else if (val >= 0.01) {
+ } else if (val >= static_cast<FloatType>(0.01)) {
mulfor6 = 1e7;
- } else if (val >= 0.001) {
+ } else if (val >= static_cast<FloatType>(0.001)) {
mulfor6 = 1e8;
- } else if (val >= 0.0001) {
+ } else if (val >= static_cast<FloatType>(0.0001)) {
mulfor6 = 1e9;
}
- if (static_cast<FloatType>(static_cast<int32_t>(val * mulfor6 + 0.5)) /
+ if (static_cast<FloatType>(static_cast<int32_t>(
+ val * mulfor6 + (static_cast<FloatType>(0.5)))) /
mulfor6 ==
val)
return 6;
- } else if (val < 1e10) {
- FloatType divfor6 = 1.0;
- if (val >= 1e9) { // 1,000,000,000 to 9,999,999,999
+ } else if (val < static_cast<FloatType>(1e10)) {
+ FloatType divfor6 = static_cast<FloatType>(1.0);
+ if (val >= static_cast<FloatType>(1e9)) { // 1,000,000,000 to 9,999,999,999
divfor6 = 10000;
- } else if (val >= 1e8) { // 100,000,000 to 999,999,999
+ } else if (val >=
+ static_cast<FloatType>(1e8)) { // 100,000,000 to 999,999,999
divfor6 = 1000;
- } else if (val >= 1e7) { // 10,000,000 to 99,999,999
+ } else if (val >=
+ static_cast<FloatType>(1e7)) { // 10,000,000 to 99,999,999
divfor6 = 100;
- } else if (val >= 1e6) { // 1,000,000 to 9,999,999
+ } else if (val >= static_cast<FloatType>(1e6)) { // 1,000,000 to 9,999,999
divfor6 = 10;
}
- if (static_cast<FloatType>(static_cast<int32_t>(val / divfor6 + 0.5)) *
+ if (static_cast<FloatType>(static_cast<int32_t>(
+ val / divfor6 + (static_cast<FloatType>(0.5)))) *
divfor6 ==
val)
return 6;
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index a932e686..45400fd0 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -1751,6 +1751,7 @@ class TestWithParam : public Test, public WithParamInterface<T> {};
// generic name and clashes with some other libraries.
#if !(defined(GTEST_DONT_DEFINE_FAIL) && GTEST_DONT_DEFINE_FAIL)
#define FAIL() GTEST_FAIL()
+#define FAIL_AT(file, line) GTEST_FAIL_AT(file, line)
#endif
// Generates a success with a generic message.
diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h
index 8e9c988b..61536d65 100644
--- a/googletest/include/gtest/internal/gtest-death-test-internal.h
+++ b/googletest/include/gtest/internal/gtest-death-test-internal.h
@@ -52,9 +52,7 @@ GTEST_DECLARE_string_(internal_run_death_test);
namespace testing {
namespace internal {
-// Names of the flags (needed for parsing Google Test flags).
-const char kDeathTestStyleFlag[] = "death_test_style";
-const char kDeathTestUseFork[] = "death_test_use_fork";
+// Name of the flag (needed for parsing Google Test flag).
const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
#ifdef GTEST_HAS_DEATH_TEST
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 4f077fcf..806b0862 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -555,7 +555,7 @@ struct SuiteApiResolver : T {
// type_param: the name of the test's type parameter, or NULL if
// this is not a typed or a type-parameterized test.
// value_param: text representation of the test's value parameter,
-// or NULL if this is not a type-parameterized test.
+// or NULL if this is not a value-parameterized test.
// code_location: code location where the test is defined
// fixture_class_id: ID of the test fixture class
// set_up_tc: pointer to the function that sets up the test suite
diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h
index dd39e98a..b04f7020 100644
--- a/googletest/include/gtest/internal/gtest-param-util.h
+++ b/googletest/include/gtest/internal/gtest-param-util.h
@@ -584,8 +584,8 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
GTEST_CHECK_(IsValidParamName(param_name))
<< "Parameterized test name '" << param_name
- << "' is invalid (contains spaces, dashes, underscores, or "
- "non-alphanumeric characters), in "
+ << "' is invalid (contains spaces, dashes, or any "
+ "non-alphanumeric characters other than underscores), in "
<< file << " line " << line << "" << std::endl;
GTEST_CHECK_(test_param_names.count(param_name) == 0)
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index daaaa74a..2adf0627 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -338,9 +338,10 @@
#define GTEST_HAS_NOTIFICATION_ 0
#endif
-#ifdef GTEST_HAS_ABSL
-#include "absl/flags/declare.h"
+#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
+#define GTEST_INTERNAL_HAS_ABSL_FLAGS // Used only in this file.
#include "absl/flags/flag.h"
+#include "absl/flags/declare.h"
#include "absl/flags/reflection.h"
#endif
@@ -2017,7 +2018,9 @@ inline std::string StripTrailingSpaces(std::string str) {
namespace posix {
// File system porting.
-#if GTEST_HAS_FILE_SYSTEM
+// Note: Not every I/O-related function is related to file systems, so don't
+// just disable all of them here. For example, fileno() and isatty(), etc. must
+// always be available in order to detect if a pipe points to a terminal.
#ifdef GTEST_OS_WINDOWS
typedef struct _stat StatStruct;
@@ -2028,27 +2031,32 @@ inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }
// time and thus not defined there.
#else
inline int FileNo(FILE* file) { return _fileno(file); }
+#if GTEST_HAS_FILE_SYSTEM
inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
inline int RmDir(const char* dir) { return _rmdir(dir); }
inline bool IsDir(const StatStruct& st) { return (_S_IFDIR & st.st_mode) != 0; }
+#endif
#endif // GTEST_OS_WINDOWS_MOBILE
#elif defined(GTEST_OS_ESP8266)
typedef struct stat StatStruct;
inline int FileNo(FILE* file) { return fileno(file); }
+#if GTEST_HAS_FILE_SYSTEM
inline int Stat(const char* path, StatStruct* buf) {
// stat function not implemented on ESP8266
return 0;
}
inline int RmDir(const char* dir) { return rmdir(dir); }
inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
+#endif
#else
typedef struct stat StatStruct;
inline int FileNo(FILE* file) { return fileno(file); }
+#if GTEST_HAS_FILE_SYSTEM
inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
#ifdef GTEST_OS_QURT
// QuRT doesn't support any directory functions, including rmdir
@@ -2057,9 +2065,9 @@ inline int RmDir(const char*) { return 0; }
inline int RmDir(const char* dir) { return rmdir(dir); }
#endif
inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
+#endif
#endif // GTEST_OS_WINDOWS
-#endif // GTEST_HAS_FILE_SYSTEM
// Other functions with a different name on Windows.
@@ -2257,7 +2265,7 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
#endif // !defined(GTEST_FLAG)
// Pick a command line flags implementation.
-#ifdef GTEST_HAS_ABSL
+#ifdef GTEST_INTERNAL_HAS_ABSL_FLAGS
// Macros for defining flags.
#define GTEST_DEFINE_bool_(name, default_val, doc) \
@@ -2282,7 +2290,8 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
(void)(::absl::SetFlag(&GTEST_FLAG(name), value))
#define GTEST_USE_OWN_FLAGFILE_FLAG_ 0
-#else // GTEST_HAS_ABSL
+#undef GTEST_INTERNAL_HAS_ABSL_FLAGS
+#else // ndef GTEST_INTERNAL_HAS_ABSL_FLAGS
// Macros for defining flags.
#define GTEST_DEFINE_bool_(name, default_val, doc) \
@@ -2324,7 +2333,7 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.
#define GTEST_FLAG_SET(name, value) (void)(::testing::GTEST_FLAG(name) = value)
#define GTEST_USE_OWN_FLAGFILE_FLAG_ 1
-#endif // GTEST_HAS_ABSL
+#endif // GTEST_INTERNAL_HAS_ABSL_FLAGS
// Thread annotations
#if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index e9d12d92..3bb7dd45 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -697,13 +697,24 @@ bool RE::PartialMatch(const char* str, const RE& re) {
void RE::Init(const char* regex) {
pattern_ = regex;
+ // NetBSD (and Android, which takes its regex implemntation from NetBSD) does
+ // not include the GNU regex extensions (such as Perl style character classes
+ // like \w) in REG_EXTENDED. REG_EXTENDED is only specified to include the
+ // [[:alpha:]] style character classes. Enable REG_GNU wherever it is defined
+ // so users can use those extensions.
+#if defined(REG_GNU)
+ constexpr int reg_flags = REG_EXTENDED | REG_GNU;
+#else
+ constexpr int reg_flags = REG_EXTENDED;
+#endif
+
// Reserves enough bytes to hold the regular expression used for a
// full match.
const size_t full_regex_len = strlen(regex) + 10;
char* const full_pattern = new char[full_regex_len];
snprintf(full_pattern, full_regex_len, "^(%s)$", regex);
- is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0;
+ is_valid_ = regcomp(&full_regex_, full_pattern, reg_flags) == 0;
// We want to call regcomp(&partial_regex_, ...) even if the
// previous expression returns false. Otherwise partial_regex_ may
// not be properly initialized can may cause trouble when it's
@@ -714,7 +725,7 @@ void RE::Init(const char* regex) {
// regex. We change it to an equivalent form "()" to be safe.
if (is_valid_) {
const char* const partial_regex = (*regex == '\0') ? "()" : regex;
- is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0;
+ is_valid_ = regcomp(&partial_regex_, partial_regex, reg_flags) == 0;
}
EXPECT_TRUE(is_valid_)
<< "Regular expression \"" << regex
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index d22822eb..34d3e301 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -43,6 +43,7 @@
#include <algorithm>
#include <chrono> // NOLINT
#include <cmath>
+#include <csignal> // NOLINT: raise(3) is used on some platforms
#include <cstdint>
#include <cstdlib>
#include <cstring>
@@ -161,6 +162,10 @@
#define GTEST_HAS_BUILTIN(x) 0
#endif // defined(__has_builtin)
+#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
+#define GTEST_HAS_ABSL_FLAGS
+#endif
+
namespace testing {
using internal::CountIf;
@@ -458,7 +463,12 @@ void AssertHelper::operator=(const Message& message) const {
UnitTest::GetInstance()->AddTestPartResult(
data_->type, data_->file, data_->line,
AppendUserMessage(data_->message, message),
- UnitTest::GetInstance()->impl()->CurrentOsStackTraceExceptTop(1)
+ // Suppress emission of the stack trace for GTEST_SKIP() since skipping is
+ // an intentional act by the developer rather than a failure requiring
+ // investigation.
+ data_->type != TestPartResult::kSkip
+ ? UnitTest::GetInstance()->impl()->CurrentOsStackTraceExceptTop(1)
+ : ""
// Skips the stack frame for this function itself.
); // NOLINT
}
@@ -3282,11 +3292,9 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
va_start(args, fmt);
static const bool in_color_mode =
-#if GTEST_HAS_FILE_SYSTEM
+ // We don't condition this on GTEST_HAS_FILE_SYSTEM because we still need
+ // to be able to detect terminal I/O regardless.
ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);
-#else
- false;
-#endif // GTEST_HAS_FILE_SYSTEM
const bool use_color = in_color_mode && (color != GTestColor::kDefault);
@@ -6203,8 +6211,8 @@ void UnitTestImpl::ListTestsMatchingFilter() {
#if GTEST_HAS_FILE_SYSTEM
const std::string& output_format = UnitTestOptions::GetOutputFormat();
if (output_format == "xml" || output_format == "json") {
- FILE* fileout = OpenFileForWriting(
- UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
+ FILE* fileout =
+ OpenFileForWriting(UnitTestOptions::GetAbsolutePathToOutputFile());
std::stringstream stream;
if (output_format == "xml") {
XmlUnitTestResultPrinter(
@@ -6685,7 +6693,7 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
// remain in place. Unrecognized flags are not reported and do not cause the
// program to exit.
void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
-#ifdef GTEST_HAS_ABSL
+#ifdef GTEST_HAS_ABSL_FLAGS
if (*argc <= 0) return;
std::vector<char*> positional_args;
@@ -6771,11 +6779,13 @@ void InitGoogleTestImpl(int* argc, CharType** argv) {
#ifdef GTEST_HAS_ABSL
absl::InitializeSymbolizer(g_argvs[0].c_str());
+#ifdef GTEST_HAS_ABSL_FLAGS
// When using the Abseil Flags library, set the program usage message to the
// help message, but remove the color-encoding from the message first.
absl::SetProgramUsageMessage(absl::StrReplaceAll(
kColorEncodedHelpMessage,
{{"@D", ""}, {"@R", ""}, {"@G", ""}, {"@Y", ""}, {"@@", "@"}}));
+#endif // GTEST_HAS_ABSL_FLAGS
#endif // GTEST_HAS_ABSL
ParseGoogleTestFlagsOnly(argc, argv);
diff --git a/googletest/test/googletest-output-test-golden-lin.txt b/googletest/test/googletest-output-test-golden-lin.txt
index 6ddf822f..e06856a2 100644
--- a/googletest/test/googletest-output-test-golden-lin.txt
+++ b/googletest/test/googletest-output-test-golden-lin.txt
@@ -970,7 +970,6 @@ googletest-output-test_.cc:#: Skipped
[----------] 1 test from TestSuiteThatSkipsInSetUp
googletest-output-test_.cc:#: Skipped
Skip entire test suite
-Stack trace: (omitted)
[ RUN ] TestSuiteThatSkipsInSetUp.ShouldNotRun
googletest-output-test_.cc:#: Skipped
diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc
index 8d210260..9f05a019 100644
--- a/googletest/test/googletest-port-test.cc
+++ b/googletest/test/googletest-port-test.cc
@@ -418,8 +418,8 @@ TYPED_TEST(RETest, ImplicitConstructorWorks) {
const RE simple(TypeParam("hello"));
EXPECT_STREQ("hello", simple.pattern());
- const RE normal(TypeParam(".*([[:alnum:]_]+)"));
- EXPECT_STREQ(".*([[:alnum:]_]+)", normal.pattern());
+ const RE normal(TypeParam(".*(\\w+)"));
+ EXPECT_STREQ(".*(\\w+)", normal.pattern());
}
// Tests that RE's constructors reject invalid regular expressions.
diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py
index 422569e4..c3fea2c0 100755
--- a/googletest/test/gtest_xml_output_unittest.py
+++ b/googletest/test/gtest_xml_output_unittest.py
@@ -112,20 +112,23 @@ Invalid characters in brackets []%(stack)s]]></failure>
</testsuite>
<testsuite name="SkippedTest" tests="3" failures="1" disabled="0" skipped="2" errors="0" time="*" timestamp="*">
<testcase name="Skipped" status="run" file="gtest_xml_output_unittest_.cc" line="75" result="skipped" time="*" timestamp="*" classname="SkippedTest">
- <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
-%(stack)s]]></skipped>
+ <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;&#x0A;"><![CDATA[gtest_xml_output_unittest_.cc:*
+
+]]></skipped>
</testcase>
<testcase name="SkippedWithMessage" file="gtest_xml_output_unittest_.cc" line="79" status="run" result="skipped" time="*" timestamp="*" classname="SkippedTest">
- <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;It is good practice to tell why you skip a test.%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
-It is good practice to tell why you skip a test.%(stack)s]]></skipped>
+ <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;It is good practice to tell why you skip a test.&#x0A;"><![CDATA[gtest_xml_output_unittest_.cc:*
+It is good practice to tell why you skip a test.
+]]></skipped>
</testcase>
<testcase name="SkippedAfterFailure" file="gtest_xml_output_unittest_.cc" line="83" status="run" result="completed" time="*" timestamp="*" classname="SkippedTest">
<failure message="gtest_xml_output_unittest_.cc:*&#x0A;Expected equality of these values:&#x0A; 1&#x0A; 2%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Expected equality of these values:
1
2%(stack)s]]></failure>
- <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;It is good practice to tell why you skip a test.%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
-It is good practice to tell why you skip a test.%(stack)s]]></skipped>
+ <skipped message="gtest_xml_output_unittest_.cc:*&#x0A;It is good practice to tell why you skip a test.&#x0A;"><![CDATA[gtest_xml_output_unittest_.cc:*
+It is good practice to tell why you skip a test.
+]]></skipped>
</testcase>
</testsuite>