Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(storage): share one test lock across storage host tests

Steven Enamakelae5942db5436
diff --git a/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs b/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs
index 462242da98..0680a25c90 100644
--- a/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_host_cdylib_tests.rs
@@ -47,9 +47,7 @@ use tinystoragedrivers_bus::STORAGE_INTERFACE;
const PROBE: &str = "ai.tinyhumans.test.StorageProbe";
-/// The linked storage module's pending slot is process-wide, so every test
-/// that attaches takes a turn.
-static TURN: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
+use crate::modules::storage_host_linked::TEST_TURN as TURN;
fn repo_root() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR"))
diff --git a/crates/openhuman-core/src/modules/storage_host_linked.rs b/crates/openhuman-core/src/modules/storage_host_linked.rs
index f61a438111..44995e656e 100644
--- a/crates/openhuman-core/src/modules/storage_host_linked.rs
+++ b/crates/openhuman-core/src/modules/storage_host_linked.rs
@@ -29,6 +29,11 @@ use super::storage_host::{serve_objects, StorageHost};
/// admitted, because a linked module's setup is a plain function with no state.
static PENDING: Mutex<Option<(Arc<StorageHost>, tokio::runtime::Handle)>> = Mutex::new(None);
+/// The pending slot is process-wide, so every test that attaches (here and in
+/// `storage_host_cdylib_tests`) takes a turn on this one lock.
+#[cfg(test)]
+pub(super) static TEST_TURN: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
+
/// How long [`attach`] waits for the module to claim the interface name.
const READY_DEADLINE: Duration = Duration::from_secs(5);
diff --git a/crates/openhuman-core/src/modules/storage_host_linked_tests.rs b/crates/openhuman-core/src/modules/storage_host_linked_tests.rs
index 579151667f..bed07f5d44 100644
--- a/crates/openhuman-core/src/modules/storage_host_linked_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_host_linked_tests.rs
@@ -13,8 +13,7 @@ use super::super::storage_grants::StorageGrant;
use super::super::storage_host::{module_scope, CallerDirectory, Environment, StorageHost};
use crate::storage::StorageBackend;
-/// The pending slot is process-wide, so tests that attach take turns.
-static TURN: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
+use super::TEST_TURN as TURN;
const MODULE: &str = "tinymcp";