test(cli): the detached-host tests follow the new shape: only serve starts a host
Plan P15 unit A5. Nothing but `wanderbooks serve` starts a host, so the tests that had a bridge or a command start one now have `serve` hold the books (a `serve` the harness keeps: Home::keep_host), or run a server of their own (the commands), or are retired. Every test of the three files plan section 6 names, and what became of it: open_while_held.rs (44 tests) KEPT, still true for serve (28): closing_the_books_ends_every_lease_and_the_bridge_stays_closed, closing_during_a_burst_of_posts_through_the_bridge_loses_nothing, a_killed_host_is_replaced_by_its_holders, holders_back_off_and_give_up_on_a_host_that_keeps_failing, the_lease_socket_takes_only_the_owners_intents, a_restart_is_not_a_close, another_apps_appimage_is_never_run_as_the_host, the_host_outlives_the_app_scope_that_started_it, the_bridge_serves_a_client_without_initialize, the_bridge_recovers_when_the_server_dies_under_it, a_message_too_large_is_refused_and_the_session_goes_on, malformed_and_boundary_input_never_ends_the_session, the_host_starts_without_a_scope_when_systemd_run_fails, a_scrubbed_app_scope_doesnt_take_the_host_with_it, doctor_doesnt_hang_on_a_frozen_host, doctor_doesnt_hang_on_a_frozen_server, serve_hears_ctrl_c_while_it_waits_to_try_again, every_malformed_message_is_answered, books_that_didnt_open_refuse_plainly, close_and_list_dont_hang_on_frozen_processes, the_books_command_takes_its_flags_and_asks_before_adopting, adopted_books_old_copies_are_put_aside_from_the_command_line, the_token_commands_and_the_bridge (the bridges there are held by serve through Agent::start), an_agent_sends_and_saves_files_with_the_commands_it_is_given, a_backup_is_restored_from_the_command_line, books_are_backed_up_now_from_the_command_line, connect_makes_anew_a_token_whose_file_is_gone_and_says_when_an_agent_refuses, token_check_says_where_the_token_file_stands_and_an_unreadable_one_is_said (these commands now run a server of their own with nothing running). MOVED, rewritten for the new shape (15): a_command_opens_the_books_and_they_close_after_the_last_holder -> a_command_leaves_nothing_running_and_serve_closes_after_its_last_holder; openers_share_one_host_and_one_server -> serve_and_the_bridges_share_one_host_and_one_server (two serves at once are the race now); the_bridge_opens_closed_books_and_holds_them_for_the_session -> the_bridge_reaches_the_books_serve_holds_and_holds_them_for_the_session; the_host_starts_clean_from_a_hostile_bridge -> the_host_serve_starts_is_clean_from_a_hostile_serve; the_bridge_answers_initialize_itself_during_a_slow_start, the_bridge_gives_up_on_books_that_never_open, a_call_cancelled_at_once_is_never_made, a_signalled_bridge_goes_at_once, books_made_mid_session_and_bad_requests (a slow `serve` holds the host; the bridge starts after it holds the root); books_commands_hold_the_books_while_they_run (serve holds, the commands lease); a_command_ends_at_its_deadline_during_a_restart (`token list`: `books list` with nothing running reads the folder and waits for nothing); a_bridge_started_without_stderr_keeps_its_descriptors_apart, the_commands_given_run_as_the_agents_own_token, an_agent_is_connected_and_reaches_the_books_by_what_it_was_given (Home::keep_host); doctor_says_whether_the_books_are_open_and_what_holds_them (new closed words). RETIRED (1): the_viewers_hold_new_books_and_close_the_books. Its viewer lease (hold_for_viewer) and "Close the books" (close_books) no longer exist: the app is the host. Covered by ledger-gui serving.rs (a_tab_opening_asks_the_server_to_open_that_company, a_tab_closing_asks_the_server_to_close_that_company, closing_the_window_stops_the_server_and_waits_for_it), owner_menu.rs (no "Close the books" item), and the replacement the_viewers_new_books_are_made_by_the_server (new_books through a server). Behaviours retired inside the moved tests, and what covers them: a command or a bridge starting a host and holding it for the close delay does not exist (app_server.rs: a_command_with_the_app_running_goes_to_its_server_and_leaves_it_running, with_nothing_running_a_command_runs_its_own_server_or_says_to_start_wanderbooks, the_bridge_says_the_app_isnt_running_then_works_once_it_is, a_command_leaves_nothing_running_and_serve_closes_after_its_last_holder); the close delay itself is kept for serve's host (same test). update.rs (16 tests) KEPT (6): an_update_replaces_the_program_keeps_the_old_one_and_rollback_brings_it_back, update_is_atomic, failed_update_rolls_back, unsigned_update_refused, package_managed_install_refuses_update, rollback_refuses_after_a_book_consented_to_a_newer_format, an_update_never_replaces_another_apps_appimage (the `update` command and the AppImage guard: no host involved). MOVED (9): bridge_survives_update, update_waits_for_a_running_call, a_replaced_appimage_restarts_the_books, the_host_stages_a_daily_update_and_the_next_start_applies_it, a_daily_update_that_is_not_ours_is_not_staged, update_installs_the_copy_the_host_staged_without_downloading_again, a_staged_update_that_was_tampered_with_is_dropped_not_applied, books_start_says_an_update_waits, the_owner_accepts_a_staged_update_in_the_app: the host they describe is serve's (restart onto a replaced file, update.lock, the daily look, the staged copy applied before a host starts), so the harness's Agent::start has a `serve` hold the books (Home::keep_host); the bridge's tool calls carry the request_key every write needs since D-88. RETIRED (0). translocation.rs (1 test) KEPT: translocated_app_refuses_to_connect. The refusal stays: an agent's pointer file records this program's path, which a quarantined download loses when the app closes, whatever starts the books. app_server.rs: no test retired. Changed: the_bridge_says_the_app_isnt_running_then_works_once_it_is (no marker; the words now name `wanderbooks serve`), a refusal touches nothing (the retired marker). New: a_mark_an_earlier_build_left_is_ignored_and_removed, a_terminal_ctrl_c_reaches_the_window_and_never_the_server (fails without the server's own process group: checked by removing it), a_command_with_the_app_running_goes_to_its_server_and_leaves_it_running, with_nothing_running_a_command_runs_its_own_server_or_says_to_start_wanderbooks, a_command_waits_in_words_for_a_server_that_is_still_opening. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
d81f6d5c83
commit
e9a520138d
3 files changed
+380
-81
No files matched your search
@@ -83,6 +83,9 @@ struct Home {
|
||||
/// from an image's mount, and `APPIMAGE` names this other file, the
|
||||
/// one an update replaces.
|
||||
image: Option<PathBuf>,
|
||||
/// The `wanderbooks serve` that holds the books for the test's agents
|
||||
/// ([`Home::keep_host`]): since P15 only `serve` starts a host.
|
||||
serving: std::sync::Mutex<Option<std::process::Child>>,
|
||||
}
|
||||
|
||||
impl Home {
|
||||
@@ -106,6 +109,7 @@ impl Home {
|
||||
dir,
|
||||
exe,
|
||||
image: None,
|
||||
serving: std::sync::Mutex::new(None),
|
||||
};
|
||||
home.runnable();
|
||||
home
|
||||
@@ -147,6 +151,32 @@ impl Home {
|
||||
}
|
||||
}
|
||||
|
||||
/// Hold the books with a `wanderbooks serve` (started again when the
|
||||
/// last one has ended, as a `close` ends it): the one program that
|
||||
/// starts a host (WB-app-5). It starts, as a host does, applying a
|
||||
/// staged update first, and the bridges of the test then lease it.
|
||||
fn keep_host(&self) {
|
||||
let mut serving = self.serving.lock().unwrap();
|
||||
if let Some(child) = serving.as_mut()
|
||||
&& child.try_wait().unwrap().is_none()
|
||||
{
|
||||
return;
|
||||
}
|
||||
let child = self
|
||||
.cmd("serve")
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.spawn()
|
||||
.unwrap();
|
||||
*serving = Some(child);
|
||||
let sock = self.root().join("run/mcp.sock");
|
||||
assert!(
|
||||
wait_for(60, || sock.exists()),
|
||||
"the books never opened under serve"
|
||||
);
|
||||
}
|
||||
|
||||
/// The environment of the pretend AppImage, if this is one.
|
||||
fn image_env(&self, c: &mut Command) {
|
||||
if let Some(image) = &self.image {
|
||||
@@ -618,6 +648,7 @@ struct Agent {
|
||||
|
||||
impl Agent {
|
||||
fn start(home: &Home, book: &str) -> Self {
|
||||
home.keep_host();
|
||||
let mut c = home.cmd("mcp");
|
||||
c.args(["--book", book]);
|
||||
let mut child = c
|
||||
@@ -651,6 +682,8 @@ impl Agent {
|
||||
}
|
||||
|
||||
fn send(&mut self, message: Value) {
|
||||
// A tool call carries the request key every write needs (D-88).
|
||||
let message = common::with_request_key(&message.to_string());
|
||||
let stdin = self.child.stdin.as_mut().unwrap();
|
||||
writeln!(stdin, "{message}").unwrap();
|
||||
stdin.flush().unwrap();
|
||||
|
||||
Reference in new issue
Block a user