4451 Commits

Author SHA1 Message Date
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
Dino Radakovic
beb552fb47 gmock_cook_book: Document DoAll's return type requirement
The requirement is vaguely  documented by "Only the return value of the last action in the sequence will be used.".
However, this can be misleading, as users could potentially expect default-constructed values to be returned in absence of a matching return type.

PiperOrigin-RevId: 570450839
Change-Id: Ibd98a6e6b2aaf2a8cfc15ed6aeab442526eab98e
2023-10-03 11:41:48 -07:00
Copybara-Service
a6d7fa8c0c Merge pull request #4382 from idzm:fix_cmake_comments
PiperOrigin-RevId: 570161165
Change-Id: Idf7eafb163bb067b0031e25a183d5c9cc3e3f378
2023-10-02 13:30:23 -07:00
Dzmitry Ivaniuk
2d09ed35cf cmake: Fix comments in cmake files
Remove extra spaces. Fix so that the comment line starts with a capital letter and ends with a dot.
2023-09-29 17:26:23 +03:00
Abseil Team
e47544ad31 Resolve -Wundef triggering on GTEST_CREATE_SHARED_LIBRARY and GTEST_LINKED_AS_SHARED_LIBRARY with shared libraries in GoogleTest
Fixes: #4372
PiperOrigin-RevId: 568327612
Change-Id: Ifc47f1a2a2648c29858a22966331557cc928cc47
2023-09-25 14:38:01 -07:00
Copybara-Service
5bd0f08e0d Merge pull request #4374 from masbug:main
PiperOrigin-RevId: 568317621
Change-Id: Icf7fb519f96f5e88eb0df491eed143134c8ac6eb
2023-09-25 14:00:54 -07:00
Abseil Team
e40661d89b Update C++ feature detection in gtest-port.h to rely on feature test macros where possible.
This also avoids conflating C++ language versions with standard library versions, which don't always align.

PiperOrigin-RevId: 567662118
Change-Id: I7c023bd043c81c540c9430eaeb7b450feaadb206
2023-09-22 10:46:16 -07:00
Abseil Team
80306a7b5e Use absl::HasAbslStringify, instead of the internal version.
PiperOrigin-RevId: 567349341
Change-Id: I35f2679901aecbe9cb90d2e78ff28c5e383e7257
2023-09-21 10:32:25 -07:00
Dino Radakovic
167a2255ae googletest: Update absl to version with HasAbslStringify
9e1789ffea

PiperOrigin-RevId: 567324946
Change-Id: I8adc5803a81075a635dad79aa0312d4455e1ad63
2023-09-21 09:08:09 -07:00
Mitja Spes
e27b194c27 Fix compile warnings in gmock-function-mocker.h
Template type int changed to size_t.
This fixes compile warning `conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result` in gmock-function-mocker.h.
2023-09-21 10:06:21 +02:00
Abseil Team
adc5145386 Update code with IWYU annotations.
PiperOrigin-RevId: 566424331
Change-Id: I0e16d979b9d79643c882c5082e154842983a5317
2023-09-18 15:04:08 -07:00
Abseil Team
8be20cce69 Use the empty() method to check for emptiness instead of length()
PiperOrigin-RevId: 566247438
Change-Id: I8199ef53310a057abbe23f8f4295507b60d6b707
2023-09-18 03:20:19 -07:00
Michael Hirshleifer
d1467f5813 GoogleTest FAQ: minor punctuation fixes
PiperOrigin-RevId: 565411290
Change-Id: I57e94c679183e39eec2a2835f330b52fc9302767
2023-09-14 10:37:04 -07:00
Michael Hirshleifer
728ec52d21 Remove Googletest FAQ entry for obsolete ProtocolMessageEquals and ProtocolMessageEquiv
* These long-dead variants of the proto matchers don't exist in the current version of Googletest.
* No evidence of external usage: [the only external references I see](https://www.google.com/search?q=%22protocolmessageequals%22+OR+%22protocolmessageequals%22) are copies of this guide. Possibly they were already removed by the time Googletest was publicly released.

PiperOrigin-RevId: 565358401
Change-Id: I61379b7333fa8ee19cd5520caedf2c539f54c2d7
2023-09-14 07:13:20 -07:00
Copybara-Service
af5ddbde4d Merge pull request #4342 from tanzislam:prefer-tmpdir-on-android
PiperOrigin-RevId: 565230380
Change-Id: I6e91eea46d05413d4d87e73a11941786604d9f27
2023-09-13 19:36:52 -07:00
Copybara-Service
eab0e7e289 Merge pull request #4365 from tanzislam:fix-thread-count-after-thread-creation
PiperOrigin-RevId: 564472305
Change-Id: I8db9bc0ba0768e7ab9c67f36d9db87edbbf14f10
2023-09-11 12:46:26 -07:00
Tanzinul Islam
b86bf840d1 Count threads after thread-creation while still holding mutex lock
The `Mutex` is locked with the `MutexLock` before spawning the thread, so that the thread is prevented from completing (by being blocked on `Mutex`) before the new thread count is obtained. However, the existing bug (introduced in 22e6055) releases `Mutex` before obtaining the new thread count, which allows the thread to run to completion in the meantime.

Also, since the `(thread_count_after_create != starting_count + 1)` condition (line 328) skips the remainder of the `for`-loop body on every iteration, `thread_count_after_join` stays uninitialized.

I believe this is why [this test failed][1] on the macOS CI with this trace:

```
[----------] 1 test from GetThreadCountTest
[ RUN      ] GetThreadCountTest.ReturnsCorrectValue
googletest/test/googletest-port-test.cc:350: Failure
Expected equality of these values:
  thread_count_after_create
    Which is: 1
  starting_count + 1
    Which is: 2

googletest/test/googletest-port-test.cc:351: Failure
Expected equality of these values:
  thread_count_after_join
    Which is: 140493185949400
  starting_count
    Which is: 1

[  FAILED  ] GetThreadCountTest.ReturnsCorrectValue (2 ms)
[----------] 1 test from GetThreadCountTest (2 ms total)
```

[1]: https://github.com/google/googletest/actions/runs/6064919420/job/16453860690?pr=3049
2023-09-03 16:46:02 +01:00
Tanzinul Islam
edf9b4964d Reuse TempDir() function 2023-08-26 08:53:45 +01:00
Dino Radakovic
8a6feabf04 googletest: Add universal printer for std::span
Fixes #4318

PiperOrigin-RevId: 560089120
Change-Id: I9d0d098140033520266747a1689e953ee8307c47
2023-08-25 07:46:02 -07:00
Copybara-Service
460ae98267 Merge pull request #4349 from sthd:httpToHttps
PiperOrigin-RevId: 559452348
Change-Id: I6f72001fd6b8e5a739c34121c8847c281d563b0f
2023-08-23 09:30:13 -07:00
sthd
f0eae4b399 changed http to https 2023-08-22 20:58:34 +03:00
Copybara-Service
cb5cd96bca Merge pull request #4343 from sthd:http-to-https
PiperOrigin-RevId: 559151399
Change-Id: I8eb2c7c5222d0fd0935db531a0abe5792633fe7e
2023-08-22 10:24:02 -07:00
Dino Radakovic
c374da15c5 googletest: Replace http with https in links to docs
This is a prerequisite for #4341

PiperOrigin-RevId: 559132807
Change-Id: Iadc961913e0ff107c5333dae17be5f8638663836
2023-08-22 09:21:04 -07:00
Derek Mauro
61332bd7e8 CI: Update the Linux hybrid-latest docker container used for testing
The following are the major updates
  * LLVM 17 branch (https://github.com/llvm/llvm-project b744f4c99cf91155c74a3c92db6f1335232ff3d)
  * GCC 13.2
  * CMake 3.27.1
  * Bazel 6.2.1

PiperOrigin-RevId: 558818264
Change-Id: Ib08d8331e2a8b2d68a702670451beaaac5d266f4
2023-08-21 09:50:40 -07:00
Abseil Team
762d3a7f66 Clean up typos: Exhaused => Exhausted
PiperOrigin-RevId: 558801066
Change-Id: Ia225d12014748db87639414f4c8c28a0d0e9e489
2023-08-21 08:47:54 -07:00
Elior Schneider
c759a58a2d
Merge branch 'google:main' into http-to-https 2023-08-20 09:39:17 +03:00
Elior Schneider
722daa3da6
Update advanced.md
http to https
2023-08-20 09:38:57 +03:00
Copybara-Service
9fce548044 Merge pull request #4322 from pgawro:ansi_colors
PiperOrigin-RevId: 558224853
Change-Id: Ib2d8ad41fcc4d38f58aa5702b537467d8867d82e
2023-08-18 12:59:42 -07:00
Tanzinul Islam
14d05f4708 Prefer $TMPDIR to /data/local/tmp on Android
Newer devices can have the latter location read-only. (I observed this with Termux on a non-rooted Pixel 6.)
2023-08-18 19:44:48 +01:00
Elior Schneider
5e47c767ff
Merge branch 'google:main' into http-to-https 2023-08-18 16:34:00 +03:00
Abseil Team
f42da0e443 Improve error message for invalid parameterized test names.
PiperOrigin-RevId: 557910190
Change-Id: Ia965a6c96e4cc5997d8af2611abc62c42e81653e
2023-08-17 12:56:29 -07:00