Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

feat(dev-detach): Extract `dev-detach` helper into its own package

Maximilian Roos5a793ab7270a
diff --git a/Cargo.lock b/Cargo.lock
index b1eba83da..327e07611 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -707,6 +707,13 @@ dependencies = [
"syn",
]
+[[package]]
+name = "dev-detach"
+version = "0.1.0"
+dependencies = [
+ "nix 0.30.1",
+]
+
[[package]]
name = "digest"
version = "0.10.7"
@@ -2918,7 +2925,6 @@ dependencies = [
"insta-cmd",
"log",
"minijinja",
- "nix 0.30.1",
"osc8",
"portable-pty",
"rayon",
diff --git a/Cargo.toml b/Cargo.toml
index e9199995e..0f219d101 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
[workspace]
-members = ["tests/helpers/setup-select-test"]
+members = ["tests/helpers/setup-select-test", "tests/helpers/dev-detach"]
[package]
name = "worktrunk"
@@ -25,8 +25,7 @@ consolidate-commits = true
default = ["syntax-highlighting"]
syntax-highlighting = ["dep:tree-sitter", "dep:tree-sitter-bash", "dep:tree-sitter-highlight"]
# Enable shell integration tests (requires bash, zsh, fish installed on system)
-# Also builds dev-detach helper binary for TTY isolation
-shell-integration-tests = ["dep:nix"]
+shell-integration-tests = []
[lib]
name = "worktrunk"
@@ -36,13 +35,6 @@ path = "src/lib.rs"
name = "wt"
path = "src/main.rs"
-# Test helper for TTY isolation in shell integration tests (Unix only)
-# Excluded from `cargo install` via required-features
-[[bin]]
-name = "dev-detach"
-path = "src/bin/dev-detach.rs"
-required-features = ["shell-integration-tests"]
-
[dependencies]
anyhow = "1.0"
anstream = "0.6"
@@ -84,8 +76,6 @@ home = "0.5.12"
[target.'cfg(unix)'.dependencies]
skim = "0.20"
-# Used by dev-detach binary for TTY isolation in shell integration tests (optional)
-nix = { version = "0.30", default-features = false, features = ["process"], optional = true }
[build-dependencies]
vergen-gitcl = { version = "1.0.8", features = ["build"] }
@@ -113,7 +103,6 @@ harness = false
# Unsafe code is denied by default but can be explicitly allowed where necessary.
# Currently used for:
# - TTY detachment in pager invocation (pre_exec + setsid) to prevent hangs in TUI contexts
-# - dev-detach helper binary (uses nix crate's wrappers for Unix syscalls)
unsafe_code = "deny"
# The profile that 'dist' will build with
diff --git a/tests/common/shell.rs b/tests/common/shell.rs
index c7108cf5d..79c1ac195 100644
--- a/tests/common/shell.rs
+++ b/tests/common/shell.rs
@@ -1,9 +1,9 @@
use super::{TestRepo, wt_command};
use insta_cmd::get_cargo_bin;
-use std::process::Command;
+use std::{path::PathBuf, process::Command, sync::LazyLock};
-/// Path to dev-detach binary (built automatically as part of the crate).
-const DEV_DETACH_BIN: &str = env!("CARGO_BIN_EXE_dev-detach");
+/// Path to dev-detach binary (workspace member in tests/helpers/dev-detach).
+static DEV_DETACH_BIN: LazyLock<PathBuf> = LazyLock::new(|| get_cargo_bin("dev-detach"));
/// Convert signal number to human-readable name
#[cfg(unix)]
@@ -33,7 +33,7 @@ pub fn get_shell_binary(shell: &str) -> &str {
/// Build a command to execute a shell script via dev-detach.
fn build_shell_command(repo: &TestRepo, shell: &str, script: &str) -> Command {
- let mut cmd = Command::new(DEV_DETACH_BIN);
+ let mut cmd = Command::new(DEV_DETACH_BIN.as_os_str());
repo.clean_cli_env(&mut cmd);
// Prevent user shell config from leaking into tests
diff --git a/tests/helpers/dev-detach/Cargo.toml b/tests/helpers/dev-detach/Cargo.toml
new file mode 100644
index 000000000..ecfc1a5c2
--- /dev/null
+++ b/tests/helpers/dev-detach/Cargo.toml
@@ -0,0 +1,13 @@
+# Helper binary for TTY isolation in shell integration tests.
+# This is a workspace member (not a separate workspace) to share target/ and Cargo.lock.
+# Never published to crates.io (publish = false) - only used during development.
+[package]
+name = "dev-detach"
+version = "0.1.0"
+edition = "2024"
+publish = false
+
+[dependencies]
+
+[target.'cfg(unix)'.dependencies]
+nix = { version = "0.30", default-features = false, features = ["process"] }
diff --git a/src/bin/dev-detach.rs b/tests/helpers/dev-detach/src/main.rs
similarity index 100%
rename from src/bin/dev-detach.rs
rename to tests/helpers/dev-detach/src/main.rs