//! Under `smarm-trace`, every actor the root-exit sweep reaches is recorded //! as a `root_sweep` event — the way to *see* unsupervised leftovers. One test //! per binary: the trace file is process-global. #![cfg(feature = "smarm-trace")] use smarm::gen_server::{self, GenServer, GenServerCtx}; use smarm::run; struct Quiet; impl GenServer for Quiet { type Call = (); type Reply = (); type Cast = (); type Info = (); type Timer = (); fn init(&mut self, _: &GenServerCtx) {} fn handle_call(&mut self, _: ()) {} fn handle_cast(&mut self, _: ()) {} } #[test] fn forgotten_server_shows_up_as_root_sweep() { let path = std::env::temp_dir().join(format!("smarm_root_sweep_{}.json", std::process::id())); std::env::set_var("SMARM_TRACE_FILE", &path); run(|| { let srv = gen_server::start(Quiet); srv.call(()).unwrap(); drop(srv); // forgotten: nobody supervises it, nobody holds it }); let trace = std::fs::read_to_string(&path).expect("trace file written"); let _ = std::fs::remove_file(&path); assert!( trace.contains("root_sweep stopped"), "expected a root_sweep line for the non-trapping leftover; got:\n{trace}" ); }