mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-11 17:53:11 +00:00
37 lines
1.1 KiB
Rust
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
|
|
}
|