Skip to content

Commit ad9ef79

Browse files
committed
flame: replace tempdir with tempfile
Similarly, `tracing-flame`'s tests also use the unmaintained `tempdir` crate. This commit replaces it with `tempfile`. Signed-off-by: Eliza Weisman <[email protected]>
1 parent 256ff1d commit ad9ef79

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

tracing-flame/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ tracing = { path = "../tracing", version = "0.2", default-features = false, feat
3030
lazy_static = "1.3.0"
3131

3232
[dev-dependencies]
33-
tempdir = "0.3.7"
33+
tempfile = "3"

tracing-flame/tests/collapsed.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
use std::thread::sleep;
22
use std::time::Duration;
3-
use tempdir::TempDir;
43
use tracing::{span, Level};
54
use tracing_flame::FlameSubscriber;
65
use tracing_subscriber::{prelude::*, registry::Registry};
76

87
#[test]
98
fn capture_supported() {
109
{
11-
let tmp_dir = TempDir::new("flamegraphs").unwrap();
10+
let tmp_dir = tempfile::Builder::new()
11+
.prefix("tracing-flamegraph-test-")
12+
.tempdir()
13+
.expect("failed to create tempdir");
1214
let (flame_layer, _guard) =
1315
FlameSubscriber::with_file(tmp_dir.path().join("tracing.folded")).unwrap();
1416

@@ -37,5 +39,7 @@ fn capture_supported() {
3739
}
3840

3941
sleep(Duration::from_millis(500));
42+
43+
tmp_dir.close().expect("failed to delete tempdir");
4044
}
4145
}

tracing-flame/tests/concurrent.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
use std::thread::sleep;
22
use std::time::Duration;
3-
use tempdir::TempDir;
43
use tracing::{span, Level};
54
use tracing_flame::FlameSubscriber;
65
use tracing_subscriber::{prelude::*, registry::Registry};
76

87
#[test]
98
fn capture_supported() {
10-
let tmp_dir = TempDir::new("flamegraphs").unwrap();
9+
let tmp_dir = tempfile::Builder::new()
10+
.prefix("tracing-flamegraph-test-")
11+
.tempdir()
12+
.expect("failed to create tempdir");
1113
let path = tmp_dir.path().join("tracing.folded");
1214
let (flame_layer, flame_guard) = FlameSubscriber::with_file(&path).unwrap();
1315

@@ -37,4 +39,6 @@ fn capture_supported() {
3739
let traces = std::fs::read_to_string(&path).unwrap();
3840
println!("{}", traces);
3941
assert_eq!(5, traces.lines().count());
42+
43+
tmp_dir.close().expect("failed to delete tempdir");
4044
}

0 commit comments

Comments
 (0)