Skip to content

Commit

Permalink
Add TEST_OUT_DIR and append test_id to temp dir (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfldde authored Nov 28, 2024
1 parent 5baaef3 commit 8342386
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/config/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)>,
Expand Down Expand Up @@ -57,22 +59,32 @@ pub struct TestCaseConfig {
// Or an absolute path.
// Defaults to resources/genesis/bitcoin-regtest
pub genesis_dir: Option<String>,
pub test_id: String,
}

impl Default for TestCaseConfig {
fn default() -> Self {
let test_id = generate_test_id();
TestCaseConfig {
n_nodes: 1,
with_sequencer: true,
with_batch_prover: false,
with_light_client_prover: false,
with_full_node: false,
timeout: Duration::from_secs(60),
dir: TempDir::new()
.expect("Failed to create temporary directory")
.into_path(),
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,
}
}
}
Expand Down

0 comments on commit 8342386

Please sign in to comment.