Skip to content

Commit

Permalink
flame: replace tempdir with tempfile
Browse files Browse the repository at this point in the history
Similarly, `tracing-flame`'s tests also use the unmaintained `tempdir`
crate. This commit replaces it with `tempfile`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
hawkw committed Aug 17, 2021
1 parent edc85a9 commit 058c9e2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tracing-flame/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ tracing = { path = "../tracing", version = "0.1.12", default-features = false, f
lazy_static = "1.3.0"

[dev-dependencies]
tempdir = "0.3.7"
tempfile = "3"
8 changes: 6 additions & 2 deletions tracing-flame/tests/collapsed.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use std::thread::sleep;
use std::time::Duration;
use tempdir::TempDir;
use tracing::{span, Level};
use tracing_flame::FlameLayer;
use tracing_subscriber::{prelude::*, registry::Registry};

#[test]
fn capture_supported() {
{
let tmp_dir = TempDir::new("flamegraphs").unwrap();
let tmp_dir = tempfile::Builder::new()
.prefix("tracing-flamegraph-test-")
.tempdir()
.expect("failed to create tempdir");
let (flame_layer, _guard) =
FlameLayer::with_file(tmp_dir.path().join("tracing.folded")).unwrap();

Expand Down Expand Up @@ -37,5 +39,7 @@ fn capture_supported() {
}

sleep(Duration::from_millis(500));

tmp_dir.close().expect("failed to delete tempdir");
}
}
8 changes: 6 additions & 2 deletions tracing-flame/tests/concurrent.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use std::thread::sleep;
use std::time::Duration;
use tempdir::TempDir;
use tracing::{span, Level};
use tracing_flame::FlameLayer;
use tracing_subscriber::{prelude::*, registry::Registry};

#[test]
fn capture_supported() {
let tmp_dir = TempDir::new("flamegraphs").unwrap();
let tmp_dir = tempfile::Builder::new()
.prefix("tracing-flamegraph-test-")
.tempdir()
.expect("failed to create tempdir");
let path = tmp_dir.path().join("tracing.folded");
let (flame_layer, flame_guard) = FlameLayer::with_file(&path).unwrap();

Expand Down Expand Up @@ -37,4 +39,6 @@ fn capture_supported() {
let traces = std::fs::read_to_string(&path).unwrap();
println!("{}", traces);
assert_eq!(5, traces.lines().count());

tmp_dir.close().expect("failed to delete tempdir");
}

0 comments on commit 058c9e2

Please sign in to comment.