From 90eaa0bcc56392615e2f67076f0f1e01ce93a5d3 Mon Sep 17 00:00:00 2001 From: Marc Riegel Date: Tue, 7 Apr 2026 14:27:55 +0200 Subject: [PATCH] test: add add-before-start regression coverage Closes #28 --- CHANGELOG.md | 2 ++ tests/integration.rs | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b13be9..06faa57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ and its version numbers follow [Semantic Versioning](https://semver.org/). scheme (`/-`). - `AGENTS.md` PR title convention (no coding-agent/tool tags) and mandatory `git pull --ff-only origin main` before branch creation (`#32`). +- Regression test coverage for runtime coordination contracts now explicitly + includes the `add()` pre-start panic behavior (`#28`). ### Changed - `process_handle()` now returns `Arc` (cheap cloning, diff --git a/tests/integration.rs b/tests/integration.rs index 15d7e14..ebc422c 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -300,6 +300,30 @@ async fn test_runnable() { ); } +#[test] +fn test_add_before_start_panics_with_contract_message() { + let manager = ProcessManager::new(); + let attempts = Arc::new(AtomicUsize::new(0)); + + let panic = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + manager.add(FlakyController::new(0, Arc::clone(&attempts))); + })) + .expect_err("add() before startup must panic"); + + let message = if let Some(s) = panic.downcast_ref::<&str>() { + (*s).to_owned() + } else if let Some(s) = panic.downcast_ref::() { + s.clone() + } else { + "".to_owned() + }; + + assert!( + message.contains("cannot call add() before manager has started"), + "unexpected panic message: {message}" + ); +} + #[tokio::test] async fn test_shutdown_waits_for_child_termination() { let mut manager = ProcessManager::new();