Skip to content

Commit 48014bf

Browse files
Remove tempdir as it is not maintained (#252)
1 parent 9890b60 commit 48014bf

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

firewood/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ assert_cmd = "2.0.7"
4646
predicates = "3.0.1"
4747
serial_test = "2.0.0"
4848
clap = { version = "4.3.1", features = ['derive'] }
49-
tempdir = "0.3.7"
5049
test-case = "3.1.0"
5150
pprof = { version = "0.12.1", features = ["flamegraph"] }
5251

firewood/src/storage/buffer.rs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,6 @@ impl DiskBufferRequester {
618618
mod tests {
619619
use sha3::Digest;
620620
use std::path::{Path, PathBuf};
621-
use tempdir::TempDir;
622621

623622
use super::*;
624623
use crate::{
@@ -632,21 +631,26 @@ mod tests {
632631

633632
const STATE_SPACE: SpaceId = 0x0;
634633
const HASH_SIZE: usize = 32;
634+
635+
fn get_tmp_dir() -> PathBuf {
636+
option_env!("CARGO_TARGET_TMPDIR")
637+
.map(Into::into)
638+
.unwrap_or(std::env::temp_dir())
639+
.join("firewood")
640+
}
641+
635642
#[test]
636643
#[ignore = "ref: https://github.com/ava-labs/firewood/issues/45"]
637644
fn test_buffer_with_undo() {
638-
let temp_dir = option_env!("CARGO_TARGET_DIR")
639-
.map(PathBuf::from)
640-
.unwrap_or(std::env::temp_dir());
641-
let tmpdb = [temp_dir.to_str().unwrap(), "sender_api_test_db"];
645+
let temp_dir = get_tmp_dir();
642646

643647
let buf_cfg = DiskBufferConfig::builder().max_buffered(1).build();
644648
let wal_cfg = WalConfig::builder().build();
645649
let disk_requester = init_buffer(buf_cfg, wal_cfg);
646650

647651
// TODO: Run the test in a separate standalone directory for concurrency reasons
648-
let path = temp_dir.join("firewood");
649-
let (root_db_path, reset) = file::open_dir(path, file::Options::Truncate).unwrap();
652+
let (root_db_path, reset) =
653+
file::open_dir(temp_dir.as_path(), file::Options::Truncate).unwrap();
650654

651655
// file descriptor of the state directory
652656
let state_path = file::touch_dir("state", &root_db_path).unwrap();
@@ -711,14 +715,14 @@ mod tests {
711715
write_thread_handle.join().unwrap();
712716
// This is not ACID compliant, write should not return before Wal log
713717
// is written to disk.
714-
assert!([
715-
&tmpdb.into_iter().collect::<String>(),
716-
"wal",
717-
"00000000.log"
718-
]
719-
.iter()
720-
.collect::<PathBuf>()
721-
.exists());
718+
719+
let log_file = temp_dir
720+
.parent()
721+
.unwrap()
722+
.join("sender_api_test_db")
723+
.join("wal")
724+
.join("00000000.log");
725+
assert!(log_file.exists());
722726

723727
// verify
724728
assert_eq!(disk_requester.collect_ash(1).unwrap().len(), 1);
@@ -732,8 +736,8 @@ mod tests {
732736
let disk_requester = init_buffer(buf_cfg, wal_cfg);
733737

734738
// TODO: Run the test in a separate standalone directory for concurrency reasons
735-
let tmp_dir = TempDir::new("firewood").unwrap();
736-
let path = get_file_path(tmp_dir.path(), file!(), line!());
739+
let tmp_dir = get_tmp_dir();
740+
let path = get_file_path(tmp_dir.as_path(), file!(), line!());
737741
let (root_db_path, reset) = file::open_dir(path, file::Options::Truncate).unwrap();
738742

739743
// file descriptor of the state directory
@@ -816,8 +820,9 @@ mod tests {
816820
let wal_cfg = WalConfig::builder().build();
817821
let disk_requester = init_buffer(buf_cfg, wal_cfg);
818822

819-
let tmp_dir = TempDir::new("firewood").unwrap();
820-
let path = get_file_path(tmp_dir.path(), file!(), line!());
823+
let tmp_dir = get_tmp_dir();
824+
let path = get_file_path(tmp_dir.as_path(), file!(), line!());
825+
std::fs::create_dir_all(&path).unwrap();
821826
let (root_db_path, reset) = file::open_dir(path, file::Options::Truncate).unwrap();
822827

823828
// file descriptor of the state directory

0 commit comments

Comments
 (0)