From 9cd86d2b683da0d65a3c400ca524f30f06432454 Mon Sep 17 00:00:00 2001 From: jfldde <168934971+jfldde@users.noreply.github.com> Date: Thu, 28 Nov 2024 13:56:24 +0000 Subject: [PATCH] Append test_id to temp dir --- src/config/test_case.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/config/test_case.rs b/src/config/test_case.rs index ed779c9..6a6c33b 100644 --- a/src/config/test_case.rs +++ b/src/config/test_case.rs @@ -2,6 +2,8 @@ use std::{env, path::PathBuf, time::Duration}; use tempfile::TempDir; +use crate::utils::generate_test_id; + #[derive(Clone, Default)] pub struct TestCaseEnv { pub test: Vec<(&'static str, &'static str)>, @@ -57,10 +59,12 @@ pub struct TestCaseConfig { // Or an absolute path. // Defaults to resources/genesis/bitcoin-regtest pub genesis_dir: Option, + pub test_id: String, } impl Default for TestCaseConfig { fn default() -> Self { + let test_id = generate_test_id(); TestCaseConfig { n_nodes: 1, with_sequencer: true, @@ -68,16 +72,19 @@ impl Default for TestCaseConfig { with_light_client_prover: false, with_full_node: false, timeout: Duration::from_secs(60), - dir: std::env::var("TEST_OUT_DIR").map_or_else( - |_| { - TempDir::new() - .expect("Failed to create temporary directory") - .into_path() - }, - PathBuf::from, - ), + dir: std::env::var("TEST_OUT_DIR") + .map_or_else( + |_| { + TempDir::new() + .expect("Failed to create temporary directory") + .into_path() + }, + PathBuf::from, + ) + .join(test_id.clone()), docker: TestCaseDockerConfig::default(), genesis_dir: None, + test_id, } } }