Skip to content

Commit

Permalink
Only save original working directory if death tests are enabled
Browse files Browse the repository at this point in the history
On a diskless system you cannot get the current directory. So if
death tests are disabled anyway, there is no point trying to
get current directory.

Without this fix, running tests on diskless systems will fail,
even when death tests are disabled.
  • Loading branch information
knutpett authored and Knut Petter Svendsen committed Nov 9, 2020
1 parent 3005672 commit f3ec19b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions googletest/src/gtest-internal-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ 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 @@ -694,6 +695,7 @@ class GTEST_API_ UnitTestImpl {
GTEST_CHECK_(!original_working_dir_.IsEmpty())
<< "Failed to get the current working directory.";
}
#endif

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

0 comments on commit f3ec19b

Please sign in to comment.