Skip to content

Commit

Permalink
original_working_dir is needed even when death tests are disabled
Browse files Browse the repository at this point in the history
UnitTest::GetInstance()->original_working_dir() is documented public API:
https://github.com/google/googletest/blob/main/docs/reference/testing.md#original_working_dir-unittestoriginal_working_dir

and is used for things like UnitTestOptions::GetAbsolutePathToOutputFile.
So stubbing it to just return an empty string breaks many other unit tests
unnecessarily if you have a filesystem but not death tests

If there's a need to do something special for diskless systems,
seems like they should have a distinct check.

reverts e5686bb
google#3090
See google#3869 for discussion

This has now been reverted (and refactored) on `main` by google#3682,
but the refactoring is more complex than I want to cherry-pick.
So we will keep the simple revert for 0.12.1
  • Loading branch information
puetzk committed Sep 26, 2022
1 parent a0b61ca commit 3486adf
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions googletest/src/gtest-internal-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,6 @@ class GTEST_API_ UnitTestImpl {
void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc,
internal::TearDownTestSuiteFunc tear_down_tc,
TestInfo* test_info) {
#if GTEST_HAS_DEATH_TEST
// In order to support thread-safe death tests, we need to
// remember the original working directory when the test program
// was first invoked. We cannot do this in RUN_ALL_TESTS(), as
Expand All @@ -681,7 +680,6 @@ class GTEST_API_ UnitTestImpl {
GTEST_CHECK_(!original_working_dir_.IsEmpty())
<< "Failed to get the current working directory.";
}
#endif // GTEST_HAS_DEATH_TEST

GetTestSuite(test_info->test_suite_name(), test_info->type_param(),
set_up_tc, tear_down_tc)
Expand Down

0 comments on commit 3486adf

Please sign in to comment.