Use tempfile::TempDir in test_progress_stream_reset#800
Open
demoray wants to merge 1 commit into
Open
Conversation
The test wrote to `std::env::temp_dir()` with a hand-rolled
pid+nanos filename, ran the body inside an `async {}` block to
capture its Result, then manually `remove_file`'d the path. A panic
or early return inside the async block skipped the cleanup, leaking
files into $TMPDIR across CI runs.
Use `tempfile::TempDir` instead. Cleanup runs on `Drop` (panic-safe),
collision-avoidance is structural, and the test body collapses back
to straight `?`-propagation without the inner async block.
Drops the now-unused `std::time::{SystemTime, UNIX_EPOCH}` import.
Adds `tempfile = "3"` to `[dev-dependencies]`.
Verified with:
- cargo fmt --check
- cargo clippy --all-features --all-targets -- -D warnings
- cargo test --all-features
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_progress_stream_resetinsrc/upload/blobstore.rswrote tostd::env::temp_dir()with a hand-rolled pid+nanos filename, ranthe test body inside an
async {}block to capture its Result, thenmanually
remove_file'd the path. A panic or early return insidethe async block skipped the cleanup, leaking files into
$TMPDIRacross CI runs.
Use
tempfile::TempDirinstead. Cleanup runs onDrop(panic-safe),collision-avoidance is structural, and the test body collapses back
to straight
?-propagation without the inner async block.std::time::{SystemTime, UNIX_EPOCH}import.tempfile = "3"to[dev-dependencies](Cargo.lockchurnpicks up the standard tempfile transitive deps).
Verified with:
cargo fmt --checkcargo clippy --all-features --all-targets -- -D warningscargo test --all-features(test_progress_stream_resetpasses)