Merge pull request #4158 from VuPhamVan:main
PiperOrigin-RevId: 512959074
Change-Id: Ifbc63077aad573d4496a837f2f57584192573820
diff --git a/WORKSPACE b/WORKSPACE
index 0f10a6a..cb5f83f 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,10 +3,10 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
- name = "com_google_absl", # 2023-01-10T21:08:25Z
- sha256 = "f9a4e749f42c386a32a90fddf0e2913ed408d10c42f7f33ccf4c59ac4f0d1d05",
- strip_prefix = "abseil-cpp-52835439ca90d86b27bf8cd1708296e95604d724",
- urls = ["https://github.com/abseil/abseil-cpp/archive/52835439ca90d86b27bf8cd1708296e95604d724.zip"],
+ name = "com_google_absl", # 2023-02-27T15:50:25Z
+ sha256 = "baf8e734ac3ce213a889ce7c248b981ee1730e2093e32808e0f0a910dc985f76",
+ strip_prefix = "abseil-cpp-0c1114c4fb83c844c7fd74708338cca1d3d9b0dc",
+ urls = ["https://github.com/abseil/abseil-cpp/archive/0c1114c4fb83c844c7fd74708338cca1d3d9b0dc.zip"],
)
# Note this must use a commit from the `abseil` branch of the RE2 project.
diff --git a/ci/linux-presubmit.sh b/ci/linux-presubmit.sh
index 9e15d9a..626989d 100644
--- a/ci/linux-presubmit.sh
+++ b/ci/linux-presubmit.sh
@@ -31,8 +31,8 @@
set -euox pipefail
-readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20220217"
-readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20220621"
+readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20230217"
+readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20230120"
if [[ -z ${GTEST_ROOT:-} ]]; then
GTEST_ROOT="$(realpath $(dirname ${0})/..)"
diff --git a/docs/advanced.md b/docs/advanced.md
index 7d15dfd..6b4c3f0 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -562,7 +562,7 @@
particular style of death tests by setting the flag programmatically:
```c++
-GTEST_FLAG_SET(death_test_style, "threadsafe")
+GTEST_FLAG_SET(death_test_style, "threadsafe");
```
You can do this in `main()` to set the style for all death tests in the binary,
diff --git a/docs/primer.md b/docs/primer.md
index 2ffbf53..d559fe8 100644
--- a/docs/primer.md
+++ b/docs/primer.md
@@ -45,23 +45,23 @@
## Beware of the nomenclature
{: .callout .note}
-_Note:_ There might be some confusion arising from different definitions of the
-terms _Test_, _Test Case_ and _Test Suite_, so beware of misunderstanding these.
+*Note:* There might be some confusion arising from different definitions of the
+terms *Test*, *Test Case* and *Test Suite*, so beware of misunderstanding these.
-Historically, googletest started to use the term _Test Case_ for grouping
+Historically, googletest started to use the term *Test Case* for grouping
related tests, whereas current publications, including International Software
Testing Qualifications Board ([ISTQB](http://www.istqb.org/)) materials and
various textbooks on software quality, use the term
-_[Test Suite][istqb test suite]_ for this.
+*[Test Suite][istqb test suite]* for this.
-The related term _Test_, as it is used in googletest, corresponds to the term
-_[Test Case][istqb test case]_ of ISTQB and others.
+The related term *Test*, as it is used in googletest, corresponds to the term
+*[Test Case][istqb test case]* of ISTQB and others.
-The term _Test_ is commonly of broad enough sense, including ISTQB's definition
-of _Test Case_, so it's not much of a problem here. But the term _Test Case_ as
+The term *Test* is commonly of broad enough sense, including ISTQB's definition
+of *Test Case*, so it's not much of a problem here. But the term *Test Case* as
was used in Google Test is of contradictory sense and thus confusing.
-googletest recently started replacing the term _Test Case_ with _Test Suite_.
+googletest recently started replacing the term *Test Case* with *Test Suite*.
The preferred API is *TestSuite*. The older TestCase API is being slowly
deprecated and refactored away.
@@ -227,14 +227,14 @@
access objects and subroutines in the test fixture:
```c++
-TEST_F(TestFixtureName, TestName) {
+TEST_F(TestFixtureClassName, TestName) {
... test body ...
}
```
-Like `TEST()`, the first argument is the test suite name, but for `TEST_F()`
-this must be the name of the test fixture class. You've probably guessed: `_F`
-is for fixture.
+Unlike `TEST()`, in `TEST_F()` the first argument must be the name of the test
+fixture class. (`_F` stands for "Fixture"). No test suite name is specified for
+this macro.
Unfortunately, the C++ macro system does not allow us to create a single macro
that can handle both types of tests. Using the wrong macro causes a compiler
@@ -381,7 +381,7 @@
## Writing the main() Function
-Most users should _not_ need to write their own `main` function and instead link
+Most users should *not* need to write their own `main` function and instead link
with `gtest_main` (as opposed to with `gtest`), which defines a suitable entry
point. See the end of this section for details. The remainder of this section
should only apply when you need to do something custom before the tests run that
@@ -476,7 +476,7 @@
* Google Test is designed to be thread-safe. The implementation is thread-safe
on systems where the `pthreads` library is available. It is currently
- _unsafe_ to use Google Test assertions from two threads concurrently on
+ *unsafe* to use Google Test assertions from two threads concurrently on
other systems (e.g. Windows). In most tests this is not an issue as usually
the assertions are done in the main thread. If you want to help, you can
volunteer to implement the necessary synchronization primitives in
diff --git a/docs/reference/testing.md b/docs/reference/testing.md
index 62cdcc1..877dfa3 100644
--- a/docs/reference/testing.md
+++ b/docs/reference/testing.md
@@ -110,6 +110,7 @@
| `Bool()` | Yields sequence `{false, true}`. |
| `Combine(g1, g2, ..., gN)` | Yields as `std::tuple` *n*-tuples all combinations (Cartesian product) of the values generated by the given *n* generators `g1`, `g2`, ..., `gN`. |
| `ConvertGenerator<T>(g)` | Yields values generated by generator `g`, `static_cast` to `T`. |
+
The optional last argument *`name_generator`* is a function or functor that
generates custom test name suffixes based on the test parameters. The function
must accept an argument of type
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 7d7e77c..739d545 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -306,9 +306,10 @@
void PrintWithFallback(const T& value, ::std::ostream* os) {
using Printer = typename FindFirstPrinter<
T, void, ContainerPrinter, FunctionPointerPrinter, PointerPrinter,
+ ProtobufPrinter,
internal_stream_operator_without_lexical_name_lookup::StreamPrinter,
- ProtobufPrinter, ConvertibleToIntegerPrinter,
- ConvertibleToStringViewPrinter, RawBytesPrinter, FallbackPrinter>::type;
+ ConvertibleToIntegerPrinter, ConvertibleToStringViewPrinter,
+ RawBytesPrinter, FallbackPrinter>::type;
Printer::PrintValue(value, os);
}
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 35c0802..6fdf552 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -302,7 +302,7 @@
template <typename T, std::enable_if_t<std::is_convertible<T, int64_t>::value,
bool> = true>
static void RecordProperty(const std::string& key, const T& value) {
- RecordProperty(key, (Message() << static_cast<int64_t>(value)).GetString());
+ RecordProperty(key, (Message() << value).GetString());
}
protected:
diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h
index 4687dae..21f3d29 100644
--- a/googletest/include/gtest/internal/gtest-death-test-internal.h
+++ b/googletest/include/gtest/internal/gtest-death-test-internal.h
@@ -238,7 +238,7 @@
} \
break; \
case ::testing::internal::DeathTest::EXECUTE_TEST: { \
- ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel( \
+ const ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel( \
gtest_dt); \
GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \
gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index e1eb2b5..7339504 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -900,8 +900,10 @@
HasDebugStringType::value && HasShortDebugStringType::value;
};
+#ifdef GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
template <typename T>
constexpr bool HasDebugStringAndShortDebugString<T>::value;
+#endif
// When the compiler sees expression IsContainerTest<C>(0), if C is an
// STL-style container class, the first overload of IsContainerTest
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index ae7fb35..5cea3e0 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -2447,4 +2447,9 @@
#endif // __has_include
#endif // GTEST_HAS_ABSL
+#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
+ GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L
+#define GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1
+#endif
+
#endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index a60a042..fb578d5 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -5409,6 +5409,8 @@
in_death_test_child_process
? nullptr
: internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE"));
+#else
+ const bool in_death_test_child_process = false;
#endif // GTEST_HAS_DEATH_TEST
// Captures the value of GTEST_FLAG(catch_exceptions). This value will be
@@ -5456,6 +5458,8 @@
}
#endif
}
+#else
+ (void)in_death_test_child_process; // Needed inside the #if block above
#endif // GTEST_OS_WINDOWS
return internal::HandleExceptionsInMethodIfSupported(
@@ -6663,8 +6667,7 @@
if (*argc > 0) {
// absl::ParseCommandLine() requires *argc > 0.
auto positional_args = absl::flags_internal::ParseCommandLineImpl(
- *argc, argv, absl::flags_internal::ArgvListAction::kRemoveParsedArgs,
- absl::flags_internal::UsageFlagsAction::kHandleUsage,
+ *argc, argv, absl::flags_internal::UsageFlagsAction::kHandleUsage,
absl::flags_internal::OnUndefinedFlag::kReportUndefined);
// Any command-line positional arguments not part of any command-line flag
// (or arguments to a flag) are copied back out to argv, with the program
diff --git a/googletest/test/googletest-json-outfiles-test.py b/googletest/test/googletest-json-outfiles-test.py
index 83a56de..ff15722 100644
--- a/googletest/test/googletest-json-outfiles-test.py
+++ b/googletest/test/googletest-json-outfiles-test.py
@@ -88,7 +88,7 @@
'time': '*',
'timestamp': '*',
'testsuite': [{
- 'name': 'TestInt64Properties',
+ 'name': 'TestInt64ConvertibleProperties',
'file': 'gtest_xml_outfile2_test_.cc',
'line': 41,
'status': 'RUN',
@@ -97,11 +97,11 @@
'time': '*',
'classname': 'PropertyTwo',
'SetUpProp': '2',
- 'TestFloatProperty': '3',
- 'TestDoubleProperty': '4',
+ 'TestFloatProperty': '3.25',
+ 'TestDoubleProperty': '4.75',
'TestSizetProperty': '5',
- 'TestBoolProperty': '1',
- 'TestCharProperty': '65',
+ 'TestBoolProperty': 'true',
+ 'TestCharProperty': 'A',
'TestInt16Property': '6',
'TestInt32Property': '7',
'TestInt64Property': '8',
diff --git a/googletest/test/gtest_xml_outfile2_test_.cc b/googletest/test/gtest_xml_outfile2_test_.cc
index 5ee216d..ed58dc8 100644
--- a/googletest/test/gtest_xml_outfile2_test_.cc
+++ b/googletest/test/gtest_xml_outfile2_test_.cc
@@ -38,9 +38,7 @@
void TearDown() override { RecordProperty("TearDownProp", 2); }
};
-TEST_F(PropertyTwo, TestInt64Properties) {
- // Floats and doubles are written as int64_t, so we test that the values
- // written are truncated to int64_t.
+TEST_F(PropertyTwo, TestInt64ConvertibleProperties) {
float float_prop = 3.25;
RecordProperty("TestFloatProperty", float_prop);
diff --git a/googletest/test/gtest_xml_outfiles_test.py b/googletest/test/gtest_xml_outfiles_test.py
index 7ee0f3c..50291b0 100755
--- a/googletest/test/gtest_xml_outfiles_test.py
+++ b/googletest/test/gtest_xml_outfiles_test.py
@@ -57,14 +57,14 @@
EXPECTED_XML_2 = """<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="0" disabled="0" errors="0" time="*" timestamp="*" name="AllTests">
<testsuite name="PropertyTwo" tests="1" failures="0" skipped="0" disabled="0" errors="0" time="*" timestamp="*">
- <testcase name="TestInt64Properties" file="gtest_xml_outfile2_test_.cc" line="41" status="run" result="completed" time="*" timestamp="*" classname="PropertyTwo">
+ <testcase name="TestInt64ConvertibleProperties" file="gtest_xml_outfile2_test_.cc" line="41" status="run" result="completed" time="*" timestamp="*" classname="PropertyTwo">
<properties>
<property name="SetUpProp" value="2"/>
- <property name="TestFloatProperty" value="3"/>
- <property name="TestDoubleProperty" value="4"/>
+ <property name="TestFloatProperty" value="3.25"/>
+ <property name="TestDoubleProperty" value="4.75"/>
<property name="TestSizetProperty" value="5"/>
- <property name="TestBoolProperty" value="1"/>
- <property name="TestCharProperty" value="65"/>
+ <property name="TestBoolProperty" value="true"/>
+ <property name="TestCharProperty" value="A"/>
<property name="TestInt16Property" value="6"/>
<property name="TestInt32Property" value="7"/>
<property name="TestInt64Property" value="8"/>