Skip to content

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

test(shell): cover docker module result success, failure, and timeout

Steven Enamakel468d8f7be66a
diff --git a/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs b/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs
index 6a93ed39c4..83b9db21e8 100644
--- a/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs
+++ b/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs
@@ -18,6 +18,51 @@ async fn configured_shell_fails_closed_when_tinybox_analysis_is_disabled() {
assert_eq!(error.to_string(), "command analysis is unavailable");
}
+#[cfg(feature = "modules")]
+#[test]
+fn docker_module_results_preserve_success_failure_and_timeout_semantics() {
+ use crate::modules::tinybox::contract::DockerRunOutput;
+
+ let success = docker_module_result(
+ DockerRunOutput {
+ exit_code: 0,
+ stdout: "hello".to_owned(),
+ stderr: String::new(),
+ timed_out: false,
+ },
+ None,
+ );
+ assert!(!success.is_error);
+ assert_eq!(success.output(), "hello");
+
+ let failure = docker_module_result(
+ DockerRunOutput {
+ exit_code: 7,
+ stdout: "partial".to_owned(),
+ stderr: "failed".to_owned(),
+ timed_out: false,
+ },
+ None,
+ );
+ assert!(failure.is_error);
+ assert!(failure.output().contains("7"));
+ assert!(failure.output().contains("partial"));
+ assert!(failure.output().contains("failed"));
+
+ let timeout = docker_module_result(
+ DockerRunOutput {
+ exit_code: -1,
+ stdout: "before timeout".to_owned(),
+ stderr: String::new(),
+ timed_out: true,
+ },
+ Some(std::time::Duration::from_secs(3)),
+ );
+ assert!(timeout.is_error);
+ assert!(timeout.output().contains("timed out after 3s"));
+ assert!(timeout.output().contains("before timeout"));
+}
+
#[cfg(not(windows))]
#[tokio::test]
async fn shell_emits_audit_line_on_success() {