4607 Commits

Author SHA1 Message Date
Abseil Team fa005b296f Set up inlining for InvokeWithoutArgs when passed a functor.
Actions can now be implicitly constructed from zero-argument callables. There is no need to create wrapper objects using InvokeWithoutArgs().

PiperOrigin-RevId: 949656497
Change-Id: Ida2bc38e446e7b33aaf185ec593caf2a1959138e
2026-07-17 10:58:22 -07:00
Copybara-Service 4141c384aa Merge pull request #4939 from fresh3nough:fix/cmake-python3-find-4847
PiperOrigin-RevId: 949359007
Change-Id: I3935301d293d9165db7dcda0c64cc821bdfe5186
2026-07-16 22:01:49 -07:00
Bogdan Graur a25f43576e Fixes -Wtautological-pointer-compare in gmock-matchers
PiperOrigin-RevId: 948667420
Change-Id: Ibb35d7e6469a193607a72f10377ef3a494f9525f
2026-07-15 18:51:05 -07:00
Copybara-Service b973ccb9ab Merge pull request #5025 from K-S-Manikandan:fix/output-test-python3
PiperOrigin-RevId: 948328634
Change-Id: I9d2c42a63138095b88cc0cff16f69e8220ee1dfd
2026-07-15 07:37:08 -07:00
Copybara-Service f132c89311 Merge pull request #5019 from kamleshkumaryadav5951-pixel:fix-emscripten-pthread-odr
PiperOrigin-RevId: 946412596
Change-Id: I86547a9de58b29f038e5bcdd21dadbad9506888d
2026-07-11 21:38:07 -07:00
Copybara-Service 961158b5e3 Merge pull request #4869 from phst:alwayslink
PiperOrigin-RevId: 946402457
Change-Id: I78650f118c24fb668bf51e861cf910a997ff227d
2026-07-11 21:03:28 -07:00
Manikandan K. S. 86ec940f63 fix: Python 3 crash in googletest-output-test.py debug mode
Fixes #3943

Change file open mode from 'wb' (binary) to 'w' (text) when writing
normalized output in DEBUG_GTEST_OUTPUT_TEST mode.
2026-07-11 19:37:13 +05:30
kamlesh kumar yadav bc410696f4 Support pthread-enabled Emscripten in GTEST_HAS_PTHREAD 2026-07-09 12:23:52 +05:30
Copybara-Service 8240fa7d62 Merge pull request #5011 from K-S-Manikandan:fix/compare-lib-android
PiperOrigin-RevId: 944164816
Change-Id: Ia57a34e3caf93d23b6a13c49e2455901c98e942a
2026-07-07 16:54:00 -07:00
Mike Kruskal 7d012aa162 Fail smoothly for nullptr on c-style strings in IsEmpty
PiperOrigin-RevId: 944115454
Change-Id: I99284439b0c0e0acee1cb4e12f2d0b8d422c83ba
2026-07-07 15:11:54 -07:00
Copybara-Service cd975499e8 Merge pull request #5008 from K-S-Manikandan:fix/wide-string-isempty
PiperOrigin-RevId: 944044650
Change-Id: I9dcd6625f41f4f098439d222c26383150f7e8f6a
2026-07-07 12:49:50 -07:00
Copybara-Service 3064a609c7 Merge pull request #5005 from tejas-sharma27:fix-help-missing-flags
PiperOrigin-RevId: 943911159
Change-Id: I42c77c8ec667c37032563c92e4b8190473892b77
2026-07-07 08:32:49 -07:00
Copybara-Service 3549aa63f2 Merge pull request #5006 from K-S-Manikandan:fix/readme-fullstops
PiperOrigin-RevId: 943641260
Change-Id: I66e46d88e36282b283124f1dec327bafe425bcef
2026-07-06 20:45:23 -07:00
Copybara-Service 985d542c73 Merge pull request #5010 from K-S-Manikandan:fix/main-version-bump
PiperOrigin-RevId: 943495261
Change-Id: I38548207cd67695c2fb76b64b47b46f21b783e2c
2026-07-06 14:24:28 -07:00
Manikandan K. S. 18c6bc3dc4 fix: only use __cpp_lib_three_way_comparison for <compare> detection
The fallback check GTEST_INTERNAL_HAS_INCLUDE(<compare>) && C++20 causes build failures on Android NDK 24 which has the header but lacks the full comparison operators needed by PrintTo. The feature test macro __cpp_lib_three_way_comparison is the reliable indicator.

Fixes #4933
2026-07-05 09:04:37 +05:30
Manikandan K. S. 22bda2ba15 chore: bump main branch version to 1.18.0 2026-07-05 08:54:29 +05:30
Manikandan K. S. df4fdc5cfd fix: add C-style wide string overload to IsEmpty matcher 2026-07-04 22:50:12 +05:30
Manikandan K. S. 1c2082e8bd docs: add missing full stops to feature descriptions in README 2026-07-04 22:14:52 +05:30
Tejas Sharma 5b39f4c876 Add missing public flags to --help output 2026-07-04 21:54:09 +05:30
Clayton Knittel 973323ed64 Delay name resolution by un-qualifying DynamicCastMessage calls from gMock.
Since we can't directly depend on proto headers, we rely on ADL + proto headers being included by calling code for this matcher to choose the right overload of `DynamicCastMessage`.

PiperOrigin-RevId: 940593408
Change-Id: I7374aed3c5cfe61a183d28ea02e6583ab340f647
2026-06-30 12:20:56 -07:00
Copybara-Service 78f6d54f9f Merge pull request #5003 from fuzzard:fix_cmake_pdb_output
PiperOrigin-RevId: 939912323
Change-Id: I2069975b7ba0d9decdf8c61ad77139494886469a
2026-06-29 10:41:38 -07:00
Abseil Team 8b53336594 Automated Code Change
PiperOrigin-RevId: 936635684
Change-Id: I3b1bfa2ef921cdc3d0aaa1fc95986b64a9ad0282
2026-06-23 06:45:34 -07:00
Abseil Team aa40ee603e Automated Code Change
PiperOrigin-RevId: 936616624
Change-Id: I3a05afadf807fc372337186c26b5d73a2bc21410
2026-06-23 06:03:11 -07:00
Brent Murphy d4a1a3599b cmake: Fix PDB output dir for install of static and shared lib
PR https://github.com/google/googletest/pull/3940 added COMPILE_PDB_OUTPUT_DIRECTORY
without updating the install command to accommodate the two PDB properties.
COMPILE_PDB_* and PDB_* properties are two distinct properties that affect static
(COMPILE_PDB_*) and shared (PDB_*) separately.
This commit adds cmake install rule for both types (optionally) to install when available
2026-06-22 19:05:27 +10:00
Abseil Team 1fc11dea10 Automated Code Change
PiperOrigin-RevId: 935893961
Change-Id: I90f8e57a7337f66a2afd37a2f0bc0e418e1ef51e
2026-06-22 00:44:28 -07:00
Clayton Knittel 0b1e895ba4 Specialize testing::WhenDynamicCastTo for protobuf messages.
Protobuf messages have a custom dynamic_cast, for when RTTI is not available on the messages.

PiperOrigin-RevId: 933270097
Change-Id: Iaeb50bce3fe1b746306a7507ab1985b111c03416
2026-06-16 13:32:04 -07:00
Abseil Team 44f22083d7 Automated Code Change
PiperOrigin-RevId: 932837091
Change-Id: Ie65ce7e76ecb97b62483b8ee0ba95e5a96b8039e
2026-06-15 20:54:24 -07:00
Mike Kruskal 7140cd416c Flip the recommendation about using EXPECT statements inside custom matchers.
PiperOrigin-RevId: 925686474
Change-Id: I7b5d7e82dc8618d6914844446fa260468b947ece
2026-06-02 18:03:04 -07:00
Abseil Team a721f1b20c Automated Code Change
PiperOrigin-RevId: 924116072
Change-Id: I3e04ebbff65c897e50c37e1a47a2018f31382104
2026-05-30 20:49:30 -07:00
Aaron Jacobs 8736d2cd5c gmock-spec-builders: support mocking const-qualified function types.
In particular this automatically gives us support for examples like the
following:

    using SomeFn = absl::AnyInvocable<R(Args...) const>;
    MockFunction<SomeFn> some_fn;

PiperOrigin-RevId: 921303527
Change-Id: I19bf59671781e85db65cc20c0d6ea10b056c528a
2026-05-26 01:30:54 -07:00
Abseil Team 09f45f51fb Mark gtest_dt_ptr as const.
PiperOrigin-RevId: 920667027
Change-Id: I3dd71c96e206eb19bf3e62bb08ce7043d83fb526
2026-05-24 16:31:25 -07:00
Abseil Team add971c7cb Introduce ContainsSubsequence matcher.
Subsequences are defined as: "a subsequence of a given sequence is a sequence that can be derived from the given sequence by deleting some or no elements without changing the order of the remaining elements."
See: https://en.wikipedia.org/wiki/Subsequence

This new matcher checks if a container contains elements that match a given sequence of matchers in the specified order, but not necessarily contiguously.
The implementation is very similar to other matchers like ElementsAre or Contains.

PiperOrigin-RevId: 918323422
Change-Id: I56d7ebbe6f81038c93546ef7585db59eea5dbd57
2026-05-20 02:39:49 -07:00
Abseil Team dc3c9eda2f Double the MOCK_METHOD parameter count limit to mitigate users running into it
PiperOrigin-RevId: 916092228
Change-Id: Ifb22a4583b3cf8e4b31a51a5f7373137c9e3b9f0
2026-05-15 11:11:10 -07:00
Dillon Sharlet d72f9c8aea Add --gtest_shard_index and --gtest_total_shards command line arguments.
This uses the environment variables as the default value for the command line argument, so this is not a breaking change to most reasonable existing use cases. This *is* a breaking change if a process expects changes to the sharding environment variables to be visible after parsing the command line arguments.

The motivation for this is that some environments do not support environment variables, which prevents the usage of test sharding. These environments also run on simulators and other slow hardware, where sharding is especially important. I've tried a few other things, like hacking together a fake implementation of `getenv`/`setenv`, but this is a pretty unreliable approach on the platform in question.

This also seems like an improvement in consistency to me. Currently, other test selection mechanisms (e.g. filtering, shuffling, repeat), `use arguments (or at least have command line arguments as an option), while as far as I can tell, sharding is the only mechanism which can *only* be specified with environment variables.

PiperOrigin-RevId: 892324928
Change-Id: I5cf814e46e16072e7c160e54c426b02300fe712b
2026-03-31 07:22:05 -07:00
Abseil Team 5fddfab2d2 Define DieInCRTDebugElse12() inside #ifdef _DEBUG
DieInCRTDebugElse12() is only used inside a #ifdef _DEBUG block. Put
its definition inside a #ifdef _DEBUG block, too, otherwise we get a
"defined but not used [-Wunused-function]" warning under MinGW GCC.

PiperOrigin-RevId: 891795658
Change-Id: Ic9109eebc354dd20b2a5430794f491c9b451931f
2026-03-30 10:47:55 -07:00
Abseil Team 2461743991 Automated Code Change
PiperOrigin-RevId: 890778982
Change-Id: Idef51b737a250560d0b71130e6e87b6249d8c47a
2026-03-27 21:30:37 -07:00
Abseil Team 015950a936 Add an implmenetation of Notification for MinGW
Add an alternative implementation of the Notification class for MinGW
using a Windows manual-reset event object.

GCC version < 13 in MinGW, if configured with the win32 thread model
(with the --enable-threads=win32 configure option), does not implement
std::mutex and std::condition_variable in the <mutex> and
<condition_variable> headers. So the current implementation of the
Notification class, which uses std::mutex and std::condition_variable,
has compilation errors. Windows has a synchronization object called a
manual-reset event object that behaves just like the Notification class.
So we can easily implement the Notification class using a Windows
manual-reset event object.

This GCC issue is fixed in GCC 13. See
https://gcc.gnu.org/gcc-13/changes.html#windows. This alternative
implementation of Notification should be removed when GoogleTest
requires GCC version >= 13 in MinGW.

Fixes https://github.com/google/googletest/issues/4031 and
https://github.com/google/googletest/issues/4464.

PiperOrigin-RevId: 888752598
Change-Id: I69e01b2e7953e1fe72d87b6d0804c7a8a8d0e740
2026-03-24 10:53:29 -07:00
Abseil Team f38004c441 Fix typo in monomorphic matcher documentation.
PiperOrigin-RevId: 886900324
Change-Id: I96832e8162b4631783cf0f2badf160d18d3256f8
2026-03-20 11:42:04 -07:00
Krzysztof Kosiński 94be250af7 Add documentation for two-argument floating point matchers.
PiperOrigin-RevId: 881536386
Change-Id: Idd38bded4dda5a0d0c1c5fd7847fc8134e7c2ece
2026-03-10 11:25:48 -07:00
Abseil Team a35bc7693c Make gmock-matchers.h auto-detect the value_type of ranges that don't have a typedef for it based on the ranges' iterators
This is needed for ranges such as [`std::ranges::subrange`](https://en.cppreference.com/w/cpp/ranges/subrange.html) that don't expose the typical typedefs.

PiperOrigin-RevId: 879124865
Change-Id: Ie89e6ff249ee861d1b2d880079dc162bb9801679
2026-03-05 10:09:30 -08:00
fresh3nough f426a71abf Fix CMake 3.22 crash in find_package(Python3) when Python is absent 2026-02-28 16:19:07 +00:00
Abseil Team 73a63ea05d Improve str concatenation performance on MatchesTest
Update str concatenation, instead of use operation+ use absl::StrCat
whenever available.

PiperOrigin-RevId: 874649732
Change-Id: I0acd91c04a9e50fa306e7130479bc330c1a0f068
2026-02-24 09:27:22 -08:00
Abseil Team a407966592 Revert Optimize copying of matchers vector to speed up ElementsAreArray by reserving a std::vector copied via push_back.
If the iterators are forward iterators, we can measure the size and reserve the vector, avoiding reallocations and copying.

PiperOrigin-RevId: 874172640
Change-Id: Ie081fdf7952858d7e41ddda63a3ae15d9867c8c5
2026-02-23 11:30:44 -08:00
Dillon Sharlet 73e0fc18eb Optimize copying of matchers vector to speed up ElementsAreArray by reserving a std::vector copied via push_back.
If the iterators are forward iterators, we can measure the size and reserve the vector, avoiding reallocations and copying.

PiperOrigin-RevId: 874129590
Change-Id: I6cdcaf38e28ac90c1cf596977b703d8de93994e5
2026-02-23 10:02:03 -08:00
Abseil Team e9907112b4 Update doc for Optional.
Change a mention of Eq(Optional(nullopt)) to Optional(Eq(nullopt)).

Optional is supposed to wrap matchers, not values. For example, Optional("bla") doesn't compile but Optional(std::string("bla")) does. Optional(Eq("bla")) is the functionally correct version. Eq() cannot wrap a matcher.

PiperOrigin-RevId: 872885639
Change-Id: I941f515308fa419162998073f6da9731fcf2168a
2026-02-20 07:10:28 -08:00
Max Shavrick 850cb69efd Add string_view overload to AssertHelper
PiperOrigin-RevId: 871382613
Change-Id: I286ccbf8b8622a740e99642b4ed853e9f67cf51c
2026-02-17 10:26:39 -08:00
Abseil Team 77f6bd3e75 Update comment for SizeIs matcher.
Clarify that SizeIs only requires the container to have a size() method, and the argument type can be any type compatible with the return type of size(). The previous comment incorrectly mentioned a requirement for size_type.

PiperOrigin-RevId: 869184176
Change-Id: Ib2d867fbfecde0006734772cf07958871a171199
2026-02-12 06:25:24 -08:00
Abseil Team f68374efa7 Replacing an internal lib name with absl in test case
PiperOrigin-RevId: 868759119
Change-Id: I85fc3723bb2108d8a3f0ec063e081d93b00ae1bf
2026-02-11 11:12:56 -08:00
Abseil Team ef6cf65af5 Fix typo in Optional(m) description.
PiperOrigin-RevId: 868638000
Change-Id: I952801ff229e4b1d195ef69761de36c34724604e
2026-02-11 06:02:51 -08:00
Derek Mauro 5a9c3f9e8d Upgrade most builds to use Bazel 9.0.0
Keep one build on 8.5.1 to test WORKSPACE

Fixes the -Wdeprecated-declaration warnings
enabled by default in Bazel 9 that come from the
single-arg Invoke().

Fixes the new -Winconsistent-missing-override that
we intentionally use in a test.

Upgrades RE2 to a version compatible with Bazel 9.

PiperOrigin-RevId: 865966282
Change-Id: I5f7c3b60daf5f8a90be08004d96aaa59611e35c4
2026-02-05 08:42:50 -08:00