In radicle/src/test.rs, we have a helper type for a Node, which creates a temporary directory using tempfile::tempdir, which creates a TempDir. When the TempDir is dropped, it deletes its associated directory. Before that happens, the Node has already stored the path. Right after that the TempDir is dropped, and the directory deleted. When the test code later opens the repository, using Storage::open, it recreates the directory. As a result, there is nothing that would delete the directory when the test finishes.
This means tests that use the helper Node type leave temporary files behind.
Fix this by storing the TempDir in the helper Node, not just its path. This means the TempDir is only dropped at the end of the test its used in, and no temporary files are left behind.
Signed-off-by: Lars Wirzenius liw@liw.fi
In radicle/src/test.rs, we have a helper type for a Node, which creates a temporary directory using tempfile::tempdir, which creates a TempDir. When the TempDir is dropped, it deletes its associated directory. Before that happens, the Node has already stored the path. Right after that the TempDir is dropped, and the directory deleted. When the test code later opens the repository, using Storage::open, it recreates the directory. As a result, there is nothing that would delete the directory when the test finishes.
This means tests that use the helper Node type leave temporary files behind.
Fix this by storing the TempDir in the helper Node, not just its path. This means the TempDir is only dropped at the end of the test its used in, and no temporary files are left behind.
Signed-off-by: Lars Wirzenius liw@liw.fi
refactor patch a little to drop use of tempdir_in
Suggested in https://radicle.zulipchat.com/#narrow/stream/383670-patches/topic/fix.20tests.20to.20not.20leave.20temporary.20files.20behind/near/432932075
LGTM
Rebase.