mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-05 08:15:41 -08:00
End the agent's process group and the consoles it opened on every quit
AI Assisted
This commit is contained in:
1 parent
98bdbc97c3
commit
6a93395148
8 files changed
+1363
-58
No files matched your search
@@ -7,7 +7,7 @@ use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use plan2code_app_lib::console_supervisor::{app_origin, ConsoleSupervisor};
|
||||
use plan2code_app_lib::console_supervisor::{app_origin, stop_console_session, ConsoleSupervisor};
|
||||
|
||||
fn have_node() -> bool {
|
||||
Command::new("node")
|
||||
@@ -120,6 +120,38 @@ fn a_killed_console_is_dead_and_restarts() {
|
||||
sup.stop().expect("stop");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stopping_a_session_by_id_never_panics() {
|
||||
let Some(project) = setup() else { return };
|
||||
// The console has nothing to stop for a session it does not know: that is
|
||||
// not a failure.
|
||||
assert_eq!(
|
||||
stop_console_session(&repo_console_dir(), &project, "no-such-session"),
|
||||
Ok(())
|
||||
);
|
||||
// A folder with no console in it is.
|
||||
let empty = temp_dir("no-console");
|
||||
let error = stop_console_session(&empty, &project, "no-such-session")
|
||||
.expect_err("no console.mjs to run");
|
||||
assert!(error.starts_with("console stop failed"), "{error}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_session_stopped_by_id_stops_answering() {
|
||||
let Some(project) = setup() else { return };
|
||||
let mut sup =
|
||||
ConsoleSupervisor::start(project.clone(), app_origin().to_string()).expect("start");
|
||||
assert!(until_health(&sup, true), "the console URL never answered");
|
||||
let sid = sup.session().sid.clone();
|
||||
|
||||
stop_console_session(&repo_console_dir(), &project, &sid).expect("stop by id");
|
||||
assert!(
|
||||
until_health(&sup, false),
|
||||
"the console still answered after stop_console_session()"
|
||||
);
|
||||
sup.stop().expect("a second stop is harmless");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_live_console_is_not_restarted() {
|
||||
let Some(project) = setup() else { return };
|
||||
|
||||
Reference in new issue
Block a user