use std::process::Command; use std::time::Duration; use tokio::time::timeout; /// Test the SAL runner in script mode with a simple ping script #[tokio::test] async fn test_sal_runner_script_mode_ping() { let output = timeout( Duration::from_secs(10), run_sal_runner_script_mode("test_sal_ping") ).await; match output { Ok(result) => { assert!(result.is_ok(), "SAL runner should execute successfully"); let stdout = result.unwrap(); assert!(stdout.contains("pong"), "Output should contain 'pong' response: {}", stdout); } Err(_) => panic!("Test timed out after 10 seconds"), } } /// Test the OSIS runner in script mode with a simple ping script #[tokio::test] async fn test_osis_runner_script_mode_ping() { let output = timeout( Duration::from_secs(10), run_osis_runner_script_mode("test_osis_ping") ).await; match output { Ok(result) => { assert!(result.is_ok(), "OSIS runner should execute successfully"); let stdout = result.unwrap(); assert!(stdout.contains("pong"), "Output should contain 'pong' response: {}", stdout); } Err(_) => panic!("Test timed out after 10 seconds"), } } /// Helper function to run SAL runner in script mode async fn run_sal_runner_script_mode( runner_id: &str ) -> Result> { let output = Command::new("cargo") .args(&[ "run", "--bin", "runner_sal", "--", runner_id, "-s", "ping" ]) .output()?; if output.status.success() { Ok(String::from_utf8_lossy(&output.stdout).to_string()) } else { let stderr = String::from_utf8_lossy(&output.stderr); Err(format!("Command failed: {}", stderr).into()) } } /// Helper function to run OSIS runner in script mode async fn run_osis_runner_script_mode( runner_id: &str ) -> Result> { let output = Command::new("cargo") .args(&[ "run", "--bin", "runner_osis", "--", runner_id, "-s", "ping" ]) .output()?; if output.status.success() { Ok(String::from_utf8_lossy(&output.stdout).to_string()) } else { let stderr = String::from_utf8_lossy(&output.stderr); Err(format!("Command failed: {}", stderr).into()) } } /// Test basic compilation and help output #[tokio::test] async fn test_sal_runner_help() { let output = Command::new("cargo") .args(&["run", "--bin", "runner_sal", "--", "--help"]) .output() .expect("Failed to execute command"); assert!(output.status.success(), "Help command should succeed"); let stdout = String::from_utf8_lossy(&output.stdout); assert!(stdout.contains("Usage") || stdout.contains("USAGE"), "Help output should contain usage information"); } /// Test basic compilation and help output for OSIS runner #[tokio::test] async fn test_osis_runner_help() { let output = Command::new("cargo") .args(&["run", "--bin", "runner_osis", "--", "--help"]) .output() .expect("Failed to execute command"); assert!(output.status.success(), "Help command should succeed"); let stdout = String::from_utf8_lossy(&output.stdout); assert!(stdout.contains("Usage") || stdout.contains("USAGE"), "Help output should contain usage information"); } /// Test library functionality - job creation and basic operations #[tokio::test] async fn test_job_creation_and_serialization() { use runner_rust::JobBuilder; let job = JobBuilder::new() .caller_id("test_caller") .context_id("test_context") .payload("ping") .runner("default") .executor("rhai") .build() .expect("Job creation should succeed"); assert_eq!(job.caller_id, "test_caller"); assert_eq!(job.context_id, "test_context"); assert_eq!(job.payload, "ping"); assert_eq!(job.runner, "default"); assert_eq!(job.executor, "rhai"); }