googletest icon indicating copy to clipboard operation
googletest copied to clipboard

[FR]: Surface `delete_environment_on_teardown` via flag

Open gammak opened this issue 4 months ago • 0 comments
trafficstars

Does the feature exist in the most recent commit?

No.

Why do we need this feature?

The commit (https://github.com/google/googletest/commit/64be1c79fa2cea015d816687120878a110775351) added logic to delete test environments during normal test Teardown (rather than during static teardown). This was added to fix tests where Environments were doing threading operations, and the above commit started to join those threads earlier than the end of the program to avoid the cases where thread-joining was causing issues during destruction.

As the commit acknowledges, though, this was a breaking change for users who call RUN_ALL_TESTS multiple times: any tests which do that call multiple times face failures due to potential early-destruction of their environments.

Describe the proposal.

Given that the delete_environment_on_teardown logic is already gated behind a bool, adding a program flag to opt-out of that behavior would allow users to use the previous behavior where static teardown still manages the Environment lifetimes.

This flag could still use the new behavior by default, but having the explicit opt-out path would enable a self-service fix path for users broken by the above change.

Is the feature specific to an operating system, compiler, or build system version?

No, the logic in question is shared across platforms.

gammak avatar Jul 10 '25 18:07 gammak