Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only save original working directory if death tests are enabled #3090

Merged
merged 1 commit into from
Nov 10, 2020

Conversation

knutpett
Copy link
Contributor

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.

Solves #3089

@google-cla google-cla bot added the cla: yes label Oct 29, 2020
@knutpett
Copy link
Contributor Author

Seems like the appveyor build timed out on windows. How can I rerun?

@kuzkry
Copy link
Contributor

kuzkry commented Nov 8, 2020

Hi @knutpett, the easiest way is to pretend you touched your commit by executing:

  1. git checkout working_dir_on_diskless
  2. git commit --amend and immediately close an editor
  3. git push --force ... onto the same branch.

@knutpett knutpett force-pushed the working_dir_on_diskless branch from e4f31a8 to f3ec19b Compare November 9, 2020 08:30
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.
@knutpett knutpett force-pushed the working_dir_on_diskless branch from f3ec19b to e5686bb Compare November 9, 2020 09:05
@knutpett
Copy link
Contributor Author

knutpett commented Nov 9, 2020

I keep getting "24 - googletest-param-test-test (Timeout)
ctest.exe : Errors while running CTest" from appveyor. Is introduced by me, or is this a known problem with this test timing out?

I've touched the PR twice, but I keeps on failing....

@CJ-Johnson
Copy link
Contributor

My apologies for the failing tests. It's a known issue and we've had trouble resolving it. For now, all that is required is the CLA and Travis.

Would you like us to import this PR? We can do additional internal testing, but importing it implies that the PR cannot be updated further.

@knutpett
Copy link
Contributor Author

knutpett commented Nov 9, 2020

@CJ-Johnson Yes, I'm happy with you importing this PR :)

@CJ-Johnson
Copy link
Contributor

Thank you for this PR! It has now been imported for internal testing. Please do not make additional changes as they will be overwritten. (341387352)

@knutpett
Copy link
Contributor Author

knutpett commented Nov 9, 2020

Thanks! What happens now? Does this mean that the change likely will be merged? How do I know when/if it is done? Should I close the PR?

@CJ-Johnson
Copy link
Contributor

Yes, if the internal testing passes, it will be merged and closed automatically. Please do not close it. :)

@mbxx mbxx mentioned this pull request Nov 10, 2020
mbxx added a commit that referenced this pull request Nov 10, 2020
mbxx added a commit that referenced this pull request Nov 10, 2020
@mbxx mbxx merged commit cda3906 into google:master Nov 10, 2020
@puetzk
Copy link

puetzk commented Mar 7, 2022

This caused a regression for me in finally updating our patches for winegcc (not submitted yet, trying to upstream the winegcc compiler improvements that enable it into winehq first).

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.

puetzk added a commit to puetzk/googletest that referenced this pull request Mar 7, 2022
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
@CJ-Johnson
Copy link
Contributor

Thank you for the comment! Do you have a proposed path for addressing the problem?

@gaspardpetit
Copy link
Contributor

gaspardpetit commented Jun 1, 2022

I ran in to the same regression, I will propose a fix in the upcoming days. The challenge here is that it is not clear what the original issue was, and I cannot tell if I will reverse the problem back to what it originally was....

@gaspardpetit
Copy link
Contributor

I undid this change in #3862
The original problem seems to be that on a system without a filesystem, FilePath::GetCurrentDir() would get called and cause getcwd to be called.

#3862 moves this logic to gtest-port.h where a custom GetCwd function can be implemented. On a diskless system, it would be possible to simply return empty string or ./.

Thus, I think #3862 solves the original problem raised here without causing the side effects observed when GTEST_HAS_DEATH_TEST is set to 0

puetzk added a commit to puetzk/googletest that referenced this pull request Sep 26, 2022
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants