-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support workflow for persisting on panic #51
Comments
It was designed with the intention of the user being able to define an environment variable and use that to pass into To un-persist, I guess we just have a Alternatively, what if we added a |
I thought that A You could try to cover all cases and future-proof the API a bit using something like enum Persist{Yes,No,OnPanic}
impl From<bool> for Persist {...}
impl TempDir {
fn set_persist(self, impl Into<Persist>) -> Self {...}
fn persist(&self) -> Persist {...} //maybe useless
} Regarding names, I don't really get the semantic difference between |
Yes, it is not reversible because we are telling the underlying let path = match self.temp {
Inner::Temp(temp) => temp.into_path(),
Inner::Persisted(path) => path,
};
|
Might I suggest Side note:
I love this idea! There have been a couple of times I wanted to persist temporary to know why a test failed. I wonder if this should be the default? |
As for a default, I'm unsure. People unaware of this might start getting a lot of files sitting in their temp directory, especially if they have a test that is supposed to panic. However, it'd be a big help to people debugging. |
I like Would it be too much to have both? |
TO have both |
Closes assert-rs#51 BREAKING CHANGE: `persist_if` was renamed to `into_persist_if`.
TempDir::persist_if(false)
should make sure that TempDir
is not persisted.
Only part of this has been addressed by #56, re-opening with the original issue updated with a summary of where we are at. |
Maintainer Edit: There are two problems that we became aware of in this issue
There are trade offs though. If someone is unaware, it could really eat up their disk space, for example.
Original title:
TempDir::persist_if(false)
should make sure thatTempDir
is not persisted.Original body:
Currently,
persist_if(false)
returns immediately, assuming that theTempDir
was not persistent to begin with and that nothing needs to be done. This doesn't work ifpersist_if(true)
had been called earlier.I'd expect an API that takes a bool to allow switching between two states, but this one can only switch from false to true.
Use-case: I'd like to automatically persist files for failed tests only, so that I can debug failures without bloating my disk. A simple way to do this would be to
persist_if(true)
at the start andpersist_if(false)
after asserts have passed:The text was updated successfully, but these errors were encountered: