3930 Commits

Author SHA1 Message Date
Derek Mauro
58d77fa807
Updates the version number in CMakeLists.txt to 1.12.1 (#3919)
Due to an oversight version 1.12.0 didn't update the version in
CMakeLists.txt. A patch release will fix this issue.

I've also added a note to instructions for creating a release to check
for this issue.
release-1.12.1
2022-06-27 13:14:55 -04:00
Derek Mauro
15460959cb Update versions of WORKSPACE dependencies
PiperOrigin-RevId: 456532035
Change-Id: I60fa4d4e7827516d317ce893377d1f72e49c6a2f
release-1.12.0 v1.12.0-pre v1.12.0
2022-06-22 09:23:46 -07:00
Derek Mauro
7df7853ea0 Update GCC floor container used by CI to fix the Bazel cache error
PiperOrigin-RevId: 456323043
Change-Id: I86e3d52b72b51c2d4e96f536daa7f84a52c598f5
2022-06-21 12:27:37 -07:00
Derek Mauro
86add13493 Disable warning C4251 around refactored code
PiperOrigin-RevId: 455452553
Change-Id: I1dc3772ae61daf6d2d39484a0b1aad7eb0134525
2022-06-16 13:18:32 -07:00
Copybara-Service
191ca1f3a9 Merge pull request #3863 from eidosmontreal:fix_unused-variable_warning
PiperOrigin-RevId: 454940948
Change-Id: Ic87dadfe9c6fc8882b0f425aa2056f0cc7a90b55
2022-06-14 13:24:55 -07:00
Abseil Team
8b521aa43a gmock_cook_book.md: Delete superfluous statement from 2014.
PiperOrigin-RevId: 454677195
Change-Id: I7a1419e22d617db41a5c310bc6f6158ba4cec1ab
2022-06-13 12:51:26 -07:00
Copybara-Service
b644b4fbbf Merge pull request #3866 from eidosmontreal:simplify_shouldusecolor
PiperOrigin-RevId: 454616721
Change-Id: I33b5671646ec027da48cc941baf84b4ddc722e07
2022-06-13 08:38:29 -07:00
Gaspard Petit
fe735a6986 Move declaration of kStdOutFileNo and kStdErrFileno
Move declaration of kStdOutFileNo and kStdErrFileno closer to where they are used to avoid having to guard for GTEST_HAS_STREAM_REDIRECTION twice
2022-06-11 10:26:41 -04:00
Abseil Team
b1f84bf176 Update googletest docs to indicate that RE2 is now used for regexp implementation when building with Bazel and using Abseil.
PiperOrigin-RevId: 454012698
Change-Id: I3a9df78368ffe3cb7cf3d315001125b97b1aebbe
2022-06-09 14:25:17 -07:00
Abseil Team
49c6185ae7 Remove undefined internal function.
Fixes #3856

PiperOrigin-RevId: 453992227
Change-Id: I5f3330a454bdcd6b0522ebba4cdfe2c888f8e638
2022-06-09 12:57:51 -07:00
Derek Mauro
0320f517fd Work around a maybe-uninitialized warning under GCC 12
Some Mock constructors insert the pointer to the Mock itself into a
global registry. Since GCC cannot see how the pointer is used (only as
an identifier), it cannot tell that the object doesn't need to be
initialized at that point at all. Work around this by using uintptr_t
instead.

PiperOrigin-RevId: 452380347
Change-Id: Ia5a493057ed90719de1d0efab71de9a8a08ddf8b
2022-06-01 14:08:04 -07:00
Abseil Team
548b13dc3c Fix internal files
PiperOrigin-RevId: 452053766
Change-Id: I9498e8809f5e66e42cfa365199a5bbc41462a533
2022-05-31 08:33:31 -07:00
Gaspard Petit
3727a90075
Merge branch 'google:main' into simplify_shouldusecolor 2022-05-30 22:01:15 -04:00
Gaspard Petit
900c3f9cd5
Merge branch 'google:main' into fix_unused-variable_warning 2022-05-30 22:00:02 -04:00
Aaron Jacobs
e649993a40 gmock-spec-builders: remove the name for an unused parameter.
This fixes unused parameter errors under both MSVC and clang (when
`-Werror=unused-parameter` is used, as reported
[here](9d21db9e0a (r74769946))).

Fixes #3858

PiperOrigin-RevId: 451907906
Change-Id: Ic07da19ea6a547eb1797fbbab19cd57cc2a83fe8
2022-05-30 12:46:59 -07:00
Gaspard Petit
59006287cd Simplify ColoredPrintf to rely on ShouldUseColor
Use ShouldUseColor to set use_color instead of having a separate check for the windows mobile cases; these cases are now moved directly to `DoIsATTY`
2022-05-30 14:19:50 -04:00
Gaspard Petit
410e5f9e04 Fix "unused variable" warning
Fix "unused variable" warning when GTEST_HAS_STREAM_REDIRECTION is set to false in gtest-port.cc
2022-05-30 11:04:54 -04:00
Aaron Jacobs
9d21db9e0a gmock-spec-builders: add support for non-moveable types.
Do this by ripping out the "untyped perform action" machinery, which isn't
necessary: we can simply template the entry point on the result type, and use
RAII to avoid the need to special case void. This makes it easier to understand
the code and harder to introduce type-related undefined behavior, to boot.
PiperOrigin-RevId: 451493451
Change-Id: I225305f83164752ca92f2916721972eafba33168
2022-05-27 15:25:37 -07:00
elixir
6cd3823783 Clarify that this-> is needed to access members of type-parameterized tests.
PiperOrigin-RevId: 451439108
Change-Id: I8929df21d53cbe6c42e38653e1bb0cac72fc36f9
2022-05-27 11:32:10 -07:00
Aaron Jacobs
28356773cb gmock-actions: properly support non-moveable results in is_callable_r.
Previously this excluded callables that return non-moveable types. This is the
same as the
[libc++ std::is_invocable_r bug](https://github.com/llvm/llvm-project/issues/55346)
fixed by
[this commit](https://github.com/llvm/llvm-project/commit/c3a24882903d): it's
wrong to use std::is_convertible for checking the return type, since (despite
its name) that doesn't check the standard-defined notion of "implicitly
convertible". Instead we must base the check on whether the source type can be
used as an argument to a function that accepts the destination type.

PiperOrigin-RevId: 451341205
Change-Id: I2530051312a0361ea7a2ce26993ae973c9242089
2022-05-27 02:23:49 -07:00
Aaron Jacobs
56246cdb94 gmock-spec-builders: move a method to the header.
In order to make the diff more readable in an upcoming commit that requires the
method to be templated on the action's result type.

PiperOrigin-RevId: 451157029
Change-Id: I57beb7544efccd0459efb3a1f039ea45cd7c7602
2022-05-26 07:25:17 -07:00
Abseil Team
cf942a5d69 Update GoogleTest documentation's spelling of "GoogleTest".
PiperOrigin-RevId: 451067898
Change-Id: I658ab92c4ea616736f0170ac4d1548bb15a944e2
2022-05-25 19:18:09 -07:00
Abseil Team
7041051488 Clarify the pitfalls of EXPECT_THAT and highlight it's best practices
PiperOrigin-RevId: 450721917
Change-Id: I34d63a65b7158975abd46a9a14cded75439e7e7f
2022-05-24 10:57:53 -07:00
Dino Radakovic
8d51dc50eb gmock-internal-utils.cc: Avoid implicit conversion from int to char
Fixes #3832

PiperOrigin-RevId: 449158813
Change-Id: Ibe85239ab1f123097b2c1b61616c9d611e5b90d0
2022-05-17 01:37:27 -07:00
Aaron Jacobs
5126f71661 gmock-actions: add support for move-only values to Return.
`Return(x)` can now be used directly with `WillOnce` (the only place it makes
sense in the type system), without using `ByMove`.

PiperOrigin-RevId: 448380066
Change-Id: Ia71cc60ccbc3b99720662731a2d309735a5ce7c8
2022-05-12 17:55:11 -07:00
Abseil Team
8a011b8a38 Add clarifying comments about when to use EXPECT_NONFATAL_FAILURE vs. EXPECT_FATAL_FAILURE.
PiperOrigin-RevId: 448237839
Change-Id: Id6242f278912f8c47cf19e3ea8c061f8b18ba832
2022-05-12 06:58:02 -07:00
Aaron Jacobs
cbca6bc395 gmock-actions: provide a const reference when converting in ReturnAction.
It doesn't make semantic sense for the conversion to modify the input, and the
fact that it's allowed to do so appears to have just been a historical accident.

PiperOrigin-RevId: 448135555
Change-Id: Id10f17af38cf3947ee25fe10654d97527173ebfc
2022-05-11 19:01:15 -07:00
Abseil Team
5e6a533680 Do a consistent way of searching for a temporary directory.
The way temporary directories were discovered from
environment variables in different operating systems
was inconsistent.

On Windows, only the system-specific environment variable
TEMP was considered, but not the bazel-common TEST_TMPDIR.
On Unix, only TEST_TMPDIR was considered, but not
the otherwise typical system specific TMPDIR.

Now, always consider TEST_TMPDIR first, followed by the
system-typical environment variable (TEMP on Windows, TMPDIR on Unix)
before falling back to a default on that particular system.

Also: the value for the temporary directory coming from the
environment variable was only checked for a trailing directory
separator on Windows (and appended if needed), not on the other
platforms.
Make this also consistent accross the systems: Now always apply
the same logic to all of these (to accomodate
tests that just concatenate TempDir() without directory separator).
PiperOrigin-RevId: 447909830
Change-Id: I9ea17acdf5944eb2a965615fd9cf142878c33a58
2022-05-10 22:43:09 -07:00
Aaron Jacobs
4224c770a3 gmock-actions: simplify Return and add better documentation.
Better document requirements, API decisions, and historical accidents. Make an
implicit conversion easier and in a more appropriate place, and ease the burden
of some assertions in the conversion operator. Stop using the legacy
ActionInterface style for defining the action.

PiperOrigin-RevId: 447894892
Change-Id: I179e23ec2abdd9bf05c204ab18dbb492f1372e8e
2022-05-10 20:41:04 -07:00
Aaron Jacobs
6386897feb gmock-actions: make OnceAction public.
So that it can be referenced in conversion operators for actions that need to
know the concrete return type.

PiperOrigin-RevId: 447889344
Change-Id: I643d3298bc8effd08741282a956c221f9d67d378
2022-05-10 20:08:51 -07:00
Abseil Team
bda85449f4 Fixup some missing overrides in googletest.
This CL adds a couple missing overrides in the googletest sources.
These were found downstream when -Wsuggest-override and
-Wsuggest-destructor-override were enabled.

PiperOrigin-RevId: 447754883
Change-Id: I7bf35a8757cbc5ae157827037aa3d13f47392406
2022-05-10 09:39:26 -07:00
Copybara-Service
4348d4efed Merge pull request #3818 from joshiayush:typo
PiperOrigin-RevId: 447003874
Change-Id: Ide8d879f6c939dbf4c10cc6d515c175d9b691e0c
2022-05-06 09:27:29 -07:00
Abseil Team
2a02723b76 Fix example of DescribeMatcher to properly support negation.
PiperOrigin-RevId: 446259163
Change-Id: I3ad5f405f44fc233f5cf5a18a274a9104b5c4ab8
2022-05-03 12:18:27 -07:00
Abseil Team
0027cf4703 Use TEST_TMPDIR on MacOS as well if available.
Currently MacOS falls back to generic /tmp, but
for all intents and purposes it should behave like
other Unixes using the TEST_TMPDIR environment variable
if available (this environment variable is set in bazel,
which sets up a unique temp directory for the test
process).

While at it, remove an incorrect #endif comment, that
looks like a leftover from some older implementation.

PiperOrigin-RevId: 446108391
Change-Id: I118eacf6e86a41d26cb81a130f7c54cccc0c5665
2022-05-02 21:57:01 -07:00
Aaron Jacobs
42ca3da579 gmock-actions: remove a no-longer-necessary friend declaration.
PiperOrigin-RevId: 445940487
Change-Id: I26952a72327db0d308bbe57ca4d1d91a0d7defc8
2022-05-02 08:37:49 -07:00
Aaron Jacobs
5176726123 gmock-actions: support ByMove in a specialization of ReturnAction.
Rather than branching on whether the return type is ByMoveWrapper within
ReturnAction itself, hoist the distinction to outside. This allows the main
class template to be modified without worrying about this special case, which
means we can stop using a shared pointer to the value (introduced as a
linked_ptr in commit 3d1c78b2bf to support ByMove) in this commit and simplify
the class template further in a future commit with the eventual aim of directly
supporting move-only result types.

PiperOrigin-RevId: 445938943
Change-Id: I7bc71ea301d5e493ac6ecbe57d62738a48a2721a
2022-05-02 08:30:07 -07:00
Ayush Joshi
fae793c101 Fix typo in the test name of NormalizeTest
Signed-off-by: Ayush Joshi <ayush854032@gmail.com>
2022-04-30 20:59:00 +05:30
Abseil Team
8ded48c37b Rewrite "Testing a Certain Property of an Object" as "Defining a Custom Matcher Class", and fix the code examples.
PiperOrigin-RevId: 445252626
Change-Id: I9f038cb669d3da6743606343c2341fc59725d722
2022-04-28 14:41:49 -07:00
Aaron Jacobs
830fb56728 gmock-actions: improve comments and tests for the implicit cast in Return.
Commit a070cbd91c added an implicit cast to this path but didn't leave a very
clear explanation for why it was desirable, a clear example, or even test
coverage. Add a better comment and a test that fails when the implicit cast is
removed.

PiperOrigin-RevId: 444871311
Change-Id: I127982fa8d5bce9b6d1b68177c12dc0709449164
2022-04-27 08:49:18 -07:00
Aaron Jacobs
c144d78f82 Support move-only and &&-qualified actions in WithArgs.
PiperOrigin-RevId: 444671005
Change-Id: I7df5f038caf17afb60d4fb35434ff0b656d4c954
2022-04-26 14:39:37 -07:00
Derek Mauro
e33c2b24ca Use RE2 for the regex implementation when building with Bazel and using Abseil
bazel build --define=absl=1 ...

A dependency on RE2 is now required when building GoogleTest with Abseil.
Using RE2 will provide a consistent cross-platform regex experience.

Users will need to add the com_googlesource_code_re2, bazel_skylib,
and platforms repository to their WORKSPACE files. See our WORKSPACE
file in the root directory of this project for an example of how to
add the dependencies.

Please note that the com_googlesource_code_re2 dependency must use a
commit from the `abseil` branch of the project:
https://github.com/google/re2/tree/abseil

PiperOrigin-RevId: 444650118
Change-Id: I45c55b26684c0c50d721a05b81c5f8a0c092400f
2022-04-26 13:27:20 -07:00
Abseil Team
238e4745c6 Generalize gmock-matchers_test to handle is_gtest_matcher-style matchers, too.
PiperOrigin-RevId: 444586594
Change-Id: I0de9b40b3773e3047a492f050266967ea935ae3e
2022-04-26 09:49:03 -07:00
Aaron Jacobs
0498660ea5 Support move-only and &&-qualified actions in DoAll.
This is necessary for generic support of these actions, since `DoAll` is a
frequently-used action wrapper.

PiperOrigin-RevId: 444561964
Change-Id: I02edb55e35ab4207fbd71e371255a319c8253136
2022-04-26 08:05:34 -07:00
Copybara-Service
b53547bf01 Merge pull request #3797 from glandium:issue3514
PiperOrigin-RevId: 444444700
Change-Id: I8ac5cc96cc6eb9d583fa7e3fb304ef3dcaa95b5b
2022-04-25 20:29:56 -07:00
Derek Mauro
bf66935e07 Remove the legacy internal GTEST_DISALLOW_* macros
PiperOrigin-RevId: 443715444
Change-Id: I3ffd54b63d2728ae4a668ee7875c8c3c8188087c
2022-04-22 11:26:03 -07:00
Derek Mauro
b85864c647 Eliminate the legacy GTEST_COMPILE_ASSERT_ macro
PiperOrigin-RevId: 443462203
Change-Id: I0c43f981663a7531ff5da4d4be01fb3d6762273d
2022-04-21 13:23:32 -07:00
Mike Hommey
d5ad28dbe1 Always initialize fields in MatcherBase constructors
This fixes -Wuninitialized warnings with GCC.

Fixes #3514.
2022-04-20 10:42:11 +09:00
Copybara-Service
8ccdb9d56d Merge pull request #3791 from MR-A0101:patch-1
PiperOrigin-RevId: 442609985
Change-Id: I4239171ef8a671ef6d548ba94e02104c5f0ecd36
2022-04-18 12:57:03 -07:00
Aaron Jacobs
80600e56cc Document two surprises in DoAllAction::NonFinalType.
PiperOrigin-RevId: 441589196
Change-Id: Ic3e483ca70d72261046bad464d817f9dfd4bec65
2022-04-13 15:04:29 -07:00
Abseil Team
733f875989 Replace infinite recursion call (intentionally invoking undefined behavior to indicate unreachability) with explicit unreachability marker.
PiperOrigin-RevId: 441474979
Change-Id: I1fcbb437026631212fec954c663482bb7e1cf819
2022-04-13 07:28:00 -07:00