From 9bd0337ee129f43037db9cc55c6232605a3bcfbd Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sat, 21 Oct 2023 07:17:56 -0700 Subject: [PATCH] Replace tempdir with tempfile Summary: `tempdir` has been deprecated since 2018: https://github.com/rust-lang-deprecated/tempdir/pull/46 It's functionality was merged into `tempfile` with minor tweaks: - Methods names: `new` -> `with_prefix`, `new_in` -> `with_prefix_in`. - `with_prefix_in`'s args order is reversed. - Temp dirs no longer have a period between the prefix and the random name (before `foo.123abc`, now `foo123abc`). Reviewed By: capickett Differential Revision: D50514209 fbshipit-source-id: a50e9f1c0c78a2642bae8edbb6098b3f04c89969 --- shed/chrome_trace/Cargo.toml | 2 +- shed/chrome_trace/src/lib.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shed/chrome_trace/Cargo.toml b/shed/chrome_trace/Cargo.toml index 8e184b808..0469113b4 100644 --- a/shed/chrome_trace/Cargo.toml +++ b/shed/chrome_trace/Cargo.toml @@ -21,4 +21,4 @@ zstd = { version = "0.13", features = ["experimental", "zstdmt"] } [dev-dependencies] maplit = "1.0" -tempdir = "0.3" +tempfile = "3.5" diff --git a/shed/chrome_trace/src/lib.rs b/shed/chrome_trace/src/lib.rs index 31a71dbc5..5fc90714f 100644 --- a/shed/chrome_trace/src/lib.rs +++ b/shed/chrome_trace/src/lib.rs @@ -593,7 +593,7 @@ mod tests { trace.add_event(begin.clone()); trace.add_event(end.clone()); - let tmp = tempdir::TempDir::new("trace-event").unwrap(); + let tmp = tempfile::TempDir::with_prefix("trace-event.").unwrap(); let path = tmp.path().join("trace.json"); trace.save(&path).expect("Failed to save trace"); @@ -627,7 +627,7 @@ mod tests { trace.add_event(begin.clone()); trace.add_event(end.clone()); - let tmp = tempdir::TempDir::new("trace-event").unwrap(); + let tmp = tempfile::TempDir::with_prefix("trace-event.").unwrap(); let path = tmp.path().join("trace.json.gz"); trace.save_gzip(&path).expect("Failed to save trace"); @@ -661,7 +661,7 @@ mod tests { trace.add_event(begin.clone()); trace.add_event(end.clone()); - let tmp = tempdir::TempDir::new("trace-event").unwrap(); + let tmp = tempfile::TempDir::with_prefix("trace-event.").unwrap(); let path = tmp.path().join("trace.json.zst"); trace.save_zstd(&path).expect("Failed to save trace");