Repository navigation
Commit ea41cb2
Cherry-pick: "Eliminate exit-time destructor in TypedTestSuitePState."
Summary:
This is a cherry-pick of commit hash b66cffcd5f5d6ee34a4f96d57bf016d9a22cb023 from googletest upstream.
Github: google/googletest@b66cffc
The original commit summary is:
`TYPED_TEST_SUITE_P` defines a static `TypedTestSuitePState` variable at namespace scope. Storing registered tests in a `std::map<std::string, CodeLocation>` required dynamic initialization, heap allocations, and an exit-time destructor, triggering `-Wexit-time-destructors` warnings in builds that enforce trivial exit.
Store registered tests in an intrusive sorted singly-linked list of static POD `RegisteredTest` nodes defined by `TYPED_TEST_P`. `TypedTestSuitePState` is now `constexpr`-constructible and trivially destructible without heap allocations.
PiperOrigin-RevId: 998634744
Change-Id: I0c833ffeebdf21b155038b7e95e497637e68564a
### Manual Fix
Upstream replaced the internal `TypedTestSuitePState::AddTestName()` with `AddTest(RegisteredTest*, const char*)`, which takes a caller-owned static `RegisteredTest` node. Four Meta-side copies of the old `TYPED_TEST_P` macro still call `AddTestName()` and fail to compile:
```
error: no member named 'AddTestName' in 'testing::internal::TypedTestSuitePState'
```
- `xplat/follyfex/gtest/GTestHelpers.h`: `CO_TYPED_TEST_P` declares a static `RegisteredTest` and registers it with `AddTest()`, matching the new upstream `TYPED_TEST_P`. Fixes `xplat/follyfex/gtest/tests:gtestAndroid`, the `xplat/assistant/oacr/contacts` warm-start tests, and `xplat/rtc/crucible/tests:callSetupFoundation` / `:callSetupRsys`.
- `fbcode/folly/coro/GtestHelpers.h`, `xplat/folly/coro/GtestHelpers.h` (identical copies): `CO_TYPED_TEST_P_` registers through the new `folly::detail::gtestAddTypedTest()`, which calls `AddTest()` when `TypedTestSuitePState::RegisteredTest` exists and falls back to `AddTestName()` otherwise. folly is open source and its getdeps build uses googletest v1.17.0, which predates this change. Fixes `folly/coro/test:gtest_helpers_test` in fbcode and xplat.
- `fbcode/paxi/common/AsyncTest.h`: `TYPED_ASYNC_TEST_P` gets the same change as follyfex. Fixes `fbcode//paxi/api/test:dummy_paxi_log_test`.
CI only flagged the follyfex and contacts targets; the crucible, folly and paxi breaks came from local builds. Test behavior is unchanged.
#build-all
allow-large-files
allow-many-files
### Upstream comparison
All 4 changed googletest files are byte-identical to upstream -- no Meta patches. The Manual Fix files are Meta-side changes and need a normal review.
___
landed-with-radar-review
Differential Revision: D125187238
fbshipit-source-id: 9fb208c40ec0be388bb3f5908d3ccf883d52f7671 parent 3251cd6 commit ea41cb2
1 file changed
Lines changed: 58 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| |||
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
41 | 73 | | |
42 | 74 | | |
43 | 75 | | |
| |||
238 | 270 | | |
239 | 271 | | |
240 | 272 | | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
265 | 299 | | |
266 | 300 | | |
267 | 301 | | |
| |||
0 commit comments