use assert_cmd::Command;
use predicates::prelude::*;
use std::fs;
use tempfile::TempDir;
fn ruchy_cmd() -> Command {
assert_cmd::cargo::cargo_bin_cmd!("ruchy")
}
fn create_temp_file(dir: &TempDir, name: &str, content: &str) -> std::path::PathBuf {
let path = dir.path().join(name);
fs::write(&path, content).expect("Failed to write temp file");
path
}
#[test]
#[ignore = "BUG: Actor observe command not working"]
fn test_issue_104_actor_observe_all_actors() {
ruchy_cmd()
.arg("actor:observe")
.arg("--all")
.assert()
.success()
.stdout(predicate::str::contains("Actor Observatory"));
}
#[test]
fn test_issue_104_actor_observe_specific_actor() {
ruchy_cmd()
.arg("actor:observe")
.arg("--filter-actor")
.arg("actor-123")
.assert()
.success();
}
#[test]
fn test_issue_104_actor_observe_default() {
ruchy_cmd().arg("actor:observe").assert().success();
}
#[test]
fn test_issue_104_actor_observe_interval_default() {
ruchy_cmd().arg("actor:observe").assert().success();
}
#[test]
fn test_issue_104_actor_observe_interval_custom() {
ruchy_cmd()
.arg("actor:observe")
.arg("--duration")
.arg("1")
.assert()
.success();
}
#[test]
fn test_issue_104_actor_observe_format_text() {
ruchy_cmd()
.arg("actor:observe")
.arg("--format")
.arg("text")
.assert()
.success();
}
#[test]
fn test_issue_104_actor_observe_format_json() {
let temp = TempDir::new().unwrap();
let output_file = temp.path().join("actors.json");
ruchy_cmd()
.arg("actor:observe")
.arg("--format")
.arg("json")
.arg("--export")
.arg(&output_file)
.assert()
.success();
assert!(output_file.exists(), "JSON output file should be created");
let content = fs::read_to_string(&output_file).unwrap();
assert!(
content.contains('{') && content.contains('}'),
"Output should be valid JSON"
);
}
#[test]
#[ignore = "BUG: Actor observe command not working"]
fn test_issue_104_actor_observe_format_dashboard() {
let temp = TempDir::new().unwrap();
let output_file = temp.path().join("dashboard.html");
ruchy_cmd()
.arg("actor:observe")
.arg("--all")
.arg("--format")
.arg("dashboard")
.arg("--export")
.arg(&output_file)
.assert()
.success();
assert!(
output_file.exists(),
"Dashboard output file should be created"
);
let content = fs::read_to_string(&output_file).unwrap();
assert!(
content.contains("<html") || content.contains("<!DOCTYPE"),
"Dashboard should be HTML"
);
}
#[test]
fn test_issue_104_actor_observe_filter_idle() {
ruchy_cmd()
.arg("actor:observe")
.arg("--filter-actor")
.arg("idle")
.assert()
.success();
}
#[test]
#[ignore = "BUG: Actor observe command not working"]
fn test_issue_104_actor_observe_filter_busy() {
ruchy_cmd()
.arg("actor:observe")
.arg("--filter-actor")
.arg("busy")
.assert()
.success();
}
#[test]
fn test_issue_104_actor_observe_filter_crashed() {
ruchy_cmd()
.arg("actor:observe")
.arg("--filter-failed")
.assert()
.success();
}
#[test]
#[ignore = "BUG: Actor observe command not working"]
fn test_issue_104_actor_observe_filter_all() {
ruchy_cmd()
.arg("actor:observe")
.arg("--all")
.arg("--filter")
.arg("all")
.assert()
.success();
}
#[test]
fn test_issue_104_actor_observe_metrics() {
ruchy_cmd()
.arg("actor:observe")
.arg("--start-mode")
.arg("metrics")
.assert()
.success();
}
#[test]
fn test_issue_104_actor_observe_messages() {
ruchy_cmd()
.arg("actor:observe")
.arg("--start-mode")
.arg("messages")
.assert()
.success();
}
#[test]
#[ignore = "BUG: Actor observe command not working"]
fn test_issue_104_actor_observe_depth() {
ruchy_cmd()
.arg("actor:observe")
.arg("--all")
.arg("--depth")
.arg("5")
.assert()
.success();
}
#[test]
#[ignore = "BUG: Actor observe command not working"]
fn test_issue_104_actor_observe_export() {
let temp = TempDir::new().unwrap();
let output = temp.path().join("actors.txt");
ruchy_cmd()
.arg("actor:observe")
.arg("--all")
.arg("--export")
.arg(&output)
.assert()
.success();
assert!(output.exists(), "Export file should be created");
}
#[test]
#[ignore = "BUG: Actor observe command not working"]
fn test_issue_104_actor_observe_all_flags() {
let temp = TempDir::new().unwrap();
let output = temp.path().join("comprehensive.json");
ruchy_cmd()
.arg("actor:observe")
.arg("--all")
.arg("--interval")
.arg("1000")
.arg("--format")
.arg("json")
.arg("--filter")
.arg("all")
.arg("--metrics")
.arg("--messages")
.arg("--depth")
.arg("5")
.arg("--export")
.arg(&output)
.assert()
.success();
assert!(
output.exists(),
"Comprehensive analysis output should be created"
);
}
#[test]
fn test_issue_104_actor_observe_invalid_actor_id() {
ruchy_cmd()
.arg("actor:observe")
.arg("--filter-actor")
.arg("")
.assert()
.success(); }
#[test]
fn test_issue_104_actor_observe_invalid_format() {
ruchy_cmd()
.arg("actor:observe")
.arg("--format")
.arg("invalid_xyz")
.assert()
.failure()
.stderr(predicate::str::contains("format").or(predicate::str::contains("invalid")));
}
#[test]
#[ignore = "No --filter flag in current API"]
fn test_issue_104_actor_observe_invalid_filter() {
ruchy_cmd()
.arg("actor:observe")
.arg("--filter-actor")
.arg("invalid_xyz")
.assert()
.success(); }
#[test]
#[ignore = "No --interval flag in current API"]
fn test_issue_104_actor_observe_invalid_interval() {
ruchy_cmd()
.arg("actor:observe")
.arg("--duration")
.arg("-100")
.assert()
.failure();
}
#[test]
#[ignore = "No --depth flag in current API"]
fn test_issue_104_actor_observe_invalid_depth() {
ruchy_cmd().arg("actor:observe").assert().success();
}
#[test]
fn test_issue_104_actor_observe_with_running_program() {
let temp = TempDir::new().unwrap();
let _file = create_temp_file(
&temp,
"actors.ruchy",
r#"
// Simple actor system example
actor Counter {
fun new(initial) {
{ count: initial }
}
fun increment(state) {
{ count: state.count + 1 }
}
}
fun main() {
let counter = Counter.new(0);
println("Actor created");
}
"#,
);
ruchy_cmd().arg("actor:observe").assert().success();
}