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

Allow changing the keep bool after a temporary directory's initialization #315

Open
n0toose opened this issue Nov 25, 2024 · 3 comments
Open

Comments

@n0toose
Copy link
Contributor

n0toose commented Nov 25, 2024

I heavily rely on tempfile for a research project's sandbox that I am working on, and I need to test whether a file (stored inside of a temporary directory using the crate) exists inside a temporary directory. However, I do not want to / I am not able to to build functionality that selectively sets keep to true depending on whether I am using a test.

It would be great if I could enable this option after initializing the temporary directory for testing purposes.

Thank you for working on this crate!

@n0toose
Copy link
Contributor Author

n0toose commented Nov 25, 2024

#[cfg(test)] does not work during integration testing, but perhaps that's an anti-pattern best solved through another way: https://doc.rust-lang.org/book/ch11-03-test-organization.html

I'll leave this up to you :D

@Stebalien
Copy link
Owner

I'm not sure I understand the request. Based on the title, I'd suggest you use TempDir::into_path().

@n0toose
Copy link
Contributor Author

n0toose commented Nov 26, 2024

I'm not sure I understand the request. Based on the title, I'd suggest you use TempDir::into_path()

Sorry for the chaotic-ness of my issue. Your suggestion seems interesting and looks like a better way than the one I wanted, I completely missed it! Do you think I should document TempDir::into_path() in the keep function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants