Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
radicle: fix tests to not leave temporary files behind
Merged liw opened 2 years ago

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

liw opened with revision 923c3ad6 on base 574ac356 +11 -7 2 years ago

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

liw pushed revision 2 0e2336a6 on base 574ac356 +10 -23 2 years ago

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

fintohaps accepted 2 years ago

LGTM

did:key:z6MksFqX...wzpT pushed revision 3 763b1c02 on base c0752236 +10 -23 2 years ago

Rebase.

did:key:z6MksFqX...wzpT merged revision 763b1c02 at 1a0221f7 2 years ago