4454 Commits

Author SHA1 Message Date
Abseil Team
504ea69cf7 Document unexpected interaction with death test error code and gmock.
If you have a death test that uses mock objects, it's very likely that those mock objects are not properly cleaned up before death. The gMock atexit leak detector will call `_exit(1)`, overriding your expected exit code.

PiperOrigin-RevId: 713722657
Change-Id: I92a326f3923efc9f0e235d825616f3094eca995c
2025-01-09 10:43:08 -08:00
Abseil Team
4bbf80823c Add UnpackStructImpl for structs with 20 fields.
PiperOrigin-RevId: 713272335
Change-Id: I2b289ece4ce3f91834a8c9ba11a4bd18e6e40fca
2025-01-08 06:38:13 -08:00
Abseil Team
7d76a231b0 gtest: Output a canned test case for test suite setup / teardown failures in XML/JSON
This surfaces useful information about the environment failure in a structured form.

As we can see from the updated test, previously unsurfaced information is now present.

PiperOrigin-RevId: 709892315
Change-Id: I2656294d50c33f995bef5c96195a66cff3c4b907
2024-12-26 15:30:52 -08:00
Abseil Team
e54519b094 Put the fake Fuchsia SDK in a module extension
This allows users to override the fake SDK with a real one using https://bazel.build/rules/lib/globals/module#override_repo.

Without this change, it is impossible for a project that depends on googletest as a `bazel_dep` to build tests using the "real" Fuchsia SDK, because any references to `@fuchsia_sdk` within googletest `BUILD.bazel` files unconditionally resolve to the "fake" Fuchsia SDK. With this change, if you have the real Fuchsia SDK declared in your `MODULE.bazel`, you can add the following lines to coerce googletest to use the real Fuchsia SDK as well:

    fake_fuchsia_sdk_extension =
    use_extension("@com_google_googletest//:fake_fuchsia_sdk.bzl", "fuchsia_sdk")
    override_repo(fake_fuchsia_sdk_extension, "fuchsia_sdk")

PiperOrigin-RevId: 709139784
Change-Id: I4d10d441c76b7a2481f15723a24f11525dba3878
2024-12-23 13:33:10 -08:00
Abseil Team
f3c355f9dd the public version already has the const qualifier
PiperOrigin-RevId: 706721910
Change-Id: I8a76a66d62028176a70678954f095ac70996cc9e
2024-12-16 08:40:16 -08:00
Abseil Team
79219e26e0 Update the links to ISTQB glossary.
PiperOrigin-RevId: 705108072
Change-Id: I209e7fb24bd093412dda1cd5eba10e9ccc2306f4
2024-12-11 08:00:11 -08:00
Abseil Team
d122c0d435 Add support for printing C++20 std::*_ordering types to gtest.
Adds feature test macro for C++20 <compare> header, a pretty-printer, and tests.
Inexplicably, these types aren't enums, so can't be handled with a switch.

PiperOrigin-RevId: 704783038
Change-Id: I29688989d18f43520fe610c12a447a20d2f98c95
2024-12-10 11:23:04 -08:00
Copybara-Service
35d0c36560 Merge pull request #4662 from asoffer:patch-1
PiperOrigin-RevId: 698420375
Change-Id: I786e5b50d171c697c21579659a67716442f224df
2024-11-20 09:37:33 -08:00
Andy Soffer
7927f8e93d
Fix documentation bug.
Matchers require the signature of these three functions to be `const`.
2024-11-15 10:19:57 -05:00
Abseil Team
d144031940 Fixing a typo in the documentation of IsSubsetOf().
PiperOrigin-RevId: 692957797
Change-Id: Ifd3efe64cd2a3a5623167fa13de61d6e3358662d
2024-11-04 07:26:27 -08:00
Abseil Team
1204d63444 Remove mention of using ASSERT_... statements inside custom matcher definitions.
PiperOrigin-RevId: 691994071
Change-Id: I63913152217c99b8c08ae6af8924bc28b02aa9d0
2024-10-31 18:04:00 -07:00
Peter Boström
5ed2186395 Use FAIL() in GTEST_SKIP() documentation
This replaces EXPECT_EQ(0, 1) which would fail if hit.

PiperOrigin-RevId: 690491467
Change-Id: Ieff4e616348254f29200e0ba1d9a6900a2eea130
2024-10-27 23:57:15 -07:00
Abseil Team
df1544bcee Avoid creating std::vector<const T> in UnorderedElementsAreArrayMatcher and others.
std::vector<const T> for trivially relocatable types is not allowed by C++ and is rejected by libc++ starting from 4e112e5c1c
PiperOrigin-RevId: 686487841
Change-Id: I3c90c7c0a6e8e23ffa5ebd1702a3f30ebc4a702f
2024-10-16 06:39:54 -07:00
Abseil Team
62df7bdbc1 This change adjusts how ASSERT_NEAR and EXPECT_NEAR treats infinity, such that ASSERT_NEAR(inf, inf, 0) passes. This makes the behavior more consistent with ASSERT_EQ(inf, inf) which succeeds.
Some examples of asserts that now pass:
```
ASSERT_NEAR(inf, inf, 0)
ASSERT_NEAR(-inf, inf, inf)
ASSERT_NEAR(inf, x, inf)  // x is any finite floating point value
```

PiperOrigin-RevId: 685748133
Change-Id: I7b3af377773e8e0031e4c6b86830cbbf76bf20c6
2024-10-14 10:13:58 -07:00
Abseil Team
71815bbf7d Automated Code Change
PiperOrigin-RevId: 682549952
Change-Id: Ica81f0020c3001c01543a5851dae7d0b42730c66
2024-10-04 20:54:14 -07:00
Abseil Team
a1e255a582 Optional(): Add support for std::optional<>-like types lacking bool conversion.
PiperOrigin-RevId: 681053268
Change-Id: If80ba667fd4c91340e1405a9691f5ca0350fa9eb
2024-10-01 09:35:17 -07:00
Abseil Team
6dae7eb4a5 Use matcher's description in AnyOf when matcher has no explanation.
PiperOrigin-RevId: 675298308
Change-Id: I32d32cafebc7a63fd03e6d957c3a47043d71e5d9
2024-09-16 14:49:27 -07:00
Abseil Team
0953a17a42 Automated Code Change
PiperOrigin-RevId: 668944316
Change-Id: I65aa0a4f3b8a980242849963a3e921ec7fd92b28
2024-08-29 08:17:22 -07:00
Derek Mauro
ff233bdd4c Update main to point to 1.15.2 patch release
PiperOrigin-RevId: 658382055
Change-Id: Ia5eed4bec26da8c8cbe29fbd3a41b44048c25e07
2024-08-01 06:34:56 -07:00
Derek Mauro
3e3b44c300 Remove auto-detection of Python toolchain from MODULE.bazel
since it affects downstream users

The correct solution appears to be
https://rules-python.readthedocs.io/en/stable/toolchains.html#library-modules-with-dev-only-python-usage

This change also includes a workaround for the new mechanism creating
paths that are too long for Windows to handle.

Fixes #4581

PiperOrigin-RevId: 657706984
Change-Id: I8ae6b9e5efeb7629d79d14e7d4d3889876282d17
2024-07-30 13:17:40 -07:00
Abseil Team
ffa31aec1c Directly include gmock.h and gtest.h in gmock-matchers tests.
These headers have been included through `gmock-matchers_test.h`

PiperOrigin-RevId: 657612455
Change-Id: I65675f1cfe7789f1821ccacbe60acf90efd5c221
2024-07-30 09:03:18 -07:00
Abseil Team
5bcb2d78a1 Use matcher's description in AllOf if matcher has no explanation.
PiperOrigin-RevId: 655569834
Change-Id: Ia760d74d1cdde766e9719864c5e19c0159da3128
2024-07-24 08:07:57 -07:00
Aaron Jacobs
352788321f gmock-actions: make DoAll convert to OnceAction via custom conversions.
Currently it will refuse to become a `OnceAction` if its component sub-actions
have an `Action` conversion operator but don't know about `OnceAction` in
particular because although `Action` is convertible to `OnceAction`, the
compiler won't follow the chain of conversions.

Instead, teach it explicitly that it can always be a `OnceAction` when it can be
an `Action`.

PiperOrigin-RevId: 655393035
Change-Id: Ib205b518ceef5f256627f4b02cd93ec9bd98343b
2024-07-23 19:43:42 -07:00
Aaron Jacobs
57e107a10e Run clang-format.
PiperOrigin-RevId: 655106304
Change-Id: Ie69b407fce74b31cf71d6dcc1361910d30e86bb5
2024-07-23 03:57:23 -07:00
Derek Mauro
cee1ba1f24 Change the Bazel build to use the canonical repo names used by Bzlmod
and the Bazel Central Registry

GoogleTest and its dependencies now use the following names:
GoogleTest: com_google_googletest -> googletest
Abseil: com_google_absl -> abseil-cpp
RE2: com_googlesource_code_re2 -> re2

Bazel users using the WORKSPACE file to specify dependencies may
need to use https://bazel.build/rules/lib/repo/http#http_archive-repo_mapping
to remap repositories to their former names if their dependencies do not
agree on on which name is used.

It is recommended that users migrate to bzlmod to manage Bazel dependencies.

PiperOrigin-RevId: 654430227
Change-Id: Iae8797994d7d87bd4f013dcdc889e7494a6ad2fb
2024-07-20 23:09:44 -07:00
Derek Mauro
9ff2450a56 Update GoogleTest Bazel quickstart for Bzlmod
PiperOrigin-RevId: 652824490
Change-Id: I5e6f57004708e7fa62abb454db9bae81fa265c83
2024-07-16 06:58:45 -07:00
Derek Mauro
b62593aceb Update main branch to reflect the release of 1.15.0
PiperOrigin-RevId: 652824317
Change-Id: I39085d9451405c3decb462a0b4682added365d17
2024-07-16 06:57:43 -07:00
Abseil Team
d49a665484 Use matcher's description in AllOf if matcher has no explanation.
PiperOrigin-RevId: 652798234
Change-Id: I8e92248a2d9faf2a5719fe220145ea563acc14ff
2024-07-16 05:22:42 -07:00
Abseil Team
417158b8bc Use matcher's description in AllOf if matcher has no explanation.
PiperOrigin-RevId: 652634229
Change-Id: I5fd7eaef4db3dea3d4142e1fb5fc97e46f654358
2024-07-15 16:40:10 -07:00
Derek Mauro
7321f950df Update dependency versions in preparation for release
PiperOrigin-RevId: 652479800
Change-Id: I71574e7dc2ea2e9a2f3071aebbbf0e6b5ce32a35
2024-07-15 07:51:06 -07:00
Derek Mauro
4b21f1abdd README.md: Remove outdated notes about continuous integration and
documentation

PiperOrigin-RevId: 651816538
Change-Id: I3c85b4a26aff8277c627b99b1c5805bad0d29df6
2024-07-12 10:31:17 -07:00
Derek Mauro
b4aaf97d8f Workaround GCC 12 -Wrestrict false-positive
Suggested workaround from 751760ad54

Fixes #4570

PiperOrigin-RevId: 651044944
Change-Id: I21f099a15dd3182d335a7891d99b9b1293e5c53e
2024-07-10 09:15:21 -07:00
Derek Mauro
3ef16ef8b3 Fix the documentation that erroneously says you can use short versions
of help flags

Fixes #4564

PiperOrigin-RevId: 650730047
Change-Id: I3a52aca490338066c607e34ab20c827bfde5090d
2024-07-09 12:59:38 -07:00
Abseil Team
34ad51b3dc Add a bounds check to protect against an empty vector from GetArgs(), which
can cause an out of bounds access in GetCurrentExecutableName(). One way this
can happen is if the user forgets to call InitGoogleTest().

PiperOrigin-RevId: 647740658
Change-Id: Id87692aa3d515b8ae0836e474be477d2aafa3871
2024-06-28 11:12:56 -07:00
Abseil Team
1d17ea141d Skip the predicate on SIGSEGV in death-test on Android builds with API level <= 21.
PiperOrigin-RevId: 643076477
Change-Id: Id9486b7d73c3b17851df1eaf8f5ab2085238bf75
2024-06-13 12:00:01 -07:00
Abseil Team
a7f443b80b Mention the optional third argument to TYPED_TEST_SUITE
PiperOrigin-RevId: 637896001
Change-Id: Ia3a61ceec4b842e864a0cdfad13e9897bf0ecaaa
2024-05-28 07:42:39 -07:00
Derek Mauro
305e5a238b Update GoogleTest CI Docker image to use Clang 19, GCC 14, and CMake 3.29.3
PiperOrigin-RevId: 636977286
Change-Id: Id9e09398a991c74c2137672948a1eb7dd2d96596
2024-05-24 11:13:43 -07:00
Derek Mauro
9b4993ca7d Change GoogleTest flag removal to not read beyond the end of the array
to the NULL terminator.  #4532 says ASAN complains about this on some
platforms, although it is not clear if ASAN or the platform implementation
is incorrect about accessing the terminating NULL.

Fixes #4532

PiperOrigin-RevId: 635886009
Change-Id: Ibb4237055488c895b1dd09145ab979347bb9a390
2024-05-21 12:08:38 -07:00
Abseil Team
c8393f8554 Print mismatches for UnorderedElements() of different sizes.
Changes the behavior of UnorderedElements()/UnorderedElementsAreArray() to print items-without-matchers and matchers-without-items in the case where the actual and expected are different sizes.

PiperOrigin-RevId: 635451316
Change-Id: I2181bb28a14c14cdb577af9268d403e12e942bea
2024-05-20 07:36:47 -07:00
Abseil Team
33af80a883 Make EXPECT_DEATH_IF_SUPPORTED work with matchers
If death tests were not supported the macro would try
to force the second parameter as a string. The second
parameter can be a matcher or a string.

PiperOrigin-RevId: 633199517
Change-Id: If5e71b4be0b569adb273eb4960202197bb264a8f
2024-05-13 07:16:53 -07:00
Copybara-Service
fa6de7f438 Merge pull request #4527 from abhina-sree:abhina/add_zos
PiperOrigin-RevId: 631167807
Change-Id: I563883341972bbb82c7407ebf3755d64317b84fc
2024-05-06 13:31:42 -07:00
Abseil Team
2d684efe87 Use std::forward on GoogleTest matcher arguments
This prevents a diagnostic from triggering for a missing std::move.

PiperOrigin-RevId: 631094640
Change-Id: I4ab33964c65f41240fb54a6bf7d0261836fd78e7
2024-05-06 09:48:55 -07:00
Copybara-Service
2d16ed055d Merge pull request #3991 from pgroke-dt:default-enable-thread-support-for-Solaris-AIX-zOS
PiperOrigin-RevId: 630402377
Change-Id: Ie9cafffaa49c2c02220981d665daa672164d35d8
2024-05-03 08:51:23 -07:00
Abseil Team
2954cb8d87 Add example using EXPECT statement in custom matcher
`EXPECT_...` statements can be used inside matcher definitions – this is an important option that is glossed over in this documentation. Users should definitely be aware of this option, since writing custom messages to the `result_listener` can be very cumbersome (and unnecessary) sometimes.

This change adds a relevant example and includes the associated error message it provides on failure.

PiperOrigin-RevId: 630206661
Change-Id: Idee00ba77ce3c1245597aa082f9cd0efff16aceb
2024-05-02 16:07:12 -07:00
Abhina Sreeskantharajan
5035ef3473 add zos for death test support 2024-05-02 09:54:31 -04:00
Paul Groke
fbc93e61c4
Merge branch 'main' into default-enable-thread-support-for-Solaris-AIX-zOS 2024-05-02 13:27:54 +02:00
Abseil Team
d83fee138a Adds "IWYU pragma: export" to gtest-param-util.h
PiperOrigin-RevId: 628105419
Change-Id: I364e8089b62050c44059e208b610e324eb5a656d
2024-04-25 09:50:29 -07:00
Derek Mauro
5a37b517ad Use [[maybe_unused]] when it is available to avoid
-Wused-but-marked-unused warnings

PiperOrigin-RevId: 625430612
Change-Id: Ia9d2e47984e1e6f91966afae8a6750119ae69446
2024-04-16 13:16:40 -07:00
Krzysztof Kosiński
5197b1a8e6 Modify example in the primer to match Testing FAQ.
The CtorVsSetUp section of the FAQ says that constructors and destructors should be preferred over SetUp() and TearDown(), because they will automatically chain up to the fixture's base class, whereas for methods the user must remember to add the chaining manually.

PiperOrigin-RevId: 624273474
Change-Id: Ida41aae193d417eaf996587c7ae1a0099a8cab32
2024-04-12 13:19:21 -07:00
Abseil Team
b1a777f319 Fix https://github.com/google/googletest/issues/4423
PiperOrigin-RevId: 623407029
Change-Id: I3559f11e1c18a4f151d521c6ac115c358a11b40c
2024-04-10 01:03:53 -07:00
Copybara-Service
3d73dee972 Merge pull request #4508 from davidmatson:addJsonSkipped
PiperOrigin-RevId: 622929007
Change-Id: Ifaf5a701baee74503e6845f32ebc27425882e950
2024-04-08 13:02:42 -07:00
Abseil Team
f10e11fb27 No external change
PiperOrigin-RevId: 622203227
Change-Id: Ic3c24edf917dbda7b02c6ab8ce695398a436dc4c
2024-04-05 09:39:59 -07:00
Lawrence Wolf-Sonkin
0af976647f [gtest] Use std::index_sequence and friends instead of rolling our own
* Applies for `std::index_sequence`, `std::make_index_sequence`, and `std::index_sequence_for` replacing `IndexSequence`, `MakeIndexSequence` and IndexSequenceFor`
* Also deleted implementation helper `DoubleSequence`
* The standard interfaces [have been in the standard library since C++14](https://en.cppreference.com/w/cpp/utility/integer_sequence), which [is the minimum supported C++ version by Google Test](https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md)

PiperOrigin-RevId: 621939977
Change-Id: Id264266f08da66c0fa2a6e6fbb8f86fd3cb3a421
2024-04-04 12:38:42 -07:00
Copybara-Service
61db1e1740 Merge pull request #4505 from to01z:add-winapi-partition-games-support
PiperOrigin-RevId: 621631167
Change-Id: I0790f7082ce3c20fef92958c820d40ec854fe91d
2024-04-03 13:59:49 -07:00
Derek Mauro
d3a29ff624 Fix a race condition between the Watcher thread and the main thread
during program exit

A race condition exist between the Watcher thread and main(). A case
was found where the Watcher thread does not get execution time before
the main function returns and calls atexit(). At that point the
Watcher thread started runing tls_init() code while the main thread
was shutting down. This resulted in rare crashes and deadlocks.

Fixes #4493
Closes #4494

PiperOrigin-RevId: 621619768
Change-Id: I66f00d8f0f3c37f9937c6d13890f7fa10038256d
2024-04-03 13:21:58 -07:00
David Matson
f16770d63d Add skipped messages to JSON output (fixes #4507).
Fix the gap between JSON and XML output.
2024-04-03 08:49:07 -07:00
Derek Mauro
ec7b38672c Delete the unofficial GitHub actions tests.
We do not look at these.

Close #4509

PiperOrigin-RevId: 621511191
Change-Id: Icbd3fe0a18444e0888bbec61345c6a957d8899d6
2024-04-03 07:06:06 -07:00
Copybara-Service
a2f106c7e2 Merge pull request #4503 from davidmatson:fixTypo
PiperOrigin-RevId: 621334548
Change-Id: I19747f832b51cc5bbb0231bbd9416a8373e4aa77
2024-04-02 16:50:56 -07:00
Copybara-Service
c4fec74514 Merge pull request #4502 from davidmatson:fixStreamHelpTextOs
PiperOrigin-RevId: 621172364
Change-Id: Ibaacb17c60b5ee0e58c3689b79aa2cd6b49dc1c4
2024-04-02 07:53:31 -07:00
Abseil Team
77afe8e014 Automated Code Change
PiperOrigin-RevId: 620448229
Change-Id: I487a0d8a8f89ebe82c9ec66fbb60cbe2203188c9
2024-03-30 01:54:42 -07:00
Troels Gram
a7678dd0db Revert changes to googletest-port-test.cc
GoogleTest's tests do not currently compile when WINAPI_FAMILY is set to
anything else than WINAPI_FAMILY_DESKTOP_APP on Windows (if WINAPI_FAMILY is not
set explicitly, it will default to WINAPI_FAMILY_DESKTOP_APP).
2024-03-28 22:05:08 -07:00
David Matson
f7a6bba24c Fix typo in comment. 2024-03-28 17:34:21 -07:00
David Matson
53ee0fc0b2 Fix help text for stream_result_to flag.
Support for Mac was previously added, in addition to Linux. Fix the help
text to match the code.
2024-03-28 16:59:37 -07:00
Troels Gram
f1269cc220 Add support for compiling GoogleTest for Xbox
Support for Xbox platforms, requires the code to support compilation with the
WINAPI_FAMILY_GAMES subset of the Win32 API.

- Add support for WINAPI_FAMILY_GAMES to enable GTEST_OS_WINDOWS_GAMES platform.
- Disable stream redirection (GTEST_HAS_STREAM_REDIRECTION = 0) and colored TTY
  printing for GTEST_OS_WINDOWS_GAMES platform. Both features currently require
  Win32 functions that don't exist in the WINAPI_FAMILY_GAMES subset.

Misc fixes:
- gtest-port.cc: Move GTEST_DISABLE_MSC_DEPRECATED_PUSH_ into
  GTEST_HAS_STREAM_REDIRECTION conditional section where the corresponding
  GTEST_DISABLE_MSC_DEPRECATED_POP_ is located.
- googletest-port-test.cc: Switch stream redirection tests to be conditional on
  GTEST_HAS_STREAM_REDIRECTION instead of !defined(GTEST_OS_WINDOWS_MOBILE).
2024-03-23 22:53:35 -07:00
Copybara-Service
eff443c6ef Merge pull request #4490 from memdo:main
PiperOrigin-RevId: 616931521
Change-Id: Iffbb24e3f9add4e7acf8f1988a03afc8628b0733
2024-03-18 13:34:04 -07:00
Mustafa Berkay Düzenli
a1a608348e Add colored output support for Alacritty 2024-03-16 00:28:30 +03:00
Abseil Team
c231e6f5b1 Add test for move-only type in Action signature
PiperOrigin-RevId: 616031018
Change-Id: Ie724f9562174387eab866a824d28106f344c558d
2024-03-15 00:00:12 -07:00
Daniel Cheng
b479e7a3c1 Guard Abseil flags usage in googlemock with GTEST_NO_ABSL_FLAGS.
googletest avoids using the Abseil flag library, so googlemock should
do the same for consistency.

PiperOrigin-RevId: 614713968
Change-Id: I0925804b8644ddc6fd3ad07a320d94829b11bb8e
2024-03-11 10:31:56 -07:00
Abseil Team
e1a38bc370 Reland: Optimize Google Test process startup
Google Test performs hidden test registration during process
startup. For test binaries that contain a large number of tests, this
registration can be costly. In this CL, we reduce the overhead of
registration via several tactics:

- Treat CodeLocation and FilePath as value types, using std::move to
  pass them around.
- Reduce string copies in various places by either passing std::string
  values via std::move, or passing const-refs to std::string instances.
- Use std::to_string to stringify an int in DefaultParamName rather than
  a std::stringstream.
- Pull some std::string instances out of nested loops in
  ParameterizedTestSuiteInfo::RegisterTests so as to reuse some
  allocations, and replace stringstream with ordinary string appends.
- Use std::unordered_map in UnitTestImpl::GetTestSuite and
  ParameterizedTestSuiteRegistry::GetTestSuitePatternHolder to spend a
  little memory to turn O(N) lookups into constant time lookpus.
- Use range-based for loops in a few places.
- Use emplace-ish methods to add to containers where appropriate.

All together, these changes reduce the overall runtime of a series of 50
death tests in a single Chromium test executable by ~38% due to the
fact that the registration costs are paid in every death test's child
process.

PiperOrigin-RevId: 613833210
Change-Id: I51a262a770edff98ffa1e3b60c4d78a8308f9a9f
2024-03-07 23:53:47 -08:00
Abseil Team
31993dfa6b Revert Optimize Google Test process startup
PiperOrigin-RevId: 612878184
Change-Id: Ia8e23da1ad09c2e0ce635a855f0c250f368f6878
2024-03-05 09:59:16 -08:00
Abseil Team
b9059aaa4c Optimize Google Test process startup
Google Test performs hidden test registration during process
startup. For test binaries that contain a large number of tests, this
registration can be costly. In this CL, we reduce the overhead of
registration via several tactics:

- Treat CodeLocation and FilePath as value types, using std::move to
  pass them around.
- Reduce string copies in various places by either passing std::string
  values via std::move, or passing const-refs to std::string instances.
- Use std::to_string to stringify an int in DefaultParamName rather than
  a std::stringstream.
- Pull some std::string instances out of nested loops in
  ParameterizedTestSuiteInfo::RegisterTests so as to reuse some
  allocations, and replace stringstream with ordinary string appends.
- Use std::unordered_map in UnitTestImpl::GetTestSuite and
  ParameterizedTestSuiteRegistry::GetTestSuitePatternHolder to spend a
  little memory to turn O(N) lookups into constant time lookpus.
- Use range-based for loops in various places.
- Use emplace-ish methods to add to containers where appropriate.

All together, these changes reduce the overall runtime of a series of 50
death tests in a single Chromium test executable by ~38% due to the
fact that the registration costs are paid in every death test's child
process.

PiperOrigin-RevId: 612763676
Change-Id: I1f46e012ccb9004c009e1027e4f7c38780ffb9e2
2024-03-05 02:37:09 -08:00
Copybara-Service
926f681a90 Merge pull request #4466 from danfabo:fix-fetch-content-uses-gtest
PiperOrigin-RevId: 612560830
Change-Id: Ib639603d34258909cf0e0d6fceb297dd8c983d54
2024-03-04 13:15:25 -08:00
Abseil Team
e4fdb87e76 Accept one-shot callables in InvokeArgument.
PiperOrigin-RevId: 611467660
Change-Id: Ic89ffc986141bee61f835cb60088aee92eb8bad9
2024-02-29 07:42:26 -08:00
Copybara-Service
e15c5a51b8 Merge pull request #4477 from tmiguelf:feature/soup_cleanup
PiperOrigin-RevId: 611133343
Change-Id: Ieef806f51fcbc2877805dae415f76d03547b8dfa
2024-02-28 09:48:31 -08:00
Abseil Team
3b6d48e8d5 Reland 9756ee7cba
Since Fuchsia engineers rarely work within this repo, initialize a lightweight fake @fuchsia_sdk repo rather than distributing the Fuchsia SDK here.

Tested locally via `bazel query --[no]enable_bzlmod "deps(set(//googletest/test:gtest_all_test))"` (#4472)

PiperOrigin-RevId: 610826859
Change-Id: I7d41b1dbe9e7f133fe535d7337dc5bff5bf97d3a
2024-02-27 11:54:30 -08:00
Abseil Team
814ba36338 Make sure that current_test_suite and current_test_info are mutex-protected while writing for thread-safety.
PiperOrigin-RevId: 610810340
Change-Id: I37f33510373dff04b8e9c9e8a9f32d30fcce46ff
2024-02-27 11:04:37 -08:00
Tiago Freire
4c676b94b8
Fixed gcc linker error 58 2024-02-23 13:23:25 +01:00
Abseil Team
9d43b27f7a Revert incorrect update.
PiperOrigin-RevId: 609387046
Change-Id: I03e42c39011fc7e9715f896591a44ebede1933b2
2024-02-22 08:48:24 -08:00
Derek Mauro
db38b59fa0 Rollback 9756ee7cba
The commit breaks some bazel commands without @fuchsia_sdk being listed as a dependency.

Fixes #4472

PiperOrigin-RevId: 609057667
Change-Id: I32ea8237862d7c10add55304ecc4547a7304ce36
2024-02-21 11:06:13 -08:00
Abseil Team
5df0241ea4 gtest.h: add IWYU export pragmas
PiperOrigin-RevId: 607136416
Change-Id: Ia29dd3156d4d455194745e58501eaee9d77045a1
2024-02-14 16:11:33 -08:00
Abseil Team
9756ee7cba Support Fuchsia target builds.
The Fuchsia team has been using either fork branches
(https://fuchsia.googlesource.com/third_
party/github.com/google/googletest/+/refs/heads/sandbox/fuchsia_bazel_sdk)
or patch files
(https://cs.opensource.google/fuchsia/fuchsia/+/main:build/bazel/patches/googletest/fuchsia-support.bundle)
to support googletest-based tests that run against a Fuchsia target device.

As our SDK is maturing and @platforms//os:fuchsia constraint has been added
for a while now, upstream Fuchsia gtest support to reduce technical debt and
overhead.

This change is noop for non-fuchsia platform builds.

PiperOrigin-RevId: 606843739
Change-Id: I61e0eb9c641f288d7ae57354fc0b484fce013223
2024-02-13 20:56:40 -08:00
Abseil Team
6eb225cb88 Add anchor for expectation ordering note
PiperOrigin-RevId: 606736565
Change-Id: Ifad0b34e1deeec1374377d733375c6210896d0d3
2024-02-13 13:55:04 -08:00
danfabo
f5448b3d71 Get include dirs from target rather than global variables.
The global variable gtest_SOURCE_DIR is replaced by CMake when fetch-content is used with the name "GTest" and points to the root directory. The include directories from the gtest target are always valid.
2024-02-11 18:50:28 +01:00
Matt Kulukundis
b75ecf1bed Switch rank structs to be consistent with written guidance in go/ranked-overloads
PiperOrigin-RevId: 605110251
Change-Id: I304f3863333cb9ef0b85c5bab5277e757ef9950a
2024-02-07 15:06:10 -08:00
Abseil Team
96519a4019 Use _Exit instead of _exit in GoogleTest
_Exit is standardized since C99, whereas _exit is POSIX-only.

Fixes: #4447
PiperOrigin-RevId: 605000352
Change-Id: Ibfa84edaa043bd003a21383e8148bf45be7217f6
2024-02-07 09:01:25 -08:00
Abseil Team
64be1c79fa Destroy installed environments in normal code, not in static teardown.
Destruction in static teardown causes issues for Environments which own threads and try to join them in their destruction.

This may be a breaking change for users who call RUN_ALL_TESTS multiple times in the same main function if they also install environments, or those who access registered environments after RUN_ALL_TESTS.

The easiest fix is to only call RUN_ALL_TESTS once as the last line of the main function. Another potential fix is to re-register new instances of the Environment once before each call to RUN_ALL_TESTS.

PiperOrigin-RevId: 604800795
Change-Id: I37c44d4aca4a238052649f45a4b6b9cfb5355b71
2024-02-06 16:31:00 -08:00
Copybara-Service
48729681ad Merge pull request #4458 from kaswhy:patch-1
PiperOrigin-RevId: 604402563
Change-Id: If99952449430161609572dab998774fac4653f01
2024-02-05 12:41:31 -08:00
Abseil Team
456574145c Modifications to improve portability of googletest tests.
PiperOrigin-RevId: 603034597
Change-Id: I4d716ed67f80f41075bfa266d975460d2ac27eb6
2024-01-31 06:51:14 -08:00
Soyeon Kim
3cb7ce90b3
Add myself to Contributors 2024-01-31 21:11:21 +09:00
Abseil Team
6fdb4c303f Do not emit stack traces for messages generated by SUCCEED()
Stack traces in assertion failures are an extremely useful tool for
developers tasked with investigating failing tests. It's difficult to
understate this. In contrast to ordinary test assertions (e.g.,
ASSERT_TRUE or EXPECT_FALSE), SUCCEED() is a developer-authored
directive that indicates a success codepath. In fact, the documentation
states that this directive doesn't generate any output. Generating stack
traces for uses of SUCCEED() is wasted work since they are never
printed. If this were to change one day in the future, they still would
not be useful since any emitted message would include the file and line
number where SUCCEED was used. In addition to being noise in the output
in this case, symbolization of stack traces is not free. In some
Chromium configurations, symbolization for use of SUCCEED() can incur a
cost in excess of 25 seconds for a test that otherwise takes 0-1ms; see
https://crbug.com/1517343.

In this CL, we suppress generation and emission of stack traces for
kSuccess messages to reduce the overhead of SUCCEED().

PiperOrigin-RevId: 602832162
Change-Id: I557dd6a1d3e6ed6562daf727d69fd01fe914827b
2024-01-30 13:55:46 -08:00
Copybara-Service
fc0076ffc4 Merge pull request #4435 from kaswhy:main
PiperOrigin-RevId: 602385832
Change-Id: I755dae5707e98b6157930a74de90a8e19ef17603
2024-01-29 07:50:37 -08:00
Derek Mauro
6a5938233b Add support for Bzlmod for the next release
https://bazel.build/external/overview#bzlmod

Bzlmod will be the default in a future Bazel release.
By default it requires projects to be registered with the
Bazel Central Registry (https://registry.bazel.build/) and
thus uses regular releases by default.

Users that want to "live-at-head" can still do this through
with overrides (https://bazel.build/external/module#overrides).

This change updates GoogleTest dependencies to use released versions.
CI uses Bzlmod except in the case of linux_gcc-floor, which will
keep testing the old WORKSPACE-based dependency system.

PiperOrigin-RevId: 601489729
Change-Id: I6be52034eba0d0e5fe12110e5e82879305cf73ff
2024-01-25 10:27:52 -08:00
Abseil Team
563ebf1769 Fix double-promotion warnings in AppropriateResolution()
When -Wdouble-promotion is enabled, the templatized function AppropriateResolution fails to compile since its float instantiation promotes floats to doubles when doing arithmetic and comparisons. Add static casts to resolve these errors.

PiperOrigin-RevId: 600776333
Change-Id: Ia530b4bbca6ddce27caf0a817196d87efef711cb
2024-01-23 07:02:53 -08:00
kaswhy
1cab76c7b8 Docs: Add mention of gtest_recreate_environments_when_repeating 2024-01-23 21:39:40 +09:00
Copybara-Service
bd30c39d61 Merge pull request #4444 from michaeldleslie:only_apply_lregex_for_qnx710_and_newer
PiperOrigin-RevId: 600548775
Change-Id: Ia693791321602e728aef9135b349602c790a058a
2024-01-22 13:13:03 -08:00
Dino Radakovic
ffc477e705 googletest: Fix incorrect comment about value_param of internal::MakeAndRegisterTestInfo
This was probably a copy-paste from the comment about `type_param`.

PiperOrigin-RevId: 600493462
Change-Id: I4a41c2673dd6560db0f68856aab3d32b103164b1
2024-01-22 10:12:16 -08:00
Abseil Team
96cd50c082 If GTEST_NO_ABSL_FLAGS is #defined, then the Abseil flag library
will not be used by googletest, even if GTEST_HAS_ABSL is #defined.

PiperOrigin-RevId: 599625032
Change-Id: Ieb994a15683dec89e88578120071eca8ac9fead1
2024-01-18 14:24:26 -08:00
Abseil Team
f6f920d2ba Make posix::FileNo available under !GTEST_HAS_FILE_SYSTEM
This enables automatic color output without filesystem support, as that only requires testing to see if the output is a terminal.

Fixes: #4439
PiperOrigin-RevId: 598929397
Change-Id: Idca7490e6e090951a78cd1cdd710f41d756a68b4
2024-01-16 12:56:41 -08:00
Abseil Team
cfe5076a8b Do not emit stack traces for messages generated by GTEST_SKIP()
Stack traces in assertion failures are an extremely useful tool for
developers tasked with investigating failing tests. It's difficult to
understate this. In contrast to ordinary test assertions (e.g.,
ASSERT_TRUE or EXPECT_FALSE), GTEST_SKIP is a developer-authored
directive to skip one or more tests. Stack traces emitted in skip
messages do not give the developer useful information, as the skip
message itself contains the code location where GTEST_SKIP was used. In
addition to being noise in the output, symbolization of stack traces is
not free. In some Chromium configurations, symbolization in a skipped
test can incur a cost in excess of 25 seconds for a test that otherwise
takes 0-1ms; see https://crbug.com/1517343#c9.

In this CL, we suppress generation and emission of stack traces for
kSkip messages to reduce the output noise and overhead of GTEST_SKIP().

PiperOrigin-RevId: 598899010
Change-Id: I46926fed452c8d7edcb3d636d8fed42cb6c0a9e9
2024-01-16 11:19:24 -08:00
kaswhy
778badf63a Docs: add conditions for calling SetUp and TearDown() 2024-01-12 01:06:00 +09:00