2025-12-18 18:19:38 +01:00

37 lines
1.1 KiB
Rust

mod api_client;
pub mod common;
pub mod executor;
pub mod validator;
use std::sync::LazyLock;
pub use api_client::{ApiClient, ApiClientError};
use tempfile::TempDir;
use testing_framework_env as tf_env;
pub(crate) const LOGS_PREFIX: &str = "__logs";
static KEEP_NODE_TEMPDIRS: LazyLock<bool> = LazyLock::new(tf_env::nomos_tests_keep_logs);
pub(crate) fn create_tempdir() -> std::io::Result<TempDir> {
// It's easier to use the current location instead of OS-default tempfile
// location because Github Actions can easily access files in the current
// location using wildcard to upload them as artifacts.
TempDir::new_in(std::env::current_dir()?)
}
fn persist_tempdir(tempdir: &mut TempDir, label: &str) -> std::io::Result<()> {
println!(
"{}: persisting directory at {}",
label,
tempdir.path().display()
);
// we need ownership of the dir to persist it
let dir = std::mem::replace(tempdir, tempfile::tempdir()?);
let _ = dir.keep();
Ok(())
}
pub(crate) fn should_persist_tempdir() -> bool {
std::thread::panicking() || *KEEP_NODE_TEMPDIRS
}