Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
more rstest (#150)
Maximilian Roos7723fce2808b
diff --git a/tests/common/mod.rs b/tests/common/mod.rsindex 6f11b8747..5a077449f 100644--- a/tests/common/mod.rs+++ b/tests/common/mod.rs@@ -134,6 +134,25 @@ pub fn repo() -> TestRepo {TestRepo::new()}+/// Temporary directory for use as fake home directory in tests.+///+/// Use this for tests that need to manipulate shell config files (~/.zshrc, ~/.bashrc, etc.)+/// or other home directory content. The directory is automatically cleaned up when dropped.+///+/// # Example+/// ```ignore+/// #[rstest]+/// fn test_shell_config(repo: TestRepo, temp_home: TempDir) {+/// let zshrc = temp_home.path().join(".zshrc");+/// fs::write(&zshrc, "# config").unwrap();+/// // test with temp_home as HOME+/// }+/// ```+#[rstest::fixture]+pub fn temp_home() -> TempDir {+ TempDir::new().unwrap()+}+/// Repo with remote tracking set up.////// Builds on the `repo` fixture, adding a "remote" for the default branch.@@ -1864,6 +1883,7 @@ fn is_leap_year(year: i64) -> bool {#[cfg(test)]mod tests {use super::*;+ use rstest::rstest;#[test]fn test_unix_to_iso8601() {@@ -1879,10 +1899,9 @@ mod tests {assert_eq!(unix_to_iso8601(1709164800), "2024-02-29T00:00:00Z");}- #[test]- fn test_commit_with_age() {+ #[rstest]+ fn test_commit_with_age(repo: TestRepo) {// TestRepo::new() already includes one initial commit from fixture- let repo = TestRepo::new();// Create commits with specific agesrepo.commit_with_age("One hour ago", HOUR);diff --git a/tests/integration_tests/approval_pty.rs b/tests/integration_tests/approval_pty.rsindex 8463111bf..bd3c1e361 100644--- a/tests/integration_tests/approval_pty.rs+++ b/tests/integration_tests/approval_pty.rs@@ -12,10 +12,11 @@//! buffering of input/output interleaving. Consider normalizing extra blank lines to make//! snapshots more stable across different environments (local vs CI vs Claude Code web).-use crate::common::TestRepo;+use crate::common::{TestRepo, repo};use insta::assert_snapshot;use insta_cmd::get_cargo_bin;use portable_pty::{CommandBuilder, PtySize};+use rstest::rstest;use std::io::{Read, Write};use std::path::Path;@@ -139,9 +140,8 @@ fn normalize_output(output: &str) -> String {output_str}-#[test]-fn test_approval_prompt_accept() {- let repo = TestRepo::new();+#[rstest]+fn test_approval_prompt_accept(repo: TestRepo) {repo.write_project_config(r#"post-create = "echo 'test command'""#);repo.commit("Add config");@@ -159,9 +159,8 @@ fn test_approval_prompt_accept() {assert_snapshot!("approval_prompt_accept", normalized);}-#[test]-fn test_approval_prompt_decline() {- let repo = TestRepo::new();+#[rstest]+fn test_approval_prompt_decline(repo: TestRepo) {repo.write_project_config(r#"post-create = "echo 'test command'""#);repo.commit("Add config");@@ -179,9 +178,8 @@ fn test_approval_prompt_decline() {assert_snapshot!("approval_prompt_decline", normalized);}-#[test]-fn test_approval_prompt_multiple_commands() {- let repo = TestRepo::new();+#[rstest]+fn test_approval_prompt_multiple_commands(repo: TestRepo) {repo.write_project_config(r#"[post-create]first = "echo 'First command'"@@ -207,9 +205,8 @@ third = "echo 'Third command'"/// TODO: Find a way to test permission errors without skipping when running as root./// See test_permission_error_prevents_save in approval_save.rs for details.-#[test]-fn test_approval_prompt_permission_error() {- let repo = TestRepo::new();+#[rstest]+fn test_approval_prompt_permission_error(repo: TestRepo) {repo.write_project_config(r#"post-create = "echo 'test command'""#);repo.commit("Add config");@@ -268,9 +265,8 @@ fn test_approval_prompt_permission_error() {assert_snapshot!("approval_prompt_permission_error", normalized);}-#[test]-fn test_approval_prompt_named_commands() {- let repo = TestRepo::new();+#[rstest]+fn test_approval_prompt_named_commands(repo: TestRepo) {repo.write_project_config(r#"[post-create]install = "echo 'Installing dependencies...'"@@ -306,9 +302,8 @@ test = "echo 'Running tests...'"assert_snapshot!("approval_prompt_named_commands", normalized);}-#[test]-fn test_approval_prompt_mixed_approved_unapproved_accept() {- let repo = TestRepo::new();+#[rstest]+fn test_approval_prompt_mixed_approved_unapproved_accept(repo: TestRepo) {repo.write_project_config(r#"[post-create]first = "echo 'First command'"@@ -364,9 +359,8 @@ approved-commands = ["echo 'Second command'"]);}-#[test]-fn test_approval_prompt_mixed_approved_unapproved_decline() {- let repo = TestRepo::new();+#[rstest]+fn test_approval_prompt_mixed_approved_unapproved_decline(repo: TestRepo) {repo.write_project_config(r#"[post-create]first = "echo 'First command'"diff --git a/tests/integration_tests/approvals.rs b/tests/integration_tests/approvals.rsindex 84ec8e5cd..828799eef 100644--- a/tests/integration_tests/approvals.rs+++ b/tests/integration_tests/approvals.rs@@ -1,7 +1,8 @@//! Integration tests for add-approvals and clear-approvals commands-use crate::common::{TestRepo, make_snapshot_cmd, setup_snapshot_settings};+use crate::common::{TestRepo, make_snapshot_cmd, repo, setup_snapshot_settings};use insta_cmd::assert_cmd_snapshot;+use rstest::rstest;use worktrunk::config::WorktrunkConfig;/// Helper to snapshot add-approvals command@@ -28,25 +29,21 @@ fn snapshot_clear_approvals(test_name: &str, repo: &TestRepo, args: &[&str]) {// add-approvals tests// ============================================================================-#[test]-fn test_add_approvals_no_config() {- let repo = TestRepo::new();-+#[rstest]+fn test_add_approvals_no_config(repo: TestRepo) {snapshot_add_approvals("add_approvals_no_config", &repo, &[]);}-#[test]-fn test_add_approvals_all_with_none_approved() {- let repo = TestRepo::new();+#[rstest]+fn test_add_approvals_all_with_none_approved(repo: TestRepo) {repo.write_project_config(r#"post-create = "echo 'test'""#);repo.commit("Add config");snapshot_add_approvals("add_approvals_all_none_approved", &repo, &["--all"]);}-#[test]-fn test_add_approvals_empty_config() {- let repo = TestRepo::new();+#[rstest]+fn test_add_approvals_empty_config(repo: TestRepo) {repo.write_project_config("");repo.commit("Add empty config");@@ -57,16 +54,13 @@ fn test_add_approvals_empty_config() {// clear-approvals tests// ============================================================================-#[test]-fn test_clear_approvals_no_approvals() {- let repo = TestRepo::new();-+#[rstest]+fn test_clear_approvals_no_approvals(repo: TestRepo) {snapshot_clear_approvals("clear_approvals_no_approvals", &repo, &[]);}-#[test]-fn test_clear_approvals_with_approvals() {- let repo = TestRepo::new();+#[rstest]+fn test_clear_approvals_with_approvals(repo: TestRepo) {let project_id = format!("{}/origin", repo.root_path().display());repo.commit("Initial commit");repo.write_project_config(r#"post-create = "echo 'test'""#);@@ -86,16 +80,13 @@ fn test_clear_approvals_with_approvals() {snapshot_clear_approvals("clear_approvals_with_approvals", &repo, &[]);}-#[test]-fn test_clear_approvals_global_no_approvals() {- let repo = TestRepo::new();-+#[rstest]+fn test_clear_approvals_global_no_approvals(repo: TestRepo) {snapshot_clear_approvals("clear_approvals_global_no_approvals", &repo, &["--global"]);}-#[test]-fn test_clear_approvals_global_with_approvals() {- let repo = TestRepo::new();+#[rstest]+fn test_clear_approvals_global_with_approvals(repo: TestRepo) {let project_id = format!("{}/origin", repo.root_path().display());repo.commit("Initial commit");repo.write_project_config(r#"post-create = "echo 'test'""#);@@ -119,9 +110,8 @@ fn test_clear_approvals_global_with_approvals() {);}-#[test]-fn test_clear_approvals_after_clear() {- let repo = TestRepo::new();+#[rstest]+fn test_clear_approvals_after_clear(repo: TestRepo) {let project_id = format!("{}/origin", repo.root_path().display());repo.commit("Initial commit");repo.write_project_config(r#"post-create = "echo 'test'""#);@@ -146,9 +136,8 @@ fn test_clear_approvals_after_clear() {snapshot_clear_approvals("clear_approvals_after_clear", &repo, &[]);}-#[test]-fn test_clear_approvals_multiple_approvals() {- let repo = TestRepo::new();+#[rstest]+fn test_clear_approvals_multiple_approvals(repo: TestRepo) {repo.write_project_config(r#"post-create = "echo 'first'"diff --git a/tests/integration_tests/bare_repository.rs b/tests/integration_tests/bare_repository.rsindex 48a2b67e7..a83b5ea6a 100644--- a/tests/integration_tests/bare_repository.rs+++ b/tests/integration_tests/bare_repository.rs@@ -1,5 +1,6 @@-use crate::common::{TestRepo, setup_temp_snapshot_settings, wait_for_file, wt_command};+use crate::common::{TestRepo, repo, setup_temp_snapshot_settings, wait_for_file, wt_command};use insta_cmd::assert_cmd_snapshot;+use rstest::rstest;use std::fs;use std::path::PathBuf;use std::process::Command;@@ -405,8 +406,8 @@ fn test_bare_repo_worktree_base_used_for_paths() {);}-#[test]-fn test_bare_repo_equivalent_to_normal_repo() {+#[rstest]+fn test_bare_repo_equivalent_to_normal_repo(repo: TestRepo) {// This test verifies that bare repos behave identically to normal repos// from the user's perspective@@ -415,16 +416,15 @@ fn test_bare_repo_equivalent_to_normal_repo() {let bare_main = bare_test.create_worktree("main", "bare-repo.main");bare_test.commit_in_worktree(&bare_main, "Commit in bare repo");- // Set up normal repo- let normal_test = TestRepo::new();- normal_test.commit("Commit in normal repo");+ // Set up normal repo (using fixture)+ repo.commit("Commit in normal repo");// Configure both with same worktree path patternlet config = r#"worktree-path = "{{ branch }}""#;fs::write(bare_test.config_path(), config).unwrap();- fs::write(normal_test.test_config_path(), config).unwrap();+ fs::write(repo.test_config_path(), config).unwrap();// List worktrees in both - should show similar structurelet mut bare_list = wt_command();@@ -432,8 +432,8 @@ worktree-path = "{{ branch }}"bare_list.arg("list").current_dir(&bare_main);let mut normal_list = wt_command();- normal_test.clean_cli_env(&mut normal_list);- normal_list.arg("list").current_dir(normal_test.root_path());+ repo.clean_cli_env(&mut normal_list);+ normal_list.arg("list").current_dir(repo.root_path());let bare_output = bare_list.output().unwrap();let normal_output = normal_list.output().unwrap();diff --git a/tests/integration_tests/column_alignment_verification.rs b/tests/integration_tests/column_alignment_verification.rsindex 1a3b17a6d..d9792dfb8 100644--- a/tests/integration_tests/column_alignment_verification.rs+++ b/tests/integration_tests/column_alignment_verification.rs@@ -11,8 +11,9 @@//!//! The detailed verification logic here catches alignment bugs that would slip through snapshot review.-use crate::common::{TestRepo, wt_command};+use crate::common::{TestRepo, repo, wt_command};use ansi_str::AnsiStr;+use rstest::rstest;use unicode_width::UnicodeWidthStr;/// Represents the start position of each column in a table row@@ -308,10 +309,8 @@ fn verify_table_alignment(output: &str) -> Result<(), String> {}}-#[test]-fn test_alignment_verification_with_varying_content() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_alignment_verification_with_varying_content(mut repo: TestRepo) {// Create diverse worktrees to test alignmentrepo.add_worktree("main-feature");repo.add_worktree("short");@@ -345,9 +344,8 @@ fn test_alignment_verification_with_varying_content() {}}-#[test]-fn test_alignment_with_unicode_content() {- let mut repo = TestRepo::new();+#[rstest]+fn test_alignment_with_unicode_content(mut repo: TestRepo) {repo.commit("Initial commit with émoji 🎉");// Create worktrees with unicode in names@@ -374,10 +372,8 @@ fn test_alignment_with_unicode_content() {}}-#[test]-fn test_alignment_with_sparse_columns() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_alignment_with_sparse_columns(mut repo: TestRepo) {// Create mix of worktrees - some with diffs, some withoutrepo.add_worktree("no-changes-1");@@ -412,10 +408,8 @@ fn test_alignment_with_sparse_columns() {}}-#[test]-fn test_alignment_real_world_scenario() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_alignment_real_world_scenario(mut repo: TestRepo) {// Create feature branches with varying amounts of working tree changes// This simulates a real-world scenario with different diff sizesrepo.add_worktree("feature-tiny");@@ -462,10 +456,8 @@ fn test_alignment_real_world_scenario() {}}-#[test]-fn test_alignment_at_different_terminal_widths() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_alignment_at_different_terminal_widths(mut repo: TestRepo) {repo.add_worktree("feature-a");repo.add_worktree("feature-b");diff --git a/tests/integration_tests/config_cache.rs b/tests/integration_tests/config_cache.rsindex b7077ee53..1a62d1c98 100644--- a/tests/integration_tests/config_cache.rs+++ b/tests/integration_tests/config_cache.rs@@ -1,5 +1,6 @@-use crate::common::{TEST_EPOCH, TestRepo, wt_command};+use crate::common::{TEST_EPOCH, TestRepo, repo, wt_command};use insta::assert_snapshot;+use rstest::rstest;use std::process::Command;fn wt_config_cache_cmd(repo: &TestRepo, args: &[&str]) -> Command {@@ -15,10 +16,8 @@ fn wt_config_cache_cmd(repo: &TestRepo, args: &[&str]) -> Command {// cache show// ============================================================================-#[test]-fn test_config_cache_show_empty() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_show_empty(repo: TestRepo) {let output = wt_config_cache_cmd(&repo, &["show"]).output().unwrap();assert!(output.status.success());assert_snapshot!(String::from_utf8_lossy(&output.stderr), @r"@@ -30,10 +29,8 @@ fn test_config_cache_show_empty() {");}-#[test]-fn test_config_cache_show_with_default_branch() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_show_with_default_branch(repo: TestRepo) {// Set default branch cache manuallyrepo.git_command(&["config", "worktrunk.defaultBranch", "main"]).status()@@ -50,10 +47,8 @@ fn test_config_cache_show_with_default_branch() {");}-#[test]-fn test_config_cache_show_with_ci_entries() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_show_with_ci_entries(repo: TestRepo) {// Add CI cache entries - use TEST_EPOCH for deterministic age=0s in snapshotsrepo.git_command(&["config",@@ -88,19 +83,15 @@ fn test_config_cache_show_with_ci_entries() {// cache clear// ============================================================================-#[test]-fn test_config_cache_clear_all_empty() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_clear_all_empty(repo: TestRepo) {let output = wt_config_cache_cmd(&repo, &["clear"]).output().unwrap();assert!(output.status.success());assert_snapshot!(String::from_utf8_lossy(&output.stderr), @"⚪ No caches to clear");}-#[test]-fn test_config_cache_clear_all_with_data() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_clear_all_with_data(repo: TestRepo) {// Set default branch cacherepo.git_command(&["config", "worktrunk.defaultBranch", "main"]).status()@@ -111,10 +102,8 @@ fn test_config_cache_clear_all_with_data() {assert_snapshot!(String::from_utf8_lossy(&output.stderr), @"✅ [32mCleared all caches[39m");}-#[test]-fn test_config_cache_clear_default_branch() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_clear_default_branch(repo: TestRepo) {// Set default branch cacherepo.git_command(&["config", "worktrunk.defaultBranch", "main"]).status()@@ -127,10 +116,8 @@ fn test_config_cache_clear_default_branch() {assert_snapshot!(String::from_utf8_lossy(&output.stderr), @"✅ [32mCleared default branch cache[39m");}-#[test]-fn test_config_cache_clear_default_branch_empty() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_clear_default_branch_empty(repo: TestRepo) {let output = wt_config_cache_cmd(&repo, &["clear", "default-branch"]).output().unwrap();@@ -138,10 +125,8 @@ fn test_config_cache_clear_default_branch_empty() {assert_snapshot!(String::from_utf8_lossy(&output.stderr), @"⚪ No default branch cache to clear");}-#[test]-fn test_config_cache_clear_ci_empty() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_clear_ci_empty(repo: TestRepo) {let output = wt_config_cache_cmd(&repo, &["clear", "ci"]).output().unwrap();@@ -149,10 +134,8 @@ fn test_config_cache_clear_ci_empty() {assert_snapshot!(String::from_utf8_lossy(&output.stderr), @"⚪ No CI cache entries to clear");}-#[test]-fn test_config_cache_clear_unknown_type() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_clear_unknown_type(repo: TestRepo) {let output = wt_config_cache_cmd(&repo, &["clear", "unknown"]).output().unwrap();@@ -165,10 +148,8 @@ fn test_config_cache_clear_unknown_type() {");}-#[test]-fn test_config_cache_clear_logs_empty() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_clear_logs_empty(repo: TestRepo) {let output = wt_config_cache_cmd(&repo, &["clear", "logs"]).output().unwrap();@@ -176,10 +157,8 @@ fn test_config_cache_clear_logs_empty() {assert_snapshot!(String::from_utf8_lossy(&output.stderr), @"⚪ No logs to clear");}-#[test]-fn test_config_cache_clear_logs_with_files() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_clear_logs_with_files(repo: TestRepo) {// Create wt-logs directory with some log fileslet git_dir = repo.root_path().join(".git");let log_dir = git_dir.join("wt-logs");@@ -197,10 +176,8 @@ fn test_config_cache_clear_logs_with_files() {assert!(!log_dir.exists());}-#[test]-fn test_config_cache_clear_logs_single_file() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_clear_logs_single_file(repo: TestRepo) {// Create wt-logs directory with one log filelet git_dir = repo.root_path().join(".git");let log_dir = git_dir.join("wt-logs");@@ -214,10 +191,8 @@ fn test_config_cache_clear_logs_single_file() {assert_snapshot!(String::from_utf8_lossy(&output.stderr), @"✅ [32mCleared [1m1[22m log file[39m");}-#[test]-fn test_config_cache_clear_all_with_logs() {- let repo = TestRepo::new();-+#[rstest]+fn test_config_cache_clear_all_with_logs(repo: TestRepo) {// Create wt-logs directory with a log filelet git_dir = repo.root_path().join(".git");let log_dir = git_dir.join("wt-logs");diff --git a/tests/integration_tests/config_init.rs b/tests/integration_tests/config_init.rsindex 4167afa80..af8746590 100644--- a/tests/integration_tests/config_init.rs+++ b/tests/integration_tests/config_init.rs@@ -1,13 +1,12 @@-use crate::common::{set_temp_home_env, setup_home_snapshot_settings, wt_command};+use crate::common::{set_temp_home_env, setup_home_snapshot_settings, temp_home, wt_command};use insta_cmd::assert_cmd_snapshot;+use rstest::rstest;use std::fs;use tempfile::TempDir;/// Test `wt config create` when config already exists (should show info message with emoji)-#[test]-fn test_config_init_already_exists() {- let temp_home = TempDir::new().unwrap();-+#[rstest]+fn test_config_init_already_exists(temp_home: TempDir) {// Create fake global config at XDG pathlet global_config_dir = temp_home.path().join(".config").join("worktrunk");fs::create_dir_all(&global_config_dir).unwrap();@@ -38,10 +37,8 @@ fn test_config_init_already_exists() {}/// Test `wt config create` creates new config file-#[test]-fn test_config_init_creates_file() {- let temp_home = TempDir::new().unwrap();-+#[rstest]+fn test_config_init_creates_file(temp_home: TempDir) {// Don't create config file - let create create itlet global_config_dir = temp_home.path().join(".config").join("worktrunk");fs::create_dir_all(&global_config_dir).unwrap();diff --git a/tests/integration_tests/config_show.rs b/tests/integration_tests/config_show.rsindex 045bfe3bc..a82f5b6f7 100644--- a/tests/integration_tests/config_show.rs+++ b/tests/integration_tests/config_show.rs@@ -1,5 +1,8 @@-use crate::common::{TestRepo, set_temp_home_env, setup_snapshot_settings_with_home, wt_command};+use crate::common::{+ TestRepo, repo, set_temp_home_env, setup_snapshot_settings_with_home, temp_home, wt_command,+};use insta_cmd::assert_cmd_snapshot;+use rstest::rstest;use std::fs;use tempfile::TempDir;@@ -8,12 +11,9 @@ use tempfile::TempDir;// Fix needed: either use cmd.exe /c wrapper or create actual .exe shims./// Test `wt config show` with both global and project configs present-#[test]+#[rstest]#[cfg_attr(windows, ignore = "mock gh/glab batch files not found on Windows")]-fn test_config_show_with_project_config() {- let mut repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+fn test_config_show_with_project_config(mut repo: TestRepo, temp_home: TempDir) {// Setup mock gh/glab for deterministic BINARIES outputrepo.setup_mock_ci_tools_unauthenticated();@@ -56,12 +56,9 @@ server = "npm run dev"}/// Test `wt config show` when there is no project config-#[test]+#[rstest]#[cfg_attr(windows, ignore = "mock gh/glab batch files not found on Windows")]-fn test_config_show_no_project_config() {- let mut repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+fn test_config_show_no_project_config(mut repo: TestRepo, temp_home: TempDir) {// Setup mock gh/glab for deterministic BINARIES outputrepo.setup_mock_ci_tools_unauthenticated();@@ -88,12 +85,10 @@ fn test_config_show_no_project_config() {}/// Test `wt config show` outside a git repository-#[test]+#[rstest]#[cfg_attr(windows, ignore = "mock gh/glab batch files not found on Windows")]-fn test_config_show_outside_git_repo() {- let mut repo = TestRepo::new();+fn test_config_show_outside_git_repo(mut repo: TestRepo, temp_home: TempDir) {let temp_dir = tempfile::tempdir().unwrap();- let temp_home = TempDir::new().unwrap();// Setup mock gh/glab for deterministic BINARIES outputrepo.setup_mock_ci_tools_unauthenticated();@@ -120,12 +115,9 @@ fn test_config_show_outside_git_repo() {}/// Test `wt config show` warns when zsh compinit is not enabled-#[test]+#[rstest]#[cfg_attr(windows, ignore = "mock gh/glab batch files not found on Windows")]-fn test_config_show_zsh_compinit_warning() {- let mut repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+fn test_config_show_zsh_compinit_warning(mut repo: TestRepo, temp_home: TempDir) {// Setup mock gh/glab for deterministic BINARIES outputrepo.setup_mock_ci_tools_unauthenticated();@@ -158,12 +150,9 @@ if command -v wt >/dev/null 2>&1; then eval "$(command wt config shell init zsh)}/// Test `wt config show` shows hint when some shells configured, some not-#[test]+#[rstest]#[cfg_attr(windows, ignore = "mock gh/glab batch files not found on Windows")]-fn test_config_show_partial_shell_config_shows_hint() {- let mut repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+fn test_config_show_partial_shell_config_shows_hint(mut repo: TestRepo, temp_home: TempDir) {// Setup mock gh/glab for deterministic BINARIES outputrepo.setup_mock_ci_tools_unauthenticated();@@ -204,12 +193,9 @@ if command -v wt >/dev/null 2>&1; then eval "$(command wt config shell init zsh)}/// Test `wt config show` shows no warning when zsh compinit is enabled-#[test]+#[rstest]#[cfg_attr(windows, ignore = "mock gh/glab batch files not found on Windows")]-fn test_config_show_zsh_compinit_correct_order() {- let mut repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+fn test_config_show_zsh_compinit_correct_order(mut repo: TestRepo, temp_home: TempDir) {// Setup mock gh/glab for deterministic BINARIES outputrepo.setup_mock_ci_tools_unauthenticated();@@ -244,12 +230,9 @@ if command -v wt >/dev/null 2>&1; then eval "$(command wt config shell init zsh)}/// Test `wt config show` warns about unknown/misspelled keys in project config-#[test]+#[rstest]#[cfg_attr(windows, ignore = "mock gh/glab batch files not found on Windows")]-fn test_config_show_warns_unknown_project_keys() {- let mut repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+fn test_config_show_warns_unknown_project_keys(mut repo: TestRepo, temp_home: TempDir) {// Setup mock gh/glab for deterministic BINARIES outputrepo.setup_mock_ci_tools_unauthenticated();@@ -284,12 +267,9 @@ fn test_config_show_warns_unknown_project_keys() {}/// Test `wt config show` warns about unknown keys in user config-#[test]+#[rstest]#[cfg_attr(windows, ignore = "mock gh/glab batch files not found on Windows")]-fn test_config_show_warns_unknown_user_keys() {- let mut repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+fn test_config_show_warns_unknown_user_keys(mut repo: TestRepo, temp_home: TempDir) {// Setup mock gh/glab for deterministic BINARIES outputrepo.setup_mock_ci_tools_unauthenticated();@@ -315,12 +295,9 @@ fn test_config_show_warns_unknown_user_keys() {}/// Test `wt config show --full` when commit generation is not configured-#[test]+#[rstest]#[cfg_attr(windows, ignore = "mock gh/glab batch files not found on Windows")]-fn test_config_show_full_not_configured() {- let mut repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+fn test_config_show_full_not_configured(mut repo: TestRepo, temp_home: TempDir) {// Setup mock gh/glab for deterministic BINARIES outputrepo.setup_mock_ci_tools_unauthenticated();@@ -352,12 +329,9 @@ fn test_config_show_full_not_configured() {}/// Test `wt config show --full` when commit generation command doesn't exist-#[test]+#[rstest]#[cfg_attr(windows, ignore = "mock gh/glab batch files not found on Windows")]-fn test_config_show_full_command_not_found() {- let mut repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+fn test_config_show_full_command_not_found(mut repo: TestRepo, temp_home: TempDir) {// Setup mock gh/glab for deterministic BINARIES outputrepo.setup_mock_ci_tools_unauthenticated();diff --git a/tests/integration_tests/config_var.rs b/tests/integration_tests/config_var.rsindex 41f01f35a..5f801c5f3 100644--- a/tests/integration_tests/config_var.rs+++ b/tests/integration_tests/config_var.rs@@ -1,5 +1,6 @@-use crate::common::{TestRepo, wt_command};+use crate::common::{TestRepo, repo, wt_command};use insta::assert_snapshot;+use rstest::rstest;use std::process::Command;fn wt_var_set_cmd(repo: &TestRepo, args: &[&str]) -> Command {@@ -29,10 +30,8 @@ fn wt_var_get_cmd(repo: &TestRepo, args: &[&str]) -> Command {cmd}-#[test]-fn test_var_set_marker_branch_default() {- let repo = TestRepo::new();-+#[rstest]+fn test_var_set_marker_branch_default(repo: TestRepo) {let output = wt_var_set_cmd(&repo, &["marker", "🚧"]).output().unwrap();assert!(output.status.success());assert_snapshot!(String::from_utf8_lossy(&output.stderr), @"✅ [32mSet marker for [1mmain[22m to [1m🚧[22m[39m");@@ -45,9 +44,8 @@ fn test_var_set_marker_branch_default() {assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "🚧");}-#[test]-fn test_var_set_marker_branch_specific() {- let repo = TestRepo::new();+#[rstest]+fn test_var_set_marker_branch_specific(repo: TestRepo) {repo.git_command(&["branch", "feature"]).status().unwrap();let output = wt_var_set_cmd(&repo, &["marker", "🔧", "--branch", "feature"])@@ -64,10 +62,8 @@ fn test_var_set_marker_branch_specific() {assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "🔧");}-#[test]-fn test_var_clear_marker_branch_default() {- let repo = TestRepo::new();-+#[rstest]+fn test_var_clear_marker_branch_default(repo: TestRepo) {// Set a marker firstrepo.git_command(&["config", "worktrunk.marker.main", "🚧"]).status()@@ -85,10 +81,8 @@ fn test_var_clear_marker_branch_default() {assert!(!output.status.success());}-#[test]-fn test_var_clear_marker_branch_specific() {- let repo = TestRepo::new();-+#[rstest]+fn test_var_clear_marker_branch_specific(repo: TestRepo) {// Set a marker firstrepo.git_command(&["config", "worktrunk.marker.feature", "🔧"]).status()@@ -108,10 +102,8 @@ fn test_var_clear_marker_branch_specific() {assert!(!output.status.success());}-#[test]-fn test_var_clear_marker_all() {- let repo = TestRepo::new();-+#[rstest]+fn test_var_clear_marker_all(repo: TestRepo) {// Set multiple markersrepo.git_command(&["config", "worktrunk.marker.main", "🚧"]).status()@@ -137,10 +129,8 @@ fn test_var_clear_marker_all() {assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");}-#[test]-fn test_var_clear_marker_all_empty() {- let repo = TestRepo::new();-+#[rstest]+fn test_var_clear_marker_all_empty(repo: TestRepo) {let output = wt_var_clear_cmd(&repo, &["marker", "--all"]).output().unwrap();@@ -148,10 +138,8 @@ fn test_var_clear_marker_all_empty() {assert_snapshot!(String::from_utf8_lossy(&output.stderr), @"⚪ No markers to clear");}-#[test]-fn test_var_get_marker() {- let repo = TestRepo::new();-+#[rstest]+fn test_var_get_marker(repo: TestRepo) {// Set a marker firstrepo.git_command(&["config", "worktrunk.marker.main", "🚧"]).status()@@ -163,19 +151,16 @@ fn test_var_get_marker() {assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "🚧");}-#[test]-fn test_var_get_marker_empty() {- let repo = TestRepo::new();-+#[rstest]+fn test_var_get_marker_empty(repo: TestRepo) {let output = wt_var_get_cmd(&repo, &["marker"]).output().unwrap();assert!(output.status.success());// Empty output when no marker is setassert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "");}-#[test]-fn test_var_get_marker_specific_branch() {- let repo = TestRepo::new();+#[rstest]+fn test_var_get_marker_specific_branch(repo: TestRepo) {repo.git_command(&["branch", "feature"]).status().unwrap();// Set a marker for feature branch@@ -191,20 +176,16 @@ fn test_var_get_marker_specific_branch() {assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "🔧");}-#[test]-fn test_var_get_default_branch() {- let repo = TestRepo::new();-+#[rstest]+fn test_var_get_default_branch(repo: TestRepo) {let output = wt_var_get_cmd(&repo, &["default-branch"]).output().unwrap();assert!(output.status.success());// data() writes to stdout for pipingassert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "main");}-#[test]-fn test_var_get_default_branch_no_remote() {- let repo = TestRepo::new();-+#[rstest]+fn test_var_get_default_branch_no_remote(repo: TestRepo) {// Without remote, should infer from local brancheslet output = wt_var_get_cmd(&repo, &["default-branch"]).output().unwrap();assert!(output.status.success());@@ -212,19 +193,16 @@ fn test_var_get_default_branch_no_remote() {assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "main");}-#[test]-fn test_var_get_ci_status() {- let repo = TestRepo::new();-+#[rstest]+fn test_var_get_ci_status(repo: TestRepo) {// Without any CI configured, should return "noci"let output = wt_var_get_cmd(&repo, &["ci-status"]).output().unwrap();assert!(output.status.success());assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "noci");}-#[test]-fn test_var_get_ci_status_specific_branch() {- let repo = TestRepo::new();+#[rstest]+fn test_var_get_ci_status_specific_branch(repo: TestRepo) {repo.git_command(&["branch", "feature"]).status().unwrap();// Without any CI configured, should return "noci"@@ -235,10 +213,8 @@ fn test_var_get_ci_status_specific_branch() {assert_eq!(String::from_utf8_lossy(&output.stdout).trim(), "noci");}-#[test]-fn test_var_get_ci_status_nonexistent_branch() {- let repo = TestRepo::new();-+#[rstest]+fn test_var_get_ci_status_nonexistent_branch(repo: TestRepo) {// Should error for nonexistent branchlet output = wt_var_get_cmd(&repo, &["ci-status", "--branch", "nonexistent"]).output()diff --git a/tests/integration_tests/configure_shell.rs b/tests/integration_tests/configure_shell.rsindex fc9de7cdb..06bf4e0fa 100644--- a/tests/integration_tests/configure_shell.rs+++ b/tests/integration_tests/configure_shell.rs@@ -1,4 +1,6 @@-use crate::common::{TestRepo, repo, set_temp_home_env, setup_home_snapshot_settings, wt_command};+use crate::common::{+ TestRepo, repo, set_temp_home_env, setup_home_snapshot_settings, temp_home, wt_command,+};use insta_cmd::assert_cmd_snapshot;use rstest::rstest;use std::fs;@@ -6,9 +8,7 @@ use tempfile::TempDir;/// Test `wt config shell install` with --force flag (skips confirmation)#[rstest]-fn test_configure_shell_with_yes(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_with_yes(repo: TestRepo, temp_home: TempDir) {// Create a fake .zshrc filelet zshrc_path = temp_home.path().join(".zshrc");fs::write(&zshrc_path, "# Existing config\n").unwrap();@@ -51,9 +51,7 @@ fn test_configure_shell_with_yes(repo: TestRepo) {/// Test `wt config shell install` with specific shell#[rstest]-fn test_configure_shell_specific_shell(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_specific_shell(repo: TestRepo, temp_home: TempDir) {// Create a fake .zshrc filelet zshrc_path = temp_home.path().join(".zshrc");fs::write(&zshrc_path, "# Existing config\n").unwrap();@@ -95,9 +93,7 @@ fn test_configure_shell_specific_shell(repo: TestRepo) {/// Test `wt config shell install` when line already exists#[rstest]-fn test_configure_shell_already_exists(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_already_exists(repo: TestRepo, temp_home: TempDir) {// Create a fake .zshrc file with the line already presentlet zshrc_path = temp_home.path().join(".zshrc");fs::write(@@ -138,9 +134,7 @@ fn test_configure_shell_already_exists(repo: TestRepo) {/// Test `wt config shell install` for Fish (creates new file in conf.d/)#[rstest]-fn test_configure_shell_fish(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_fish(repo: TestRepo, temp_home: TempDir) {let settings = setup_home_snapshot_settings(&temp_home);settings.bind(|| {let mut cmd = wt_command();@@ -183,9 +177,7 @@ fn test_configure_shell_fish(repo: TestRepo) {/// Test `wt config shell install` when fish extension already exists/// Fish completions are now inline in the init script, so no separate file is needed#[rstest]-fn test_configure_shell_fish_extension_exists(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_fish_extension_exists(repo: TestRepo, temp_home: TempDir) {// Create fish conf.d directory with wt.fish (extension exists)let conf_d = temp_home.path().join(".config/fish/conf.d");fs::create_dir_all(&conf_d).unwrap();@@ -239,9 +231,7 @@ fn test_configure_shell_fish_extension_exists(repo: TestRepo) {/// Test `wt config shell install` when no config files exist#[rstest]-fn test_configure_shell_no_files(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_no_files(repo: TestRepo, temp_home: TempDir) {let settings = setup_home_snapshot_settings(&temp_home);settings.bind(|| {let mut cmd = wt_command();@@ -270,9 +260,7 @@ fn test_configure_shell_no_files(repo: TestRepo) {/// Test `wt config shell install` with multiple existing config files#[rstest]-fn test_configure_shell_multiple_configs(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_multiple_configs(repo: TestRepo, temp_home: TempDir) {// Create multiple shell config fileslet bash_config_path = temp_home.path().join(".bashrc");let zshrc_path = temp_home.path().join(".zshrc");@@ -326,9 +314,7 @@ fn test_configure_shell_multiple_configs(repo: TestRepo) {/// Test `wt config shell install` shows both shells needing updates and already configured shells#[rstest]-fn test_configure_shell_mixed_states(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_mixed_states(repo: TestRepo, temp_home: TempDir) {// Create bash config with wt already configuredlet bash_config_path = temp_home.path().join(".bashrc");fs::write(@@ -390,9 +376,7 @@ fn test_configure_shell_mixed_states(repo: TestRepo) {/// Test `wt config shell uninstall` removes shell integration#[rstest]-fn test_uninstall_shell(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_uninstall_shell(repo: TestRepo, temp_home: TempDir) {// Create a fake .zshrc file with wt integrationlet zshrc_path = temp_home.path().join(".zshrc");fs::write(@@ -443,9 +427,7 @@ fn test_uninstall_shell(repo: TestRepo) {/// Test `wt config shell uninstall` with multiple shells#[rstest]-fn test_uninstall_shell_multiple(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_uninstall_shell_multiple(repo: TestRepo, temp_home: TempDir) {// Create multiple shell configs with wt integrationlet bash_config_path = temp_home.path().join(".bashrc");let zshrc_path = temp_home.path().join(".zshrc");@@ -504,9 +486,7 @@ fn test_uninstall_shell_multiple(repo: TestRepo) {/// Test `wt config shell uninstall` when not installed#[rstest]-fn test_uninstall_shell_not_found(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_uninstall_shell_not_found(repo: TestRepo, temp_home: TempDir) {// Create a fake .zshrc file without wt integrationlet zshrc_path = temp_home.path().join(".zshrc");fs::write(&zshrc_path, "# Existing config\n").unwrap();@@ -537,9 +517,7 @@ fn test_uninstall_shell_not_found(repo: TestRepo) {/// Test `wt config shell uninstall` for Fish (deletes file)#[rstest]-fn test_uninstall_shell_fish(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_uninstall_shell_fish(repo: TestRepo, temp_home: TempDir) {// Create fish conf.d directory with wt.fishlet conf_d = temp_home.path().join(".config/fish/conf.d");fs::create_dir_all(&conf_d).unwrap();@@ -582,9 +560,7 @@ fn test_uninstall_shell_fish(repo: TestRepo) {/// Test install and then uninstall roundtrip#[rstest]-fn test_install_uninstall_roundtrip(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_install_uninstall_roundtrip(repo: TestRepo, temp_home: TempDir) {// Create initial config filelet zshrc_path = temp_home.path().join(".zshrc");fs::write(@@ -649,9 +625,7 @@ fn test_install_uninstall_roundtrip(repo: TestRepo) {/// Test that compinit warning does NOT show when .zshrc has compinit enabled#[rstest]-fn test_configure_shell_no_warning_when_compinit_enabled(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_no_warning_when_compinit_enabled(repo: TestRepo, temp_home: TempDir) {// Create a .zshrc that enables compinit - detection should find itlet zshrc_path = temp_home.path().join(".zshrc");fs::write(@@ -692,9 +666,7 @@ fn test_configure_shell_no_warning_when_compinit_enabled(repo: TestRepo) {/// Test that compinit warning does NOT show when $SHELL is bash (not a zsh user)/// Even when installing all shells, we don't warn bash users about zsh compinit#[rstest]-fn test_configure_shell_no_warning_for_bash_user(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_no_warning_for_bash_user(repo: TestRepo, temp_home: TempDir) {// Create config files for both shells (no compinit in zshrc)let zshrc_path = temp_home.path().join(".zshrc");let bashrc_path = temp_home.path().join(".bashrc");@@ -733,9 +705,7 @@ fn test_configure_shell_no_warning_for_bash_user(repo: TestRepo) {/// Test that compinit warning does NOT show when installing fish (even if SHELL=zsh)/// Only `install zsh` or `install` (all) should trigger zsh-specific warnings#[rstest]-fn test_configure_shell_no_warning_for_fish_install(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_no_warning_for_fish_install(repo: TestRepo, temp_home: TempDir) {// Create fish conf.d directorylet fish_conf_d = temp_home.path().join(".config/fish/conf.d");fs::create_dir_all(&fish_conf_d).unwrap();@@ -770,9 +740,7 @@ fn test_configure_shell_no_warning_for_fish_install(repo: TestRepo) {/// Test that compinit warning does NOT show when zsh is already configured#[rstest]-fn test_configure_shell_no_warning_when_already_configured(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_no_warning_when_already_configured(repo: TestRepo, temp_home: TempDir) {// Create a .zshrc that ALREADY has wt integration (no compinit)let zshrc_path = temp_home.path().join(".zshrc");fs::write(@@ -809,9 +777,7 @@ fn test_configure_shell_no_warning_when_already_configured(repo: TestRepo) {/// Test that compinit warning does NOT show when $SHELL is unset#[rstest]-fn test_configure_shell_no_warning_when_shell_unset(repo: TestRepo) {- let temp_home = TempDir::new().unwrap();-+fn test_configure_shell_no_warning_when_shell_unset(repo: TestRepo, temp_home: TempDir) {// Create zsh and bash config files (no compinit)let zshrc_path = temp_home.path().join(".zshrc");let bashrc_path = temp_home.path().join(".bashrc");diff --git a/tests/integration_tests/default_branch.rs b/tests/integration_tests/default_branch.rsindex 6fa09ba7f..22042294b 100644--- a/tests/integration_tests/default_branch.rs+++ b/tests/integration_tests/default_branch.rs@@ -1,11 +1,9 @@-use crate::common::TestRepo;+use crate::common::{TestRepo, repo, repo_with_remote};+use rstest::rstest;use worktrunk::git::Repository;-#[test]-fn test_get_default_branch_with_origin_head() {- let mut repo = TestRepo::new();- repo.setup_remote("main");-+#[rstest]+fn test_get_default_branch_with_origin_head(#[from(repo_with_remote)] repo: TestRepo) {// origin/HEAD should be set automatically by setup_remoteassert!(repo.has_origin_head());@@ -14,11 +12,8 @@ fn test_get_default_branch_with_origin_head() {assert_eq!(branch, "main");}-#[test]-fn test_get_default_branch_without_origin_head() {- let mut repo = TestRepo::new();- repo.setup_remote("main");-+#[rstest]+fn test_get_default_branch_without_origin_head(#[from(repo_with_remote)] repo: TestRepo) {// Clear origin/HEAD to force remote queryrepo.clear_origin_head();assert!(!repo.has_origin_head());@@ -31,11 +26,8 @@ fn test_get_default_branch_without_origin_head() {assert!(repo.has_origin_head());}-#[test]-fn test_get_default_branch_caches_result() {- let mut repo = TestRepo::new();- repo.setup_remote("main");-+#[rstest]+fn test_get_default_branch_caches_result(#[from(repo_with_remote)] repo: TestRepo) {// Clear origin/HEADrepo.clear_origin_head();assert!(!repo.has_origin_head());@@ -49,10 +41,8 @@ fn test_get_default_branch_caches_result() {assert_eq!(branch, "main");}-#[test]-fn test_get_default_branch_no_remote() {- let repo = TestRepo::new();-+#[rstest]+fn test_get_default_branch_no_remote(repo: TestRepo) {// No remote configured, should infer from local branches// Since there's only one local branch, it should return thatlet result = Repository::at(repo.root_path()).default_branch();@@ -67,9 +57,8 @@ fn test_get_default_branch_no_remote() {assert_eq!(inferred_branch, current_branch);}-#[test]-fn test_get_default_branch_with_custom_remote() {- let mut repo = TestRepo::new();+#[rstest]+fn test_get_default_branch_with_custom_remote(mut repo: TestRepo) {repo.setup_custom_remote("upstream", "main");// Test that we can get the default branch from a custom remote@@ -77,9 +66,8 @@ fn test_get_default_branch_with_custom_remote() {assert_eq!(branch, "main");}-#[test]-fn test_primary_remote_detects_custom_remote() {- let mut repo = TestRepo::new();+#[rstest]+fn test_primary_remote_detects_custom_remote(mut repo: TestRepo) {repo.setup_custom_remote("upstream", "develop");// Test that primary_remote detects the custom remote name@@ -87,9 +75,8 @@ fn test_primary_remote_detects_custom_remote() {assert_eq!(remote, "upstream");}-#[test]-fn test_branch_exists_with_custom_remote() {- let mut repo = TestRepo::new();+#[rstest]+fn test_branch_exists_with_custom_remote(mut repo: TestRepo) {repo.setup_custom_remote("upstream", "main");let git_repo = Repository::at(repo.root_path());@@ -101,10 +88,8 @@ fn test_branch_exists_with_custom_remote() {assert!(!git_repo.branch_exists("nonexistent").unwrap());}-#[test]-fn test_get_default_branch_no_remote_common_names_fallback() {- let repo = TestRepo::new();-+#[rstest]+fn test_get_default_branch_no_remote_common_names_fallback(repo: TestRepo) {// Create additional branches (no remote configured)repo.git_command(&["branch", "feature"]).status().unwrap();repo.git_command(&["branch", "bugfix"]).status().unwrap();@@ -115,10 +100,8 @@ fn test_get_default_branch_no_remote_common_names_fallback() {assert_eq!(branch, "main");}-#[test]-fn test_get_default_branch_no_remote_master_fallback() {- let repo = TestRepo::new();-+#[rstest]+fn test_get_default_branch_no_remote_master_fallback(repo: TestRepo) {// Rename main to master, then create other branchesrepo.git_command(&["branch", "-m", "main", "master"]).status()@@ -132,10 +115,8 @@ fn test_get_default_branch_no_remote_master_fallback() {assert_eq!(branch, "master");}-#[test]-fn test_get_default_branch_no_remote_init_default_branch_config() {- let repo = TestRepo::new();-+#[rstest]+fn test_get_default_branch_no_remote_init_default_branch_config(repo: TestRepo) {// Rename main to something non-standard, create the configured defaultrepo.git_command(&["branch", "-m", "main", "primary"]).status()@@ -153,10 +134,8 @@ fn test_get_default_branch_no_remote_init_default_branch_config() {assert_eq!(branch, "primary");}-#[test]-fn test_get_default_branch_no_remote_fails_when_no_match() {- let repo = TestRepo::new();-+#[rstest]+fn test_get_default_branch_no_remote_fails_when_no_match(repo: TestRepo) {// Rename main to something non-standardrepo.git_command(&["branch", "-m", "main", "xyz"]).status()diff --git a/tests/integration_tests/directives.rs b/tests/integration_tests/directives.rsindex f475dbb4a..130057293 100644--- a/tests/integration_tests/directives.rs+++ b/tests/integration_tests/directives.rs@@ -1,4 +1,4 @@-use crate::common::{TestRepo, repo, setup_snapshot_settings, wt_command};+use crate::common::{TestRepo, repo, repo_with_remote, setup_snapshot_settings, wt_command};use insta::Settings;use insta_cmd::assert_cmd_snapshot;use rstest::rstest;@@ -13,8 +13,7 @@ use rstest::rstest;/// Test that switch with --internal=powershell outputs PowerShell Set-Location syntax#[rstest]-fn test_switch_internal_powershell_directive(mut repo: TestRepo) {- repo.setup_remote("main");+fn test_switch_internal_powershell_directive(#[from(repo_with_remote)] mut repo: TestRepo) {let _feature_wt = repo.add_worktree("feature");let mut settings = setup_snapshot_settings(&repo);@@ -37,8 +36,7 @@ fn test_switch_internal_powershell_directive(mut repo: TestRepo) {/// Test merge with --internal=powershell (switch back to main after merge)#[rstest]-fn test_merge_internal_powershell_directive(mut repo: TestRepo) {- repo.setup_remote("main");+fn test_merge_internal_powershell_directive(#[from(repo_with_remote)] mut repo: TestRepo) {repo.add_main_worktree();// Create a feature worktree and make a commit@@ -72,8 +70,7 @@ fn test_merge_internal_powershell_directive(mut repo: TestRepo) {/// on both platforms - this is purely a test snapshot compatibility issue.#[rstest]#[cfg_attr(windows, ignore)]-fn test_remove_internal_powershell_directive(mut repo: TestRepo) {- repo.setup_remote("main");+fn test_remove_internal_powershell_directive(#[from(repo_with_remote)] mut repo: TestRepo) {let feature_wt = repo.add_worktree("feature");let mut settings = setup_snapshot_settings(&repo);diff --git a/tests/integration_tests/e2e_shell.rs b/tests/integration_tests/e2e_shell.rsindex ffa5f8252..2b3a5e775 100644--- a/tests/integration_tests/e2e_shell.rs+++ b/tests/integration_tests/e2e_shell.rs@@ -2,7 +2,7 @@#![cfg(all(unix, feature = "shell-integration-tests"))]use crate::common::{- TestRepo,+ TestRepo, repo,shell::{execute_shell_script, generate_init_code, path_export_syntax, shell_available, wt_bin_dir,},@@ -24,9 +24,8 @@ macro_rules! skip_if_shell_unavailable {#[case("bash")]#[case("fish")]#[case("zsh")]-fn test_shell_integration_switch_and_remove(#[case] shell: &str) {+fn test_shell_integration_switch_and_remove(#[case] shell: &str, repo: TestRepo) {skip_if_shell_unavailable!(shell);- let repo = TestRepo::new();let init_code = generate_init_code(&repo, shell);let bin_path = wt_bin_dir();@@ -78,10 +77,9 @@ fn test_shell_integration_switch_and_remove(#[case] shell: &str) {);}-#[test]-fn test_bash_shell_integration_error_handling() {+#[rstest]+fn test_bash_shell_integration_error_handling(repo: TestRepo) {skip_if_shell_unavailable!("bash");- let repo = TestRepo::new();let init_code = generate_init_code(&repo, "bash");let bin_path = wt_bin_dir();@@ -119,10 +117,9 @@ fn test_bash_shell_integration_error_handling() {);}-#[test]-fn test_bash_shell_integration_switch_existing_worktree() {+#[rstest]+fn test_bash_shell_integration_switch_existing_worktree(repo: TestRepo) {skip_if_shell_unavailable!("bash");- let repo = TestRepo::new();let init_code = generate_init_code(&repo, "bash");let bin_path = wt_bin_dir();diff --git a/tests/integration_tests/e2e_shell_post_start.rs b/tests/integration_tests/e2e_shell_post_start.rsindex 96781c039..799bc8ef6 100644--- a/tests/integration_tests/e2e_shell_post_start.rs+++ b/tests/integration_tests/e2e_shell_post_start.rs@@ -2,7 +2,7 @@#![cfg(all(unix, feature = "shell-integration-tests"))]use crate::common::{- TestRepo, resolve_git_common_dir,+ TestRepo, repo, resolve_git_common_dir,shell::{execute_shell_script, generate_init_code, path_export_syntax, shell_available, wt_bin_dir,},@@ -27,9 +27,8 @@ macro_rules! skip_if_shell_unavailable {// Test with bash and fish#[case("bash")]#[case("fish")]-fn test_shell_integration_post_start_background(#[case] shell: &str) {+fn test_shell_integration_post_start_background(#[case] shell: &str, repo: TestRepo) {skip_if_shell_unavailable!(shell);- let repo = TestRepo::new();// Create project config with background commandlet config_dir = repo.root_path().join(".config");@@ -119,10 +118,8 @@ approved-commands = ["sleep 0.05 && echo 'Background task done' > bg_marker.txt"}/// Test that multiple post-start commands run in parallel with shell integration-#[test]-fn test_bash_shell_integration_post_start_parallel() {- let repo = TestRepo::new();-+#[rstest]+fn test_bash_shell_integration_post_start_parallel(repo: TestRepo) {// Create project config with multiple background commandslet config_dir = repo.root_path().join(".config");fs::create_dir_all(&config_dir).unwrap();@@ -191,10 +188,8 @@ approved-commands = [}/// Test that post-create commands block before shell returns-#[test]-fn test_bash_shell_integration_post_create_blocks() {- let repo = TestRepo::new();-+#[rstest]+fn test_bash_shell_integration_post_create_blocks(repo: TestRepo) {// Create project config with blocking commandlet config_dir = repo.root_path().join(".config");fs::create_dir_all(&config_dir).unwrap();@@ -262,10 +257,8 @@ approved-commands = ["echo 'Setup done' > setup.txt"]/// Test fish shell specifically with background tasks#[cfg(unix)]-#[test]-fn test_fish_shell_integration_post_start_background() {- let repo = TestRepo::new();-+#[rstest]+fn test_fish_shell_integration_post_start_background(repo: TestRepo) {// Create project config with background commandlet config_dir = repo.root_path().join(".config");fs::create_dir_all(&config_dir).unwrap();diff --git a/tests/integration_tests/for_each.rs b/tests/integration_tests/for_each.rsindex 92de8eea4..0deee8429 100644--- a/tests/integration_tests/for_each.rs+++ b/tests/integration_tests/for_each.rs@@ -1,7 +1,8 @@//! Integration tests for `wt step for-each`-use crate::common::{TestRepo, make_snapshot_cmd, setup_snapshot_settings};+use crate::common::{TestRepo, make_snapshot_cmd, repo, setup_snapshot_settings};use insta_cmd::assert_cmd_snapshot;+use rstest::rstest;/// Helper to create snapshot for for-each commandfn snapshot_for_each(test_name: &str, repo: &TestRepo, args: &[&str]) {@@ -12,17 +13,10 @@ fn snapshot_for_each(test_name: &str, repo: &TestRepo, args: &[&str]) {});}-/// Common setup for for-each tests - creates repo with initial commit-fn setup_repo() -> TestRepo {- let repo = TestRepo::new();- repo.commit("Initial commit");- repo-}--#[test]-fn test_for_each_single_worktree() {- let repo = setup_repo();-+/// Skipped on Windows: snapshot output differs due to shell/path differences.+#[cfg_attr(windows, ignore)]+#[rstest]+fn test_for_each_single_worktree(repo: TestRepo) {// Only main worktree existssnapshot_for_each("for_each_single_worktree",@@ -31,10 +25,10 @@ fn test_for_each_single_worktree() {);}-#[test]-fn test_for_each_multiple_worktrees() {- let mut repo = setup_repo();-+/// Skipped on Windows: snapshot output differs due to shell/path differences.+#[cfg_attr(windows, ignore)]+#[rstest]+fn test_for_each_multiple_worktrees(mut repo: TestRepo) {// Create additional worktreesrepo.add_worktree("feature-a");repo.add_worktree("feature-b");@@ -46,10 +40,10 @@ fn test_for_each_multiple_worktrees() {);}-#[test]-fn test_for_each_command_fails_in_one() {- let mut repo = setup_repo();-+/// Skipped on Windows: snapshot output differs due to shell/path differences.+#[cfg_attr(windows, ignore)]+#[rstest]+fn test_for_each_command_fails_in_one(mut repo: TestRepo) {repo.add_worktree("feature");// Use a command that will fail: try to show a non-existent ref@@ -60,18 +54,16 @@ fn test_for_each_command_fails_in_one() {);}-#[test]-fn test_for_each_no_args_error() {- let repo = setup_repo();-+#[rstest]+fn test_for_each_no_args_error(repo: TestRepo) {// Missing arguments should show errorsnapshot_for_each("for_each_no_args", &repo, &["for-each"]);}-#[test]-fn test_for_each_with_detached_head() {- let mut repo = setup_repo();-+/// Skipped on Windows: snapshot output differs due to shell/path differences.+#[cfg_attr(windows, ignore)]+#[rstest]+fn test_for_each_with_detached_head(mut repo: TestRepo) {// Create a worktree and detach its HEADrepo.add_worktree("detached-test");repo.detach_head_in_worktree("detached-test");@@ -83,10 +75,10 @@ fn test_for_each_with_detached_head() {);}-#[test]-fn test_for_each_with_template() {- let repo = setup_repo();-+/// Skipped on Windows: snapshot output differs due to shell/path differences.+#[cfg_attr(windows, ignore)]+#[rstest]+fn test_for_each_with_template(repo: TestRepo) {// Test template expansion with {{ branch }}snapshot_for_each("for_each_with_template",diff --git a/tests/integration_tests/hook_show.rs b/tests/integration_tests/hook_show.rsindex f2f623247..7d3a7a409 100644--- a/tests/integration_tests/hook_show.rs+++ b/tests/integration_tests/hook_show.rs@@ -1,16 +1,16 @@//! Integration tests for `wt hook show` command-use crate::common::{TestRepo, set_temp_home_env, setup_snapshot_settings_with_home, wt_command};+use crate::common::{+ TestRepo, repo, set_temp_home_env, setup_snapshot_settings_with_home, temp_home, wt_command,+};use insta_cmd::assert_cmd_snapshot;+use rstest::rstest;use std::fs;use tempfile::TempDir;/// Test `wt hook show` with both user and project hooks-#[test]-fn test_hook_show_with_both_configs() {- let repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+#[rstest]+fn test_hook_show_with_both_configs(repo: TestRepo, temp_home: TempDir) {// Create user config with hookslet global_config_dir = temp_home.path().join(".config").join("worktrunk");fs::create_dir_all(&global_config_dir).unwrap();@@ -48,11 +48,8 @@ test = "cargo test"}/// Test `wt hook show` with no hooks configured-#[test]-fn test_hook_show_no_hooks() {- let repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+#[rstest]+fn test_hook_show_no_hooks(repo: TestRepo, temp_home: TempDir) {// Create user config without hookslet global_config_dir = temp_home.path().join(".config").join("worktrunk");fs::create_dir_all(&global_config_dir).unwrap();@@ -75,11 +72,8 @@ fn test_hook_show_no_hooks() {}/// Test `wt hook show` filtering by hook type-#[test]-fn test_hook_show_filter_by_type() {- let repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+#[rstest]+fn test_hook_show_filter_by_type(repo: TestRepo, temp_home: TempDir) {// Create user config without hookslet global_config_dir = temp_home.path().join(".config").join("worktrunk");fs::create_dir_all(&global_config_dir).unwrap();@@ -120,11 +114,8 @@ deploy = "scripts/deploy.sh"}/// Test `wt hook show` shows approval status for project hooks-#[test]-fn test_hook_show_approval_status() {- let repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+#[rstest]+fn test_hook_show_approval_status(repo: TestRepo, temp_home: TempDir) {// Create user config at XDG path with one approved commandlet global_config_dir = temp_home.path().join(".config").join("worktrunk");fs::create_dir_all(&global_config_dir).unwrap();@@ -162,10 +153,9 @@ test = "cargo test"}/// Test `wt hook show` outside git repo-#[test]-fn test_hook_show_outside_git_repo() {+#[rstest]+fn test_hook_show_outside_git_repo(temp_home: TempDir) {let temp_dir = tempfile::tempdir().unwrap();- let temp_home = TempDir::new().unwrap();// Create user configlet global_config_dir = temp_home.path().join(".config").join("worktrunk");diff --git a/tests/integration_tests/init.rs b/tests/integration_tests/init.rsindex bcce511a9..b641b53f0 100644--- a/tests/integration_tests/init.rs+++ b/tests/integration_tests/init.rs@@ -5,15 +5,13 @@//! are not the primary shell integration path on Windows (PowerShell is).#![cfg(not(windows))]-use crate::common::{TestRepo, wt_command};+use crate::common::{TestRepo, repo, wt_command};use insta::Settings;use insta_cmd::assert_cmd_snapshot;use rstest::rstest;/// Helper to create snapshot for config shell init command-fn snapshot_init(test_name: &str, shell: &str, extra_args: &[&str]) {- let repo = TestRepo::new();-+fn snapshot_init(test_name: &str, repo: &TestRepo, shell: &str, extra_args: &[&str]) {// Custom settings for init tests - these output shell scripts with intentional// backslashes (\cd, \n) so we can't use setup_snapshot_settings which has a// backslash normalization filter that would corrupt the output@@ -43,14 +41,12 @@ fn snapshot_init(test_name: &str, shell: &str, extra_args: &[&str]) {#[case("bash")]#[case("fish")]#[case("zsh")]-fn test_init(#[case] shell: &str) {- snapshot_init(&format!("init_{}", shell), shell, &[]);+fn test_init(#[case] shell: &str, repo: TestRepo) {+ snapshot_init(&format!("init_{}", shell), &repo, shell, &[]);}-#[test]-fn test_init_invalid_shell() {- let repo = TestRepo::new();-+#[rstest]+fn test_init_invalid_shell(repo: TestRepo) {// Same custom settings as snapshot_initlet mut settings = Settings::clone_current();settings.set_snapshot_path("../snapshots");diff --git a/tests/integration_tests/internal_flag.rs b/tests/integration_tests/internal_flag.rsindex fb247895e..e2ad2b813 100644--- a/tests/integration_tests/internal_flag.rs+++ b/tests/integration_tests/internal_flag.rs@@ -6,10 +6,11 @@//! 3. The --internal flag can be safely passed to all commandsuse crate::common::{- TestRepo, set_temp_home_env, setup_snapshot_settings, setup_snapshot_settings_with_home,- wt_command,+ TestRepo, repo, set_temp_home_env, setup_snapshot_settings, setup_snapshot_settings_with_home,+ temp_home, wt_command,};use insta_cmd::assert_cmd_snapshot;+use rstest::rstest;use std::fs;use tempfile::TempDir;@@ -22,10 +23,8 @@ use tempfile::TempDir;/// Expected behavior:/// - stdout: empty (no directives emitted by list command)/// - stderr: complete table output with ANSI formatting-#[test]-fn test_list_with_internal_flag() {- let repo = TestRepo::new();-+#[rstest]+fn test_list_with_internal_flag(repo: TestRepo) {let settings = setup_snapshot_settings(&repo);settings.bind(|| {@@ -42,12 +41,9 @@ fn test_list_with_internal_flag() {/// Test that `config show` command works with --internal flag////// Config show doesn't emit directives, but should work fine with --internal.-#[test]+#[rstest]#[cfg_attr(windows, ignore = "mock gh/glab batch files not found on Windows")]-fn test_config_show_with_internal_flag() {- let mut repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+fn test_config_show_with_internal_flag(mut repo: TestRepo, temp_home: TempDir) {// Setup mock gh/glab for deterministic BINARIES outputrepo.setup_mock_ci_tools_unauthenticated();diff --git a/tests/integration_tests/list.rs b/tests/integration_tests/list.rsindex 06ca177ec..f6cc51554 100644--- a/tests/integration_tests/list.rs+++ b/tests/integration_tests/list.rs@@ -938,10 +938,8 @@ fn test_list_user_marker_with_special_characters(mut repo: TestRepo) {/// - `+33` main…± — Doc skeleton with structure/// - `⎇` branch without worktree///-/// Returns (repo, feature_api_path) for running commands from feature-api.-fn setup_readme_example_repo() -> (TestRepo, std::path::PathBuf) {- let mut repo = TestRepo::new();-+/// Returns feature_api_path for running commands from feature-api.+fn setup_readme_example_repo(repo: &mut TestRepo) -> std::path::PathBuf {// === Set up main branch with initial codebase ===// Main has a working API with security issues that fix-auth will hardenstd::fs::write(@@ -975,15 +973,15 @@ pub mod handlers {"#,).unwrap();- run_git(&repo, &["add", "api.rs"], repo.root_path());+ run_git(repo, &["add", "api.rs"], repo.root_path());repo.commit_staged_with_age("Initial API implementation", DAY, repo.root_path());repo.setup_remote("main");// Make main behind its remote: push a teammate's commit, then reset local// Story: A teammate pushed a hotfix while we were working on featuresrepo.commit_with_age("Fix production timeout issue", 2 * HOUR);- run_git(&repo, &["push", "origin", "main"], repo.root_path());- run_git(&repo, &["reset", "--hard", "HEAD~1"], repo.root_path());+ run_git(repo, &["push", "origin", "main"], repo.root_path());+ run_git(repo, &["reset", "--hard", "HEAD~1"], repo.root_path());// === Create fix-auth worktree ===// Story: Security audit found the token validation was too weak.@@ -1028,7 +1026,7 @@ pub mod handlers {"#,).unwrap();- run_git(&repo, &["add", "api.rs"], &fix_auth);+ run_git(repo, &["add", "api.rs"], &fix_auth);repo.commit_staged_with_age("Harden token validation", 6 * HOUR, &fix_auth);// Second commit: Add secure token storage@@ -1077,11 +1075,11 @@ pub mod handlers {"#,).unwrap();- run_git(&repo, &["add", "api.rs"], &fix_auth);+ run_git(repo, &["add", "api.rs"], &fix_auth);repo.commit_staged_with_age("Add secure token storage", 5 * HOUR, &fix_auth);// Push fix-auth and sync with remote- run_git(&repo, &["push", "-u", "origin", "fix-auth"], &fix_auth);+ run_git(repo, &["push", "-u", "origin", "fix-auth"], &fix_auth);// === Create feature-api worktree ===// Story: Major API refactoring - replacing the legacy handlers with a proper@@ -1210,13 +1208,9 @@ pub enum Method { Get, Post, Put, Delete }"#,).unwrap();- run_git(&repo, &["add", "api.rs", "routes.rs"], &feature_api);+ run_git(repo, &["add", "api.rs", "routes.rs"], &feature_api);repo.commit_staged_with_age("Refactor API to REST modules", 4 * HOUR, &feature_api);- run_git(- &repo,- &["push", "-u", "origin", "feature-api"],- &feature_api,- );+ run_git(repo, &["push", "-u", "origin", "feature-api"], &feature_api);// More commits (ahead of remote - unpushed local work)std::fs::write(@@ -1331,7 +1325,7 @@ pub enum AuthError { MissingToken, InvalidToken }"#,).unwrap();- run_git(&repo, &["add", "middleware.rs"], &feature_api);+ run_git(repo, &["add", "middleware.rs"], &feature_api);repo.commit_staged_with_age("Add request middleware", 3 * HOUR, &feature_api);std::fs::write(@@ -1346,7 +1340,7 @@ pub fn validate(body: &[u8], headers: &Headers) -> Result<(), Error> {"#,).unwrap();- run_git(&repo, &["add", "validation.rs"], &feature_api);+ run_git(repo, &["add", "validation.rs"], &feature_api);repo.commit_staged_with_age("Add request validation", 2 * HOUR, &feature_api);std::fs::write(@@ -1367,7 +1361,7 @@ mod tests {"#,).unwrap();- run_git(&repo, &["add", "tests.rs"], &feature_api);+ run_git(repo, &["add", "tests.rs"], &feature_api);repo.commit_staged_with_age("Add API tests", 30 * MINUTE, &feature_api);// Staged changes: new files + refactor existing (creates mixed +/- for HEAD±)@@ -1445,7 +1439,7 @@ fn validate_headers(h: &Headers) -> Result<(), ValidationError> {).unwrap();run_git(- &repo,+ repo,&["add", "cache.rs", "rate_limit.rs", "validation.rs"],&feature_api,);@@ -1458,7 +1452,7 @@ fn validate_headers(h: &Headers) -> Result<(), ValidationError> {// schema design and resolvers, but the team decided to stick with REST for now.let exp_wt = repo.root_path().parent().unwrap().join("temp-exp");run_git(- &repo,+ repo,&["worktree", "add", "-b", "exp", exp_wt.to_str().unwrap()],repo.root_path(),);@@ -1533,7 +1527,7 @@ pub struct PageInfo {"#,).unwrap();- run_git(&repo, &["add", "graphql.rs"], &exp_wt);+ run_git(repo, &["add", "graphql.rs"], &exp_wt);repo.commit_staged_with_age("Explore GraphQL schema design", 2 * DAY, &exp_wt);std::fs::write(@@ -1613,12 +1607,12 @@ impl SubscriptionRoot {"#,).unwrap();- run_git(&repo, &["add", "resolvers.rs"], &exp_wt);+ run_git(repo, &["add", "resolvers.rs"], &exp_wt);repo.commit_staged_with_age("Add GraphQL resolvers scaffold", 2 * DAY, &exp_wt);// Remove the worktree but keep the branchrun_git(- &repo,+ repo,&["worktree", "remove", exp_wt.to_str().unwrap()],repo.root_path(),);@@ -1643,7 +1637,7 @@ impl SubscriptionRoot {// Create wip from the earlier commit (before main advanced)let wip_wt = repo.root_path().parent().unwrap().join("temp-wip");run_git(- &repo,+ repo,&["worktree","add",@@ -1693,12 +1687,12 @@ TODO: Add request/response examples for each endpoint"#,).unwrap();- run_git(&repo, &["add", "API.md"], &wip_wt);+ run_git(repo, &["add", "API.md"], &wip_wt);repo.commit_staged_with_age("Start API documentation", 3 * DAY, &wip_wt);// Remove the worktree but keep the branchrun_git(- &repo,+ repo,&["worktree", "remove", wip_wt.to_str().unwrap()],repo.root_path(),);@@ -1706,12 +1700,12 @@ TODO: Add request/response examples for each endpoint// === Mock CI status ===// CI requires --full flag, but we mock it so examples show realistic output// Note: main's CI is mocked AFTER the merge commit so the hash matches- mock_ci_status(&repo, "main", "passed", "pullrequest", false);- mock_ci_status(&repo, "fix-auth", "passed", "pullrequest", false);+ mock_ci_status(repo, "main", "passed", "pullrequest", false);+ mock_ci_status(repo, "fix-auth", "passed", "pullrequest", false);// feature-api has unpushed commits, so CI is stale (shows dimmed)- mock_ci_status(&repo, "feature-api", "running", "pullrequest", true);+ mock_ci_status(repo, "feature-api", "running", "pullrequest", true);- (repo, feature_api)+ feature_api}/// Helper to run git commands@@ -1779,8 +1773,8 @@ fn mock_ci_status(repo: &TestRepo, branch: &str, status: &str, source: &str, is_/// Uses narrower width (100 cols) to fit in doc site code blocks./// Output: tests/snapshots/integration__integration_tests__list__readme_example_list.snap#[rstest]-fn test_readme_example_list() {- let (repo, feature_api) = setup_readme_example_repo();+fn test_readme_example_list(mut repo: TestRepo) {+ let feature_api = setup_readme_example_repo(&mut repo);snapshot_readme_list_from_dir("readme_example_list", &repo, &feature_api);}@@ -1790,8 +1784,8 @@ fn test_readme_example_list() {/// Uses narrower width (100 cols) to fit in doc site code blocks./// Output: tests/snapshots/integration__integration_tests__list__readme_example_list_full.snap#[rstest]-fn test_readme_example_list_full() {- let (repo, feature_api) = setup_readme_example_repo();+fn test_readme_example_list_full(mut repo: TestRepo) {+ let feature_api = setup_readme_example_repo(&mut repo);snapshot_readme_list_full_from_dir("readme_example_list_full", &repo, &feature_api);}@@ -1801,8 +1795,8 @@ fn test_readme_example_list_full() {/// Uses narrower width (100 cols) to fit in doc site code blocks./// Output: tests/snapshots/integration__integration_tests__list__readme_example_list_branches.snap#[rstest]-fn test_readme_example_list_branches() {- let (repo, feature_api) = setup_readme_example_repo();+fn test_readme_example_list_branches(mut repo: TestRepo) {+ let feature_api = setup_readme_example_repo(&mut repo);snapshot_readme_list_branches_full_from_dir("readme_example_list_branches",&repo,diff --git a/tests/integration_tests/list_column_alignment.rs b/tests/integration_tests/list_column_alignment.rsindex e2c206cd0..99eea70ce 100644--- a/tests/integration_tests/list_column_alignment.rs+++ b/tests/integration_tests/list_column_alignment.rs@@ -3,14 +3,13 @@//! These tests ensure that column headers align with their data,//! and that progressive rendering maintains consistent alignment.-use crate::common::{TestRepo, make_snapshot_cmd, setup_snapshot_settings};+use crate::common::{TestRepo, make_snapshot_cmd, repo, setup_snapshot_settings};use insta_cmd::assert_cmd_snapshot;+use rstest::rstest;/// Test that Status column data aligns with Status header-#[test]-fn test_status_column_alignment_with_header() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_status_column_alignment_with_header(mut repo: TestRepo) {// Create worktree with status symbolslet wt = repo.add_worktree("test");std::fs::write(wt.join("file.txt"), "content").unwrap();@@ -39,10 +38,8 @@ fn test_status_column_alignment_with_header() {}/// Test that Status column width is consistent across all rows-#[test]-fn test_status_column_width_consistency() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_status_column_width_consistency(mut repo: TestRepo) {// Create multiple worktrees with different status symbol combinationslet wt1 = repo.add_worktree("simple");std::fs::write(wt1.join("file.txt"), "content").unwrap();diff --git a/tests/integration_tests/list_config.rs b/tests/integration_tests/list_config.rsindex 4cfef6ea6..8c921350e 100644--- a/tests/integration_tests/list_config.rs+++ b/tests/integration_tests/list_config.rs@@ -1,16 +1,16 @@//! Tests for `wt list` command with user config-use crate::common::{TestRepo, set_temp_home_env, setup_snapshot_settings_with_home, wt_command};+use crate::common::{+ TestRepo, repo, set_temp_home_env, setup_snapshot_settings_with_home, temp_home, wt_command,+};use insta_cmd::assert_cmd_snapshot;+use rstest::rstest;use std::fs;use tempfile::TempDir;/// Test `wt list` with config setting full = true-#[test]-fn test_list_config_full_enabled() {- let repo = TestRepo::new();- let temp_home = TempDir::new().unwrap();-+#[rstest]+fn test_list_config_full_enabled(repo: TestRepo, temp_home: TempDir) {// Create user config with list.full = truelet global_config_dir = temp_home.path().join(".config").join("worktrunk");fs::create_dir_all(&global_config_dir).unwrap();@@ -36,10 +36,8 @@ full = true}/// Test `wt list` with config setting branches = true-#[test]-fn test_list_config_branches_enabled() {- let repo = TestRepo::new();-+#[rstest]+fn test_list_config_branches_enabled(repo: TestRepo, temp_home: TempDir) {// Create a branch without a worktreelet mut cmd = std::process::Command::new("git");repo.configure_git_cmd(&mut cmd);@@ -48,8 +46,6 @@ fn test_list_config_branches_enabled() {.output().unwrap();- let temp_home = TempDir::new().unwrap();-// Create user config with list.branches = truelet global_config_dir = temp_home.path().join(".config").join("worktrunk");fs::create_dir_all(&global_config_dir).unwrap();@@ -75,10 +71,8 @@ branches = true}/// Test that CLI flags override config settings-#[test]-fn test_list_config_cli_override() {- let repo = TestRepo::new();-+#[rstest]+fn test_list_config_cli_override(repo: TestRepo, temp_home: TempDir) {// Create a branch without a worktreelet mut cmd = std::process::Command::new("git");repo.configure_git_cmd(&mut cmd);@@ -87,8 +81,6 @@ fn test_list_config_cli_override() {.output().unwrap();- let temp_home = TempDir::new().unwrap();-// Create user config with list.branches = false (default)let global_config_dir = temp_home.path().join(".config").join("worktrunk");fs::create_dir_all(&global_config_dir).unwrap();@@ -117,10 +109,8 @@ branches = false}/// Test `wt list` with both full and branches config enabled-#[test]-fn test_list_config_full_and_branches() {- let repo = TestRepo::new();-+#[rstest]+fn test_list_config_full_and_branches(repo: TestRepo, temp_home: TempDir) {// Create a branch without a worktreelet mut cmd = std::process::Command::new("git");repo.configure_git_cmd(&mut cmd);@@ -129,8 +119,6 @@ fn test_list_config_full_and_branches() {.output().unwrap();- let temp_home = TempDir::new().unwrap();-// Create user config with both full and branches enabledlet global_config_dir = temp_home.path().join(".config").join("worktrunk");fs::create_dir_all(&global_config_dir).unwrap();@@ -157,10 +145,8 @@ branches = true}/// Test `wt list` without config (default behavior)-#[test]-fn test_list_no_config() {- let repo = TestRepo::new();-+#[rstest]+fn test_list_no_config(repo: TestRepo, temp_home: TempDir) {// Create a branch without a worktreelet mut cmd = std::process::Command::new("git");repo.configure_git_cmd(&mut cmd);@@ -169,8 +155,6 @@ fn test_list_no_config() {.output().unwrap();- let temp_home = TempDir::new().unwrap();-// Create minimal user config without list settingslet global_config_dir = temp_home.path().join(".config").join("worktrunk");fs::create_dir_all(&global_config_dir).unwrap();diff --git a/tests/integration_tests/list_progressive.rs b/tests/integration_tests/list_progressive.rsindex 5da940fc7..310778f99 100644--- a/tests/integration_tests/list_progressive.rs+++ b/tests/integration_tests/list_progressive.rs@@ -4,13 +4,12 @@//! verifying that the table structure appears first and data fills in progressively.#![cfg(unix)]-use crate::common::TestRepo;use crate::common::progressive_output::{ProgressiveCaptureOptions, capture_progressive_output};+use crate::common::{TestRepo, repo};+use rstest::rstest;-#[test]-fn test_list_progressive_rendering_basic() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_list_progressive_rendering_basic(mut repo: TestRepo) {// Create a few worktrees to have data to renderrepo.add_worktree("feature-a");repo.add_worktree("feature-b");@@ -55,10 +54,8 @@ fn test_list_progressive_rendering_basic() {// No need for additional assertions - verify_progressive_filling already confirms progressive behavior}-#[test]-fn test_list_progressive_dots_decrease() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_list_progressive_dots_decrease(mut repo: TestRepo) {// Create multiple worktrees to ensure progressive rendering is observablefor i in 1..=5 {repo.add_worktree(&format!("branch-{}", i));@@ -75,9 +72,8 @@ fn test_list_progressive_dots_decrease() {output.verify_progressive_filling().unwrap();}-#[test]-fn test_list_progressive_timing() {- let mut repo = TestRepo::new();+#[rstest]+fn test_list_progressive_timing(mut repo: TestRepo) {repo.add_worktree("feature");let output = capture_progressive_output(@@ -103,9 +99,8 @@ fn test_list_progressive_timing() {);}-#[test]-fn test_list_progressive_snapshot_at() {- let mut repo = TestRepo::new();+#[rstest]+fn test_list_progressive_snapshot_at(mut repo: TestRepo) {repo.add_worktree("feature");let output = capture_progressive_output(@@ -132,10 +127,8 @@ fn test_list_progressive_snapshot_at() {}/// Test with a larger dataset to ensure progressive rendering is visible-#[test]-fn test_list_progressive_many_worktrees() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_list_progressive_many_worktrees(mut repo: TestRepo) {// Create many worktrees to ensure rendering takes timefor i in 1..=10 {repo.add_worktree(&format!("branch-{:02}", i));@@ -177,10 +170,8 @@ fn test_list_progressive_many_worktrees() {}/// Test that we can capture output even for fast commands-#[test]-fn test_list_progressive_fast_command() {- let repo = TestRepo::new();-+#[rstest]+fn test_list_progressive_fast_command(repo: TestRepo) {// Run list without any worktrees (fast)let output = capture_progressive_output(&repo,diff --git a/tests/integration_tests/post_start_commands.rs b/tests/integration_tests/post_start_commands.rsindex 341a3f2f0..c8e0ea119 100644--- a/tests/integration_tests/post_start_commands.rs+++ b/tests/integration_tests/post_start_commands.rs@@ -1,7 +1,7 @@use crate::common::{- TestRepo, make_snapshot_cmd, repo, resolve_git_common_dir, setup_snapshot_settings,- wait_for_file, wait_for_file_content, wait_for_file_count, wait_for_file_lines,- wait_for_valid_json,+ TestRepo, make_snapshot_cmd, repo, repo_with_remote, resolve_git_common_dir,+ setup_snapshot_settings, wait_for_file, wait_for_file_content, wait_for_file_count,+ wait_for_file_lines, wait_for_valid_json,};use insta::assert_snapshot;use insta_cmd::assert_cmd_snapshot;@@ -243,9 +243,7 @@ approved-commands = ["echo 'Default: {{ default_branch }}' > default.txt"]/// Skipped on Windows: snapshot output differs due to shell/path differences.#[cfg_attr(windows, ignore)]#[rstest]-fn test_post_create_git_variables_template(mut repo: TestRepo) {- repo.setup_remote("main");-+fn test_post_create_git_variables_template(#[from(repo_with_remote)] repo: TestRepo) {// Set up an upstream tracking branchrepo.git_command(&["push", "-u", "origin", "main"]).output()@@ -319,9 +317,7 @@ worktree_name = "echo 'Worktree Name: {{ worktree_name }}' >> git_vars.txt"/// Skipped on Windows: snapshot output differs due to shell/path differences.#[cfg_attr(windows, ignore)]#[rstest]-fn test_post_create_upstream_template(mut repo: TestRepo) {- repo.setup_remote("main");-+fn test_post_create_upstream_template(#[from(repo_with_remote)] repo: TestRepo) {// Push main to set up trackingrepo.git_command(&["push", "-u", "origin", "main"]).output()diff --git a/tests/integration_tests/security.rs b/tests/integration_tests/security.rsindex a97d58a26..359268c2e 100644--- a/tests/integration_tests/security.rs+++ b/tests/integration_tests/security.rs@@ -96,21 +96,20 @@//! For comprehensive security testing, see `tests/integration_tests/shell_wrapper.rs` which//! tests the full shell integration pipeline.-use crate::common::{TestRepo, setup_snapshot_settings, wt_command};+use crate::common::{TestRepo, repo, setup_snapshot_settings, wt_command};use insta::Settings;use insta_cmd::assert_cmd_snapshot;+use rstest::rstest;use std::process::Command;/// Test that Git rejects NUL bytes in commit messages////// Git provides the first line of defense by refusing to create commits/// with NUL bytes in the message.-#[test]-fn test_git_rejects_nul_in_commit_messages() {+#[rstest]+fn test_git_rejects_nul_in_commit_messages(repo: TestRepo) {use std::process::Stdio;- let repo = TestRepo::new();-// Try to create a commit with NUL in the message// We can't use Command::arg() because Rust rejects NUL bytes,// so we use printf piped to git commit -F -@@ -160,10 +159,8 @@ fn test_git_rejects_nul_in_commit_messages() {////// This verifies that the OS/Rust provides protection against NUL injection./// Rust's Command API uses C strings internally, which reject NUL bytes.-#[test]-fn test_rust_prevents_nul_bytes_in_args() {- let repo = TestRepo::new();-+#[rstest]+fn test_rust_prevents_nul_bytes_in_args(repo: TestRepo) {// Rust's Command API should reject NUL bytes in argumentslet malicious_branch = "feature\0__WORKTRUNK_EXEC__echo PWNED";@@ -197,10 +194,8 @@ fn test_rust_prevents_nul_bytes_in_args() {/// Test that branch names that ARE directives themselves don't get executed////// This tests the case where the entire branch name is a directive-#[test]-fn test_branch_name_is_directive_not_executed() {- let repo = TestRepo::new();-+#[rstest]+fn test_branch_name_is_directive_not_executed(repo: TestRepo) {let malicious_branch = "__WORKTRUNK_EXEC__echo PWNED > /tmp/hacked2";// Try to create this branch@@ -239,10 +234,8 @@ fn test_branch_name_is_directive_not_executed() {}/// Test that branch names with newline + directive are not executed-#[test]-fn test_branch_name_with_newline_directive_not_executed() {- let repo = TestRepo::new();-+#[rstest]+fn test_branch_name_with_newline_directive_not_executed(repo: TestRepo) {let malicious_branch = "feature\n__WORKTRUNK_EXEC__echo PWNED > /tmp/hacked3";let mut cmd = Command::new("git");@@ -280,12 +273,8 @@ fn test_branch_name_with_newline_directive_not_executed() {/// Test that commit messages with directives in list output don't get executed////// This tests if commit messages shown in output (e.g., wt list, logs) could inject directives-#[test]-fn test_commit_message_with_directive_not_executed() {- use crate::common::setup_snapshot_settings;-- let mut repo = TestRepo::new();-+#[rstest]+fn test_commit_message_with_directive_not_executed(mut repo: TestRepo) {// Create commit with malicious message (no NUL - Rust prevents those)let malicious_message = "Fix bug\n__WORKTRUNK_EXEC__echo PWNED > /tmp/hacked4";repo.commit_with_message(malicious_message);@@ -318,12 +307,8 @@ fn test_commit_message_with_directive_not_executed() {////// This tests if file paths shown in output could inject directives#[cfg(unix)]-#[test]-fn test_path_with_directive_not_executed() {- use crate::common::setup_snapshot_settings;-- let repo = TestRepo::new();-+#[rstest]+fn test_path_with_directive_not_executed(repo: TestRepo) {// Create a directory with a malicious namelet malicious_dir = repo.root_path()@@ -350,10 +335,8 @@ fn test_path_with_directive_not_executed() {/// Test that CD directive in branch names is not treated as a directive////// Similar to EXEC injection, but for CD directives-#[test]-fn test_branch_name_with_cd_directive_not_executed() {- let repo = TestRepo::new();-+#[rstest]+fn test_branch_name_with_cd_directive_not_executed(repo: TestRepo) {// Branch name that IS a CD directive (no NUL - git allows this)let malicious_branch = "__WORKTRUNK_CD__/tmp";@@ -388,10 +371,8 @@ fn test_branch_name_with_cd_directive_not_executed() {/// Test that error messages cannot inject directives////// This tests if error messages (e.g., from git) could inject directives-#[test]-fn test_error_message_with_directive_not_executed() {- let repo = TestRepo::new();-+#[rstest]+fn test_error_message_with_directive_not_executed(repo: TestRepo) {// Try to switch to a non-existent branch with a name that looks like a directivelet malicious_branch = "__WORKTRUNK_EXEC__echo PWNED > /tmp/hacked6";@@ -420,10 +401,8 @@ fn test_error_message_with_directive_not_executed() {/// The -x flag is SUPPOSED to execute commands, so this tests that:/// 1. Commands from -x are emitted as shell script to stdout/// 2. User content in branch names that looks like old directives doesn't cause injection-#[test]-fn test_execute_flag_with_directive_like_branch_name() {- let repo = TestRepo::new();-+#[rstest]+fn test_execute_flag_with_directive_like_branch_name(repo: TestRepo) {// Branch name that looks like a directivelet malicious_branch = "__WORKTRUNK_EXEC__echo PWNED > /tmp/hacked7";diff --git a/tests/integration_tests/select.rs b/tests/integration_tests/select.rsindex 2667c1633..9b4e905d5 100644--- a/tests/integration_tests/select.rs+++ b/tests/integration_tests/select.rs@@ -19,10 +19,11 @@//! - **Stabilization detection** waits for screen to stop changing//! - **Content expectations** wait for async preview content to load (e.g., "diff --git")-use crate::common::TestRepo;+use crate::common::{TestRepo, repo};use insta::assert_snapshot;use insta_cmd::get_cargo_bin;use portable_pty::{CommandBuilder, PtySize};+use rstest::rstest;use std::io::{Read, Write};use std::path::Path;use std::sync::mpsc;@@ -340,11 +341,8 @@ fn normalize_output(output: &str) -> String {}}-#[test]--fn test_select_abort_with_escape() {- let repo = TestRepo::new();-+#[rstest]+fn test_select_abort_with_escape(repo: TestRepo) {let env_vars = repo.test_env_vars();let (raw_output, exit_code) = exec_in_pty_with_input(get_cargo_bin("wt").to_str().unwrap(),@@ -361,10 +359,8 @@ fn test_select_abort_with_escape() {assert_snapshot!("select_abort_escape", normalized);}-#[test]--fn test_select_with_multiple_worktrees() {- let mut repo = TestRepo::new();+#[rstest]+fn test_select_with_multiple_worktrees(mut repo: TestRepo) {repo.add_worktree("feature-one");repo.add_worktree("feature-two");@@ -384,10 +380,8 @@ fn test_select_with_multiple_worktrees() {assert_snapshot!("select_multiple_worktrees", normalized);}-#[test]--fn test_select_with_branches() {- let mut repo = TestRepo::new();+#[rstest]+fn test_select_with_branches(mut repo: TestRepo) {repo.add_worktree("active-worktree");// Create a branch without a worktreelet output = repo@@ -413,10 +407,8 @@ fn test_select_with_branches() {}/// Test preview panel 1: HEAD± shows uncommitted changes-#[test]--fn test_select_preview_panel_uncommitted() {- let mut repo = TestRepo::new();+#[rstest]+fn test_select_preview_panel_uncommitted(mut repo: TestRepo) {let feature_path = repo.add_worktree("feature");// First, create and commit a file so we have something to modify@@ -468,10 +460,8 @@ fn test_select_preview_panel_uncommitted() {}/// Test preview panel 2: log shows recent commits-#[test]--fn test_select_preview_panel_log() {- let mut repo = TestRepo::new();+#[rstest]+fn test_select_preview_panel_log(mut repo: TestRepo) {let feature_path = repo.add_worktree("feature");// Make several commits in the feature worktree@@ -522,10 +512,8 @@ fn test_select_preview_panel_log() {}/// Test preview panel 3: main…± shows diff vs main branch-#[test]--fn test_select_preview_panel_main_diff() {- let mut repo = TestRepo::new();+#[rstest]+fn test_select_preview_panel_main_diff(mut repo: TestRepo) {let feature_path = repo.add_worktree("feature");// Make commits in the feature worktree that differ from maindiff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rsindex 7c3cc7775..82474a5d5 100644--- a/tests/integration_tests/shell_wrapper.rs+++ b/tests/integration_tests/shell_wrapper.rs@@ -700,9 +700,8 @@ mod tests {#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_wrapper_handles_command_failure(#[case] shell: &str) {+ fn test_wrapper_handles_command_failure(#[case] shell: &str, mut repo: TestRepo) {skip_if_shell_unavailable!(shell);- let mut repo = TestRepo::new();// Create a worktree that already existsrepo.add_worktree("existing");@@ -734,9 +733,8 @@ mod tests {#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_wrapper_switch_create(#[case] shell: &str) {+ fn test_wrapper_switch_create(#[case] shell: &str, repo: TestRepo) {skip_if_shell_unavailable!(shell);- let repo = TestRepo::new();let output = exec_through_wrapper(shell, &repo, "switch", &["--create", "feature"]);@@ -761,9 +759,8 @@ mod tests {#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_wrapper_remove(#[case] shell: &str) {+ fn test_wrapper_remove(#[case] shell: &str, mut repo: TestRepo) {skip_if_shell_unavailable!(shell);- let mut repo = TestRepo::new();// Create a worktree to removerepo.add_worktree("to-remove");@@ -784,9 +781,8 @@ mod tests {#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_wrapper_step_for_each(#[case] shell: &str) {+ fn test_wrapper_step_for_each(#[case] shell: &str, mut repo: TestRepo) {skip_if_shell_unavailable!(shell);- let mut repo = TestRepo::new();repo.commit("Initial commit");// Create additional worktrees@@ -844,9 +840,8 @@ mod tests {#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_wrapper_merge(#[case] shell: &str) {+ fn test_wrapper_merge(#[case] shell: &str, mut repo: TestRepo) {skip_if_shell_unavailable!(shell);- let mut repo = TestRepo::new();// Create a feature branchrepo.add_worktree("feature");@@ -867,9 +862,8 @@ mod tests {#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_wrapper_switch_with_execute(#[case] shell: &str) {+ fn test_wrapper_switch_with_execute(#[case] shell: &str, repo: TestRepo) {skip_if_shell_unavailable!(shell);- let repo = TestRepo::new();// Use --force to skip approval prompt in testslet output = exec_through_wrapper(@@ -908,9 +902,8 @@ mod tests {#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_wrapper_execute_exit_code_propagation(#[case] shell: &str) {+ fn test_wrapper_execute_exit_code_propagation(#[case] shell: &str, repo: TestRepo) {skip_if_shell_unavailable!(shell);- let repo = TestRepo::new();// Use --force to skip approval prompt in tests// wt should succeed (creates worktree), but the execute command should fail with exit 42@@ -953,9 +946,8 @@ mod tests {// #[case("bash")] // TODO: Flaky PTY output ordering - command output appears before command display#[case("zsh")]// #[case("fish")] // TODO: Fish shell has non-deterministic PTY output ordering- fn test_wrapper_switch_with_hooks(#[case] shell: &str) {+ fn test_wrapper_switch_with_hooks(#[case] shell: &str, repo: TestRepo) {skip_if_shell_unavailable!(shell);- let repo = TestRepo::new();// Create project config with both post-create and post-start hookslet config_dir = repo.root_path().join(".config");@@ -1213,10 +1205,8 @@ approved-commands = [// Bash Shell Wrapper Tests// ========================================================================- #[test]- fn test_switch_with_post_start_command_no_directive_leak() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_switch_with_post_start_command_no_directive_leak(repo: TestRepo) {// Configure a post-start command in the project config (this is where the bug manifests)// The println! in handle_post_start_commands causes directive leakslet config_dir = repo.root_path().join(".config");@@ -1256,10 +1246,8 @@ approved-commands = ["echo 'test command executed'"]assert_snapshot!(output.normalized());}- #[test]- fn test_switch_with_execute_through_wrapper() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_switch_with_execute_through_wrapper(repo: TestRepo) {// Use --force to skip approval prompt in testslet output = exec_through_wrapper("bash",@@ -1290,10 +1278,8 @@ approved-commands = ["echo 'test command executed'"]assert_snapshot!(output.normalized());}- #[test]- fn test_bash_shell_integration_hint_suppressed() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_bash_shell_integration_hint_suppressed(repo: TestRepo) {// When running through the shell wrapper, the "To enable automatic cd" hint// should NOT appear because the user already has shell integrationlet output = exec_through_wrapper("bash", &repo, "switch", &["--create", "bash-test"]);@@ -1314,10 +1300,8 @@ approved-commands = ["echo 'test command executed'"]assert_snapshot!(output.normalized());}- #[test]- fn test_readme_example_simple_switch() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_readme_example_simple_switch(repo: TestRepo) {// Create worktree through shell wrapper (suppresses hint)let output = exec_through_wrapper("bash", &repo, "switch", &["--create", "fix-auth"]);@@ -1329,10 +1313,8 @@ approved-commands = ["echo 'test command executed'"]assert_snapshot!(output.normalized());}- #[test]- fn test_readme_example_switch_back() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_readme_example_switch_back(repo: TestRepo) {// Create worktrees (fix-auth is where we are after step 2, feature-api exists from earlier)exec_through_wrapper("bash", &repo, "switch", &["--create", "fix-auth"]);// Create feature-api from main (simulating it already existed)@@ -1351,10 +1333,8 @@ approved-commands = ["echo 'test command executed'"]assert_snapshot!(output.normalized());}- #[test]- fn test_readme_example_remove() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_readme_example_remove(repo: TestRepo) {// Create worktreesexec_through_wrapper("bash", &repo, "switch", &["--create", "fix-auth"]);exec_through_wrapper("bash", &repo, "switch", &["--create", "feature-api"]);@@ -1371,10 +1351,8 @@ approved-commands = ["echo 'test command executed'"]assert_snapshot!(output.normalized());}- #[test]- fn test_wrapper_preserves_progress_messages() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_wrapper_preserves_progress_messages(repo: TestRepo) {// Configure a post-start background command that will trigger progress outputlet config_dir = repo.root_path().join(".config");fs::create_dir_all(&config_dir).unwrap();@@ -1438,10 +1416,8 @@ approved-commands = ["echo 'background task'"]// a single string before eval (fish splits on newlines by default).#[cfg(unix)]- #[test]- fn test_fish_wrapper_preserves_progress_messages() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_fish_wrapper_preserves_progress_messages(repo: TestRepo) {// Configure a post-start background command that will trigger progress outputlet config_dir = repo.root_path().join(".config");fs::create_dir_all(&config_dir).unwrap();@@ -1489,10 +1465,8 @@ approved-commands = ["echo 'fish background task'"]}#[cfg(unix)]- #[test]- fn test_fish_multiline_command_execution() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_fish_multiline_command_execution(repo: TestRepo) {// Test that Fish wrapper handles multi-line commands correctly// This tests Fish's NUL-byte parsing with embedded newlines// Use actual newlines in the command string@@ -1527,10 +1501,8 @@ approved-commands = ["echo 'fish background task'"]}#[cfg(unix)]- #[test]- fn test_fish_wrapper_handles_empty_chunks() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_fish_wrapper_handles_empty_chunks(repo: TestRepo) {// Test edge case: command that produces minimal output// This verifies Fish's `test -n "$chunk"` check works correctlylet output = exec_through_wrapper("fish", &repo, "switch", &["--create", "fish-minimal"]);@@ -1562,11 +1534,9 @@ approved-commands = ["echo 'fish background task'"]#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_source_flag_forwards_errors(#[case] shell: &str) {+ fn test_source_flag_forwards_errors(#[case] shell: &str, repo: TestRepo) {use std::env;- let repo = TestRepo::new();-// Get the worktrunk source directory (where this test is running from)// This is the directory that contains Cargo.toml with the workspacelet worktrunk_source = env::current_dir().unwrap().canonicalize().unwrap();@@ -1672,10 +1642,8 @@ approved-commands = ["echo 'fish background task'"]/// Test that zsh doesn't show job control notifications inline/// The NO_MONITOR option should suppress [1] 12345 and [1] + done messages- #[test]- fn test_zsh_no_job_control_notifications() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_zsh_no_job_control_notifications(repo: TestRepo) {// Configure a post-start command that will trigger background joblet config_dir = repo.root_path().join(".config");fs::create_dir_all(&config_dir).unwrap();@@ -1726,10 +1694,8 @@ approved-commands = ["echo 'background job'"]/// The shell wrapper suppresses these via two mechanisms (see posix_directives.sh):/// - START notifications (`[1] 12345`): stderr redirection around `&`/// - DONE notifications (`[1]+ Done`): `set +m` before backgrounding- #[test]- fn test_bash_job_control_suppression() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_bash_job_control_suppression(repo: TestRepo) {// Configure a post-start command that will trigger background joblet config_dir = repo.root_path().join(".config");fs::create_dir_all(&config_dir).unwrap();@@ -1810,10 +1776,8 @@ approved-commands = ["echo 'bash background'"]/// Test that bash completions are properly registered/// Note: Completions are inline in the wrapper script (lazy loading)- #[test]- fn test_bash_completions_registered() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_bash_completions_registered(repo: TestRepo) {let wt_bin = get_cargo_bin("wt");let wrapper_script = generate_wrapper(&repo, "bash");@@ -1849,10 +1813,8 @@ approved-commands = ["echo 'bash background'"]}/// Test that fish completions are properly registered- #[test]- fn test_fish_completions_registered() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_fish_completions_registered(repo: TestRepo) {let wt_bin = get_cargo_bin("wt");let wrapper_script = generate_wrapper(&repo, "fish");let completions_script = generate_completions(&repo, "fish");@@ -1894,10 +1856,8 @@ approved-commands = ["echo 'bash background'"]/// Test that zsh wrapper function is properly defined/// Note: Completions are inline in the wrapper script (lazy loading via compdef)- #[test]- fn test_zsh_wrapper_function_registered() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_zsh_wrapper_function_registered(repo: TestRepo) {let wt_bin = get_cargo_bin("wt");let wrapper_script = generate_wrapper(&repo, "zsh");@@ -1947,9 +1907,7 @@ approved-commands = ["echo 'bash background'"]#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_branch_name_with_slashes(#[case] shell: &str) {- let repo = TestRepo::new();-+ fn test_branch_name_with_slashes(#[case] shell: &str, repo: TestRepo) {// Branch name with slashes (common git convention)let output =exec_through_wrapper(shell, &repo, "switch", &["--create", "feature/test-branch"]);@@ -1969,9 +1927,7 @@ approved-commands = ["echo 'bash background'"]#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_branch_name_with_dashes_underscores(#[case] shell: &str) {- let repo = TestRepo::new();-+ fn test_branch_name_with_dashes_underscores(#[case] shell: &str, repo: TestRepo) {let output = exec_through_wrapper(shell, &repo, "switch", &["--create", "fix-bug_123"]);assert_eq!(output.exit_code, 0, "{}: Command should succeed", shell);@@ -1993,9 +1949,7 @@ approved-commands = ["echo 'bash background'"]#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_worktrunk_bin_fallback(#[case] shell: &str) {- let repo = TestRepo::new();-+ fn test_worktrunk_bin_fallback(#[case] shell: &str, repo: TestRepo) {let wt_bin = get_cargo_bin("wt");let wrapper_script = generate_wrapper(&repo, shell);@@ -2104,9 +2058,7 @@ approved-commands = ["echo 'bash background'"]#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_shell_completes_cleanly(#[case] shell: &str) {- let repo = TestRepo::new();-+ fn test_shell_completes_cleanly(#[case] shell: &str, repo: TestRepo) {// Configure a post-start command to exercise the background job code pathlet config_dir = repo.root_path().join(".config");fs::create_dir_all(&config_dir).unwrap();@@ -2426,10 +2378,8 @@ command = "{}"/// Uses shell wrapper to avoid "To enable automatic cd" hint.////// Source: tests/snapshots/shell_wrapper__tests__readme_example_hooks_post_create.snap- #[test]- fn test_readme_example_hooks_post_create() {- let repo = TestRepo::new();-+ #[rstest]+ fn test_readme_example_hooks_post_create(repo: TestRepo) {// Create project config with post-create and post-start hookslet config_dir = repo.root_path().join(".config");fs::create_dir_all(&config_dir).unwrap();@@ -2516,13 +2466,11 @@ fi/// Note: This uses direct PTY execution (not shell wrapper) because interactive prompts/// require direct stdin access. The shell wrapper approach detects non-interactive mode./// The shell integration hint is truncated from the output.- #[test]- fn test_readme_example_approval_prompt() {+ #[rstest]+ fn test_readme_example_approval_prompt(repo: TestRepo) {use portable_pty::{CommandBuilder, PtySize};use std::io::{Read, Write};- let repo = TestRepo::new();-// Create project config with named post-create commandsrepo.write_project_config(r#"[post-create]@@ -2631,13 +2579,11 @@ test = "echo 'Running tests...'"/// - Completion not registered at all/// - Completion function not loading (lazy loading broken)/// - Completion output being executed as commands (the COMPLETE mode bug)- #[test]- fn test_bash_completion_produces_correct_output() {+ #[rstest]+ fn test_bash_completion_produces_correct_output(repo: TestRepo) {use portable_pty::{CommandBuilder, PtySize};use std::io::Read;- let repo = TestRepo::new();-let wt_bin = get_cargo_bin("wt");let wt_bin_dir = wt_bin.parent().unwrap();@@ -2795,13 +2741,11 @@ fi/// This test verifies completion works WITHOUT knowing internal function names./// It checks that a completion is registered for 'wt' and that calling the/// wt command with COMPLETE=zsh produces completion candidates.- #[test]- fn test_zsh_completion_produces_correct_output() {+ #[rstest]+ fn test_zsh_completion_produces_correct_output(repo: TestRepo) {use portable_pty::{CommandBuilder, PtySize};use std::io::Read;- let repo = TestRepo::new();-let wt_bin = get_cargo_bin("wt");let wt_bin_dir = wt_bin.parent().unwrap();@@ -3066,13 +3010,11 @@ for c in "${{COMPREPLY[@]}}"; do echo "${{c%% *}}"; done#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_wrapper_help_redirect_captures_all_output(#[case] shell: &str) {+ fn test_wrapper_help_redirect_captures_all_output(#[case] shell: &str, repo: TestRepo) {skip_if_shell_unavailable!(shell);use portable_pty::{CommandBuilder, PtySize};use std::io::Read;- let repo = TestRepo::new();-let wt_bin = get_cargo_bin("wt");let wt_bin_dir = wt_bin.parent().unwrap();@@ -3264,13 +3206,11 @@ echo "SCRIPT_COMPLETED"#[case("bash")]#[case("zsh")]#[case("fish")]- fn test_wrapper_help_interactive_uses_pager(#[case] shell: &str) {+ fn test_wrapper_help_interactive_uses_pager(#[case] shell: &str, repo: TestRepo) {skip_if_shell_unavailable!(shell);use portable_pty::{CommandBuilder, PtySize};use std::io::Read;- let repo = TestRepo::new();-let wt_bin = get_cargo_bin("wt");let wt_bin_dir = wt_bin.parent().unwrap();diff --git a/tests/integration_tests/spacing_edge_cases.rs b/tests/integration_tests/spacing_edge_cases.rsindex 578162317..88db918ac 100644--- a/tests/integration_tests/spacing_edge_cases.rs+++ b/tests/integration_tests/spacing_edge_cases.rs@@ -1,6 +1,7 @@-use crate::common::{TestRepo, list_snapshots, setup_snapshot_settings};+use crate::common::{TestRepo, list_snapshots, repo, setup_snapshot_settings};use insta::Settings;use insta_cmd::assert_cmd_snapshot;+use rstest::rstest;use std::process::Command;fn snapshot_list(test_name: &str, repo: &TestRepo) {@@ -25,10 +26,8 @@ fn run_snapshot(settings: Settings, test_name: &str, mut cmd: Command) {});}-#[test]-fn test_short_branch_names_shorter_than_header() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_short_branch_names_shorter_than_header(mut repo: TestRepo) {// Create worktrees with very short branch names (shorter than "Branch" header)repo.add_worktree("a");repo.add_worktree("bb");@@ -37,10 +36,8 @@ fn test_short_branch_names_shorter_than_header() {snapshot_list("short_branch_names", &repo);}-#[test]-fn test_long_branch_names_longer_than_header() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_long_branch_names_longer_than_header(mut repo: TestRepo) {// Create worktrees with very long branch namesrepo.add_worktree("very-long-feature-branch-name");repo.add_worktree("another-extremely-long-name-here");@@ -49,10 +46,8 @@ fn test_long_branch_names_longer_than_header() {snapshot_list("long_branch_names", &repo);}-#[test]-fn test_unicode_branch_names_width_calculation() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_unicode_branch_names_width_calculation(mut repo: TestRepo) {// Create worktrees with unicode characters that have different visual widths// Note: Git may have restrictions on branch names, so use valid charactersrepo.add_worktree("cafe");@@ -62,10 +57,8 @@ fn test_unicode_branch_names_width_calculation() {snapshot_list("unicode_branch_names", &repo);}-#[test]-fn test_mixed_length_branch_names() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_mixed_length_branch_names(mut repo: TestRepo) {// Mix of very short, medium, and very long branch namesrepo.add_worktree("x");repo.add_worktree("medium");@@ -77,10 +70,8 @@ fn test_mixed_length_branch_names() {// Column alignment tests with varying diff sizes// (Merged from column_alignment.rs)-#[test]-fn test_column_alignment_varying_diff_widths() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_column_alignment_varying_diff_widths(mut repo: TestRepo) {// Create worktrees with varying diff sizes to test alignmentrepo.add_worktree("feature-small");repo.add_worktree("feature-medium");@@ -106,10 +97,8 @@ fn test_column_alignment_varying_diff_widths() {snapshot_list_with_width("alignment_varying_diffs", &repo, 180);}-#[test]-fn test_column_alignment_with_empty_diffs() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_column_alignment_with_empty_diffs(mut repo: TestRepo) {// Mix of worktrees with and without diffsrepo.add_worktree("no-changes");@@ -123,10 +112,8 @@ fn test_column_alignment_with_empty_diffs() {snapshot_list_with_width("alignment_empty_diffs", &repo, 180);}-#[test]-fn test_column_alignment_extreme_diff_sizes() {- let mut repo = TestRepo::new();-+#[rstest]+fn test_column_alignment_extreme_diff_sizes(mut repo: TestRepo) {// Create worktrees with extreme diff size differencesrepo.add_worktree("tiny");repo.add_worktree("huge");diff --git a/tests/integration_tests/statusline.rs b/tests/integration_tests/statusline.rsindex b624fc3b1..325c89ce8 100644--- a/tests/integration_tests/statusline.rs+++ b/tests/integration_tests/statusline.rs@@ -2,8 +2,9 @@//!//! Tests the statusline output for shell prompts and Claude Code integration.-use crate::common::{TestRepo, wt_command};+use crate::common::{TestRepo, repo, wt_command};use insta::assert_snapshot;+use rstest::rstest;use std::io::Write;use std::process::Stdio;@@ -60,20 +61,14 @@ fn run_statusline(repo: &TestRepo, args: &[&str], stdin_json: Option<&str>) -> Srun_statusline_from_dir(repo, args, stdin_json, repo.root_path())}-// --- Test Fixtures -----fn setup_repo_with_changes() -> TestRepo {- let repo = TestRepo::new();+// --- Test Setup Helpers ---+fn add_uncommitted_changes(repo: &TestRepo) {// Create uncommitted changesstd::fs::write(repo.root_path().join("modified.txt"), "modified content").unwrap();-- repo}-fn setup_repo_with_commits_ahead() -> TestRepo {- let mut repo = TestRepo::new();-+fn add_commits_ahead(repo: &mut TestRepo) {// Create feature branch with commits aheadlet feature_path = repo.add_worktree("feature");@@ -97,29 +92,26 @@ fn setup_repo_with_commits_ahead() -> TestRepo {.current_dir(&feature_path).output().unwrap();-- repo}// --- Basic Tests ----#[test]-fn test_statusline_basic() {- let repo = TestRepo::new();+#[rstest]+fn test_statusline_basic(repo: TestRepo) {let output = run_statusline(&repo, &[], None);assert_snapshot!(output, @"main [2m^[22m");}-#[test]-fn test_statusline_with_changes() {- let repo = setup_repo_with_changes();+#[rstest]+fn test_statusline_with_changes(repo: TestRepo) {+ add_uncommitted_changes(&repo);let output = run_statusline(&repo, &[], None);assert_snapshot!(output, @"main [36m?[39m[2m^[22m");}-#[test]-fn test_statusline_commits_ahead() {- let repo = setup_repo_with_commits_ahead();+#[rstest]+fn test_statusline_commits_ahead(mut repo: TestRepo) {+ add_commits_ahead(&mut repo);// Run from the feature worktree to see commits aheadlet feature_path = repo.worktree_path("feature");let output = run_statusline_from_dir(&repo, &[], None, feature_path);@@ -151,10 +143,10 @@ fn escape_path_for_json(path: &std::path::Path) -> String {/// Skipped on Windows: stdin read has 10ms timeout, Windows process spawning is slower/// causing timing-sensitive race condition where model name is lost.-#[test]+#[rstest]#[cfg_attr(windows, ignore)]-fn test_statusline_claude_code_full_context() {- let repo = setup_repo_with_changes();+fn test_statusline_claude_code_full_context(repo: TestRepo) {+ add_uncommitted_changes(&repo);let escaped_path = escape_path_for_json(repo.root_path());let json = format!(@@ -179,10 +171,8 @@ fn test_statusline_claude_code_full_context() {});}-#[test]-fn test_statusline_claude_code_minimal() {- let repo = TestRepo::new();-+#[rstest]+fn test_statusline_claude_code_minimal(repo: TestRepo) {let escaped_path = escape_path_for_json(repo.root_path());let json = format!(r#"{{"workspace": {{"current_dir": "{escaped_path}"}}}}"#,);@@ -194,11 +184,9 @@ fn test_statusline_claude_code_minimal() {/// Skipped on Windows: stdin read has 10ms timeout, Windows process spawning is slower/// causing timing-sensitive race condition where model name is lost.-#[test]+#[rstest]#[cfg_attr(windows, ignore)]-fn test_statusline_claude_code_with_model() {- let repo = TestRepo::new();-+fn test_statusline_claude_code_with_model(repo: TestRepo) {let escaped_path = escape_path_for_json(repo.root_path());let json = format!(r#"{{@@ -215,10 +203,10 @@ fn test_statusline_claude_code_with_model() {// --- Directive Mode Tests ----#[test]-fn test_statusline_directive_mode() {+#[rstest]+fn test_statusline_directive_mode(repo: TestRepo) {// When called with --internal, output goes to stderr (stdout empty for shell eval)- let repo = setup_repo_with_changes();+ add_uncommitted_changes(&repo);let mut cmd = wt_command();cmd.current_dir(repo.root_path());