agent-manager v0.2.0 : gestionnaire d'agents IA locaux
- CLI Rust (am) : list/install/uninstall/update/start/stop/restart/run/status/search/info/config/doctor/completion/export/import/self-update + shell interactif (Tab, historique) - 9 methodes d'installation (npm, pip, uv, cargo, go, bun, curl, binary, git) - catalogue de 72 agents, dependances, processus, securite (dry-run, checksums) - sondes de version paralleles + cache (am list ~25 ms a chaud) - installateurs one-liner : install.sh, install.ps1
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
//! Process lifecycle: background spawn, liveness, stop.
|
||||
|
||||
mod common;
|
||||
|
||||
use agent_manager::process;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
fn sleep_cmd() -> (&'static str, Vec<String>) {
|
||||
if cfg!(windows) {
|
||||
(
|
||||
"ping",
|
||||
vec![
|
||||
"-n".to_string(),
|
||||
"40".to_string(),
|
||||
"127.0.0.1".to_string(),
|
||||
],
|
||||
)
|
||||
} else {
|
||||
("sleep", vec!["40".to_string()])
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spawn_detect_stop_cycle() {
|
||||
let app = common::test_app("proc", &["status"]);
|
||||
let (prog, args) = sleep_cmd();
|
||||
let env = BTreeMap::new();
|
||||
let pid = process::spawn_background(
|
||||
&app,
|
||||
"test-agent",
|
||||
std::path::Path::new(prog),
|
||||
&args,
|
||||
&env,
|
||||
)
|
||||
.unwrap();
|
||||
assert!(pid > 0);
|
||||
assert!(process::is_running(pid));
|
||||
assert!(process::stop_pid(pid, true, 5));
|
||||
assert!(!process::is_running(pid));
|
||||
// The log file was created.
|
||||
assert!(process::agent_log_path(&app, "test-agent").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spawning_a_failing_program_reports_an_error() {
|
||||
let app = common::test_app("procfail", &["status"]);
|
||||
let env = BTreeMap::new();
|
||||
// A command that exits immediately with an error.
|
||||
let (prog, args) = if cfg!(windows) {
|
||||
("cmd", vec!["/C".to_string(), "exit 7".to_string()])
|
||||
} else {
|
||||
("sh", vec!["-c".to_string(), "exit 7".to_string()])
|
||||
};
|
||||
let err = process::spawn_background(
|
||||
&app,
|
||||
"failing",
|
||||
std::path::Path::new(prog),
|
||||
&args,
|
||||
&env,
|
||||
)
|
||||
.unwrap_err();
|
||||
assert!(
|
||||
err.to_string().contains("exited immediately"),
|
||||
"unexpected error: {err:#}"
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user