4380 Commits

Author SHA1 Message Date
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
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
Michael Leslie
f57505314b only apply -lregex for qnx710 and newer 2024-01-10 11:48:14 -08:00
Derek Mauro
7c07a86369 Update CI builds to use Bazel 7.0.0
--features=external_include_paths has been removed from Windows builds
since it appears cause build command errors currently
PiperOrigin-RevId: 597020418
Change-Id: Ie37be0d05f3a154ab0d3c3f7d39b4e2c0ed650a3
2024-01-09 13:02:32 -08:00
Abseil Team
7f409cb3c0 Add a note about argv requiring NULL termination.
Fixes: #4434
PiperOrigin-RevId: 596960654
Change-Id: I1f70cc0801764fe0328030c46254f82eb9893a49
2024-01-09 09:39:16 -08:00
Krzysztof Kosiński
3b26f7e53b Disable -Wfloat-equal in AppropriateResolution().
This function makes exact floating point that are correct in this context, but trigger the compiler warning.

PiperOrigin-RevId: 596944060
Change-Id: I4bba3c2abcf3ac189107530978961955ad47d6f0
2024-01-09 08:39:28 -08:00
kaswhy
dda72ef321 Docs: add conditions for calling TearDown() 2023-12-29 02:05:18 +09:00
Abseil Team
dddb219c3e Accept move-only callables in InvokeArguments
PiperOrigin-RevId: 594223533
Change-Id: I491fae7d851d4e0df07fb3627416949071fec8d6
2023-12-28 04:04:00 -08:00
Abseil Team
96eadf659f Minor documentation correction.
PiperOrigin-RevId: 593126348
Change-Id: I78e12ab5dd2e5acc69b21250bdb04e62990b6309
2023-12-22 08:51:16 -08:00
Derek Mauro
cde9a745a6 Fix broken links in primer.md
Closes #4432

PiperOrigin-RevId: 592335698
Change-Id: I9859451981f58f1426255067d702a0767718b1d5
2023-12-19 13:56:36 -08:00
Abseil Team
8495449f07 Fix data race in leak detection
TSAN identified a data race between updates to the states_ map (ex. in Mock::UnregisterLocked) and the iteration done in this destructor. Writes to the map use g_gmock_mutex, but the destructor does not acquire it. Acquiring the lock here fixes the data race.

It should only be possible to trigger this TSAN finding in cases where a mock object is deleted by a thread other than the main thread.

PiperOrigin-RevId: 591935393
Change-Id: I9dd1faa40058d78e165a91333346514b4b73365c
2023-12-18 10:14:49 -08:00
Abseil Team
530d5c8c84 Add FAIL_AT macro variant of FAIL matching ADD_FAILURE, ADD_FAILURE_AT
`FAIL_AT` is shorthand for `GTEST_FAIL_AT` like `FAIL` is for `GTEST_FAIL`.

PiperOrigin-RevId: 590393926
Change-Id: I68263af8fa2f98ca0bbef509d475c84e22068018
2023-12-12 17:40:45 -08:00
Tom Hughes
eb80f759d5 Remove unnecessary conversion
`GetAbsolutePathToOutputFile` returns a `std::string` and `OpenFileForWriting`
takes a `std::string&`.

PiperOrigin-RevId: 589984409
Change-Id: I75be9cb105f49b3a279a5d33b1b82dfcfc912cfd
2023-12-11 16:17:28 -08:00
Copybara-Service
b3a9ba2b8e Merge pull request #4426 from tamaskenez:cmake_external_absl_re2
PiperOrigin-RevId: 587836393
Change-Id: Ia8895898bd0a826b35dc0ebedd8c76503bc8cd43
2023-12-04 14:11:54 -08:00
Derek Mauro
8760db154a Skip find_package(Python3) when not building tests
#4424 claims this saves several seconds of build time
Closes #4424

PiperOrigin-RevId: 587827426
Change-Id: I207779a6539f9af16a39d6b40887770dc930b74f
2023-12-04 13:42:25 -08:00
Tamas Kenez
48b373f6e0 Allow using external absl and re2. 2023-12-01 23:09:53 +01:00
Abseil Team
76bb2afb8b Implement testing::Rethrow to throw exceptions more easily via std::exception_ptr
We avoid overloading or specializing `testing::Throw` as this is fundamentally a different operation than throwing the object.
However, we disable the corresponding overload of `testing::Throw` to prevent likely mistakes in the usage.

Fixes: #4412
PiperOrigin-RevId: 585745469
Change-Id: I03bb585427ce51983d914e88f2bf65a13545c920
2023-11-27 13:32:49 -08:00
Copybara-Service
b10fad38c4 Merge pull request #4397 from botovq:raise
PiperOrigin-RevId: 577958594
Change-Id: I8a27f67dc5b6817b741bfd2fc0f27c6302291a00
2023-10-30 14:33:13 -07:00
Abseil Team
5b7fd63d6d Export gmock-spec-builders.
gmock.h is the umbrella header to be used for rest of the library, and it also
enables users to export certain details. This wasn't working for some interfaces
like EXPECT_CALL because gmock-spec-builders wasn't explicitly exported.

PiperOrigin-RevId: 576966583
Change-Id: Ie050430cf11384977cd95f4ed6e73235d6857057
2023-10-26 13:15:23 -07:00
Theo Buehler
7f036c5563 Add missing include for raise(3)
If SIGTRAP is defined, this file may end up using raise(3), which is
defined in csignal, leading to a compilation failure on at least
OpenBSD/sparc64 with gcc 8.
2023-10-25 07:52:23 +02:00
Dino Radakovic
518387203b StartsWith: Explicitly construct matcher-typed strings from matchee parameter
The current implementation breaks for absl::string_view on gcc, c++14: https://godbolt.org/z/Tzd3q1fqx

Closes #4391

PiperOrigin-RevId: 575853981
Change-Id: I7b782598add480eb69d4ca27ea4a4bf5f758f6a3
2023-10-23 10:11:36 -07:00
Abseil Team
116b7e5528 Improve error message for invalid parameterized test names.
PiperOrigin-RevId: 574992011
Change-Id: Id6030a9e5f317966186cc48ef2c09ad97fa15d3e
2023-10-19 13:55:15 -07:00
Abseil Team
9bb354fa83 s/::testing::/testing::/ in test documentation outside of using statements to align with best practice
PiperOrigin-RevId: 574377544
Change-Id: I0ca69a3bf14cc1aab75784eba220a48bf50cef04
2023-10-17 23:50:43 -07:00
Dino Radakovic
829c19901d gtest-death-test-internal: Delete obsolete string constants
These are not used anywhere in googletest and they are in namespace `testing::internal`

PiperOrigin-RevId: 574171727
Change-Id: I5f668157a81ba3efaed77c1302b40cf07eeda52b
2023-10-17 09:18:52 -07:00
Abseil Team
2dd1c13195 Fix RE::Init for Android and NetBSD.
This is a somewhat recent change for Android (I'm not clear on whether it's a recent change for NetBSD, or if Android was just very behind on its implementation), so while this worked fine as recently as API 32 devices, REG_GNU is required for API 34 (API 33 untested).

A test actually caught this, but https://github.com/google/googletest/pull/4334 "fixed" the test rather than the implementation. This CL also reverts the test change so it can catch the failure.

PiperOrigin-RevId: 571126374
Change-Id: I420dfcedea58f2c8b605f699515d744006c0a9d9
2023-10-05 14:13:04 -07:00