Skip to content

Use tempfile::TempDir in test_progress_stream_reset#800

Open
demoray wants to merge 1 commit into
mainfrom
bcaswell/tempdir-progress-stream-test
Open

Use tempfile::TempDir in test_progress_stream_reset#800
demoray wants to merge 1 commit into
mainfrom
bcaswell/tempdir-progress-stream-test

Conversation

@demoray
Copy link
Copy Markdown
Collaborator

@demoray demoray commented May 18, 2026

test_progress_stream_reset in src/upload/blobstore.rs wrote to
std::env::temp_dir() with a hand-rolled pid+nanos filename, ran
the test 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] (Cargo.lock churn
    picks up the standard tempfile transitive deps).

Verified with:

  • cargo fmt --check
  • cargo clippy --all-features --all-targets -- -D warnings
  • cargo test --all-features (test_progress_stream_reset passes)

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
@demoray demoray enabled auto-merge (squash) May 18, 2026 20:50
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

Successfully merging this pull request may close these issues.

1 participant