aboutsummaryrefslogtreecommitdiff
path: root/tests/auto_detect.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto_detect.rs')
-rw-r--r--tests/auto_detect.rs118
1 files changed, 2 insertions, 116 deletions
diff --git a/tests/auto_detect.rs b/tests/auto_detect.rs
index 94ab3f07..49473dbb 100644
--- a/tests/auto_detect.rs
+++ b/tests/auto_detect.rs
@@ -2,7 +2,7 @@
#![cfg(not(target_os = "macos"))]
-mod support;
+pub mod support;
use std::fs;
use std::io::{BufRead, BufReader, Write};
@@ -150,7 +150,7 @@ fn spawn_herdr_auto(
.unwrap();
let mut cmd = CommandBuilder::new(env!("CARGO_BIN_EXE_herdr"));
- // No subcommand, no --no-session → auto-detect launch
+ // No subcommand → auto-detect launch.
cmd.env("XDG_CONFIG_HOME", config_home);
cmd.env("XDG_RUNTIME_DIR", runtime_dir);
cmd.env("HERDR_SOCKET_PATH", api_socket_path);
@@ -168,48 +168,6 @@ fn spawn_herdr_auto(
}
}
-/// Spawn `herdr --no-session` — the monolithic escape hatch.
-fn spawn_herdr_no_session(
- config_home: &Path,
- runtime_dir: &Path,
- api_socket_path: &Path,
-) -> SpawnedHerdr {
- fs::create_dir_all(config_home.join("herdr")).unwrap();
- fs::create_dir_all(runtime_dir).unwrap();
- register_runtime_dir(runtime_dir);
- fs::write(
- config_home.join("herdr/config.toml"),
- "onboarding = false\n",
- )
- .unwrap();
-
- let pair = native_pty_system()
- .openpty(PtySize {
- rows: 24,
- cols: 80,
- pixel_width: 0,
- pixel_height: 0,
- })
- .unwrap();
-
- let mut cmd = CommandBuilder::new(env!("CARGO_BIN_EXE_herdr"));
- cmd.arg("--no-session");
- cmd.env("XDG_CONFIG_HOME", config_home);
- cmd.env("XDG_RUNTIME_DIR", runtime_dir);
- cmd.env("HERDR_SOCKET_PATH", api_socket_path);
- cmd.env("SHELL", "/bin/sh");
- cmd.env_remove("HERDR_ENV");
-
- let child = pair.slave.spawn_command(cmd).unwrap();
- register_spawned_herdr_pid(child.process_id());
- drop(pair.slave);
-
- SpawnedHerdr {
- _master: pair.master,
- child,
- }
-}
-
fn ping_socket(socket_path: &Path) -> String {
let mut stream = UnixStream::connect(socket_path).expect("should connect to API socket");
@@ -423,50 +381,6 @@ fn auto_detect_socket_path_consistency() {
cleanup_spawned_herdr(herdr, base);
}
-/// `herdr --no-session` bypasses server/client and runs
-/// monolithically. No server process is spawned. No client socket is created.
-#[test]
-fn no_session_flag_runs_monolithically() {
- let _lock = test_lock();
- let base = unique_test_dir();
- let config_home = base.join("config");
- let runtime_dir = base.join("runtime");
- let api_socket = runtime_dir.join("herdr.sock");
- let client_socket = runtime_dir.join("herdr-client.sock");
-
- // Run `herdr --no-session` — monolithic mode, no server/client.
- let herdr = spawn_herdr_no_session(&config_home, &runtime_dir, &api_socket);
-
- // Wait for the API socket (monolithic mode creates it).
- wait_for_socket(&api_socket, Duration::from_secs(10));
-
- // Verify the API socket exists and responds.
- let response = ping_socket(&api_socket);
- assert!(
- response.contains("pong"),
- "monolithic API should respond: {response}"
- );
-
- // Verify NO client socket was created — this is the key distinction
- // between monolithic mode and server/client mode.
- assert!(
- !client_socket.exists(),
- "no client socket should exist in monolithic mode"
- );
-
- // Verify the API socket is served by the monolithic process itself,
- // not by a separate server. We can check this by verifying the client
- // PID matches what would be serving the socket — in monolithic mode,
- // there is only one herdr process.
- let client_pid = herdr.child.process_id().expect("should have PID");
- assert!(
- process_exists(client_pid),
- "monolithic process should be running"
- );
-
- cleanup_spawned_herdr(herdr, base);
-}
-
/// CLI subcommands work through the server's JSON API socket.
#[test]
fn cli_subcommands_work_through_server() {
@@ -701,34 +615,6 @@ fn auto_detect_writes_client_and_server_logs_to_separate_files() {
}
#[test]
-fn no_session_writes_startup_logs_to_monolith_file() {
- let _lock = test_lock();
- let base = unique_test_dir();
- let config_home = base.join("config");
- let runtime_dir = base.join("runtime");
- let api_socket = runtime_dir.join("herdr.sock");
-
- let spawned = spawn_herdr_no_session(&config_home, &runtime_dir, &api_socket);
- wait_for_socket(&api_socket, Duration::from_secs(10));
-
- let app_dir_name = if cfg!(debug_assertions) {
- "herdr-dev"
- } else {
- "herdr"
- };
- let log_dir = config_home.join(app_dir_name);
- let monolith_log = log_dir.join("herdr.log");
-
- wait_for_log_contains(
- &monolith_log,
- "event=\"app.startup\" subsystem=\"app\"",
- Duration::from_secs(10),
- );
-
- cleanup_spawned_herdr(spawned, base);
-}
-
-#[test]
fn auto_detect_respects_nested_guard_before_auto_attach() {
let _lock = test_lock();
let base = unique_test_dir();