Skip to content

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

Refactor tests to use rstest fixture instead of manual setup

Maximilian Roos35674060b15e
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 604569ba2..74d4633ad 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -146,6 +146,115 @@ pub fn repo_with_remote(mut repo: TestRepo) -> TestRepo {
repo
}
+/// Merge test setup with a single commit on feature branch.
+///
+/// Creates a repo with:
+/// - A worktree for main at `repo.main-wt`
+/// - A feature worktree with one commit adding `feature.txt`
+///
+/// Returns `(repo, feature_worktree_path)`.
+///
+/// # Example
+/// ```ignore
+/// #[rstest]
+/// fn test_merge(merge_scenario: (TestRepo, PathBuf)) {
+/// let (repo, feature_wt) = merge_scenario;
+/// // feature_wt has one commit ready to merge
+/// }
+/// ```
+#[rstest::fixture]
+pub fn merge_scenario(mut repo: TestRepo) -> (TestRepo, PathBuf) {
+ // Create a worktree for main
+ let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
+ let mut cmd = Command::new("git");
+ repo.configure_git_cmd(&mut cmd);
+ cmd.args(["worktree", "add", main_wt.to_str().unwrap(), "main"])
+ .current_dir(repo.root_path())
+ .output()
+ .unwrap();
+
+ // Create a feature worktree and make a commit
+ let feature_wt = repo.add_worktree("feature");
+ std::fs::write(feature_wt.join("feature.txt"), "feature content").unwrap();
+
+ let mut cmd = Command::new("git");
+ repo.configure_git_cmd(&mut cmd);
+ cmd.args(["add", "feature.txt"])
+ .current_dir(&feature_wt)
+ .output()
+ .unwrap();
+
+ let mut cmd = Command::new("git");
+ repo.configure_git_cmd(&mut cmd);
+ cmd.args(["commit", "-m", "Add feature file"])
+ .current_dir(&feature_wt)
+ .output()
+ .unwrap();
+
+ (repo, feature_wt)
+}
+
+/// Merge test setup with multiple commits on feature branch.
+///
+/// Creates a repo with:
+/// - A worktree for main at `repo.main-wt`
+/// - A feature worktree with two commits: `file1.txt` and `file2.txt`
+///
+/// Returns `(repo, feature_worktree_path)`.
+///
+/// # Example
+/// ```ignore
+/// #[rstest]
+/// fn test_squash(merge_scenario_multi_commit: (TestRepo, PathBuf)) {
+/// let (repo, feature_wt) = merge_scenario_multi_commit;
+/// // feature_wt has two commits ready to squash-merge
+/// }
+/// ```
+#[rstest::fixture]
+pub fn merge_scenario_multi_commit(mut repo: TestRepo) -> (TestRepo, PathBuf) {
+ // Create a worktree for main
+ let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
+ let mut cmd = Command::new("git");
+ repo.configure_git_cmd(&mut cmd);
+ cmd.args(["worktree", "add", main_wt.to_str().unwrap(), "main"])
+ .current_dir(repo.root_path())
+ .output()
+ .unwrap();
+
+ // Create a feature worktree and make multiple commits
+ let feature_wt = repo.add_worktree("feature");
+
+ std::fs::write(feature_wt.join("file1.txt"), "content 1").unwrap();
+ let mut cmd = Command::new("git");
+ repo.configure_git_cmd(&mut cmd);
+ cmd.args(["add", "file1.txt"])
+ .current_dir(&feature_wt)
+ .output()
+ .unwrap();
+ let mut cmd = Command::new("git");
+ repo.configure_git_cmd(&mut cmd);
+ cmd.args(["commit", "-m", "feat: add file 1"])
+ .current_dir(&feature_wt)
+ .output()
+ .unwrap();
+
+ std::fs::write(feature_wt.join("file2.txt"), "content 2").unwrap();
+ let mut cmd = Command::new("git");
+ repo.configure_git_cmd(&mut cmd);
+ cmd.args(["add", "file2.txt"])
+ .current_dir(&feature_wt)
+ .output()
+ .unwrap();
+ let mut cmd = Command::new("git");
+ repo.configure_git_cmd(&mut cmd);
+ cmd.args(["commit", "-m", "feat: add file 2"])
+ .current_dir(&feature_wt)
+ .output()
+ .unwrap();
+
+ (repo, feature_wt)
+}
+
/// Returns a PTY system after ensuring SIGTTIN/SIGTTOU signals are blocked.
///
/// Use this instead of `portable_pty::native_pty_system()` directly to ensure
diff --git a/tests/integration_tests/completion.rs b/tests/integration_tests/completion.rs
index d3d602cb5..324c8586a 100644
--- a/tests/integration_tests/completion.rs
+++ b/tests/integration_tests/completion.rs
@@ -1,5 +1,6 @@
-use crate::common::{TestRepo, wt_command, wt_completion_command};
+use crate::common::{TestRepo, repo, wt_command, wt_completion_command};
use insta::Settings;
+use rstest::rstest;
use std::process::Command;
fn only_option_suggestions(stdout: &str) -> bool {
@@ -29,21 +30,20 @@ fn value_suggestions(stdout: &str) -> Vec<&str> {
.collect()
}
-#[test]
-fn test_complete_switch_shows_branches() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_shows_branches(repo: TestRepo) {
+ repo.commit("initial");
// Create some branches using git
Command::new("git")
.args(["branch", "feature/new"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
Command::new("git")
.args(["branch", "hotfix/bug"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
@@ -51,7 +51,7 @@ fn test_complete_switch_shows_branches() {
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
settings.bind(|| {
- let output = temp.completion_cmd(&["wt", "switch", ""]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", "switch", ""]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stdout.contains("feature/new"));
@@ -60,18 +60,17 @@ fn test_complete_switch_shows_branches() {
});
}
-#[test]
-fn test_complete_switch_shows_all_branches_including_worktrees() {
- let mut temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_shows_all_branches_including_worktrees(mut repo: TestRepo) {
+ repo.commit("initial");
// Create worktree (this creates a new branch "feature/new")
- temp.add_worktree("feature/new");
+ repo.add_worktree("feature/new");
// Create another branch without worktree
Command::new("git")
.args(["branch", "hotfix/bug"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
@@ -79,7 +78,7 @@ fn test_complete_switch_shows_all_branches_including_worktrees() {
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
settings.bind(|| {
- let output = temp.completion_cmd(&["wt", "switch", ""]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", "switch", ""]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
assert!(stdout.contains("feature/new"));
@@ -88,18 +87,17 @@ fn test_complete_switch_shows_all_branches_including_worktrees() {
});
}
-#[test]
-fn test_complete_push_shows_all_branches() {
- let mut temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_push_shows_all_branches(mut repo: TestRepo) {
+ repo.commit("initial");
// Create worktree (creates "feature/new" branch)
- temp.add_worktree("feature/new");
+ repo.add_worktree("feature/new");
// Create another branch without worktree
Command::new("git")
.args(["branch", "hotfix/bug"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
@@ -107,7 +105,7 @@ fn test_complete_push_shows_all_branches() {
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
settings.bind(|| {
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "step", "push", ""])
.output()
.unwrap();
@@ -123,21 +121,20 @@ fn test_complete_push_shows_all_branches() {
});
}
-#[test]
-fn test_complete_base_flag_all_formats() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_base_flag_all_formats(repo: TestRepo) {
+ repo.commit("initial");
// Create branches
Command::new("git")
.args(["branch", "develop"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
Command::new("git")
.args(["branch", "feature/existing"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
@@ -152,7 +149,7 @@ fn test_complete_base_flag_all_formats() {
];
for args in test_cases {
- let output = temp.completion_cmd(args).output().unwrap();
+ let output = repo.completion_cmd(args).output().unwrap();
assert!(output.status.success(), "Failed for args: {:?}", args);
let stdout = String::from_utf8_lossy(&output.stdout);
let branches = value_suggestions(&stdout);
@@ -172,7 +169,7 @@ fn test_complete_base_flag_all_formats() {
}
// Test partial completion --base=m (shell handles filtering, we return all)
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "--create", "new-branch", "--base=m"])
.output()
.unwrap();
@@ -182,7 +179,7 @@ fn test_complete_base_flag_all_formats() {
assert!(branches.iter().any(|b| b.contains("main")));
}
-#[test]
+#[rstest]
fn test_complete_outside_git_repo() {
let temp = tempfile::tempdir().unwrap();
let mut settings = Settings::clone_current();
@@ -205,7 +202,7 @@ fn test_complete_outside_git_repo() {
});
}
-#[test]
+#[rstest]
fn test_complete_empty_repo() {
let repo = TestRepo::empty();
let mut settings = Settings::clone_current();
@@ -225,9 +222,8 @@ fn test_complete_empty_repo() {
});
}
-#[test]
-fn test_complete_unknown_command() {
- let repo = TestRepo::new();
+#[rstest]
+fn test_complete_unknown_command(repo: TestRepo) {
repo.commit("initial");
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
@@ -248,9 +244,8 @@ fn test_complete_unknown_command() {
});
}
-#[test]
-fn test_complete_step_commit_no_positionals() {
- let repo = TestRepo::new();
+#[rstest]
+fn test_complete_step_commit_no_positionals(repo: TestRepo) {
repo.commit("initial");
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
@@ -272,9 +267,8 @@ fn test_complete_step_commit_no_positionals() {
});
}
-#[test]
-fn test_complete_list_command() {
- let repo = TestRepo::new();
+#[rstest]
+fn test_complete_list_command(repo: TestRepo) {
repo.commit("initial");
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
@@ -294,7 +288,7 @@ fn test_complete_list_command() {
});
}
-#[test]
+#[rstest]
fn test_init_fish_no_inline_completions() {
// Test that fish init does NOT have inline completions (they're in a separate file)
let mut cmd = wt_command();
@@ -321,27 +315,26 @@ fn test_init_fish_no_inline_completions() {
);
}
-#[test]
-fn test_complete_with_partial_prefix() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_with_partial_prefix(repo: TestRepo) {
+ repo.commit("initial");
// Create branches with common prefix
Command::new("git")
.args(["branch", "feature/one"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
Command::new("git")
.args(["branch", "feature/two"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
Command::new("git")
.args(["branch", "hotfix/bug"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
@@ -349,7 +342,7 @@ fn test_complete_with_partial_prefix() {
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
settings.bind(|| {
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "feat"])
.output()
.unwrap();
@@ -360,17 +353,16 @@ fn test_complete_with_partial_prefix() {
});
}
-#[test]
-fn test_complete_switch_shows_all_branches_even_with_worktrees() {
- let mut temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_shows_all_branches_even_with_worktrees(mut repo: TestRepo) {
+ repo.commit("initial");
// Create two branches, both with worktrees
- temp.add_worktree("feature/new");
- temp.add_worktree("hotfix/bug");
+ repo.add_worktree("feature/new");
+ repo.add_worktree("hotfix/bug");
// From the main worktree, test completion - should show all branches
- let output = temp.completion_cmd(&["wt", "switch", ""]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", "switch", ""]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
@@ -380,28 +372,27 @@ fn test_complete_switch_shows_all_branches_even_with_worktrees() {
assert!(stdout.contains("hotfix/bug"));
}
-#[test]
-fn test_complete_excludes_remote_branches() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_excludes_remote_branches(repo: TestRepo) {
+ repo.commit("initial");
// Create local branches
Command::new("git")
.args(["branch", "feature/local"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Set up a fake remote
Command::new("git")
.args(["remote", "add", "origin", "https://example.com/repo.git"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Create a remote-tracking branch by fetching from a local "remote"
// First, create a bare repo to act as remote
- let remote_dir = temp.root_path().parent().unwrap().join("remote.git");
+ let remote_dir = repo.root_path().parent().unwrap().join("remote.git");
Command::new("git")
.args(["init", "--bare", remote_dir.to_str().unwrap()])
.output()
@@ -410,32 +401,32 @@ fn test_complete_excludes_remote_branches() {
// Update remote URL to point to our bare repo
Command::new("git")
.args(["remote", "set-url", "origin", remote_dir.to_str().unwrap()])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Push to create remote branches
Command::new("git")
.args(["push", "origin", "main"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
Command::new("git")
.args(["push", "origin", "feature/local:feature/remote"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Fetch to create remote-tracking branches
Command::new("git")
.args(["fetch", "origin"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test completion
- let output = temp.completion_cmd(&["wt", "switch", ""]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", "switch", ""]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
@@ -458,23 +449,22 @@ fn test_complete_excludes_remote_branches() {
);
}
-#[test]
-fn test_complete_merge_shows_branches() {
- let mut temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_merge_shows_branches(mut repo: TestRepo) {
+ repo.commit("initial");
// Create worktree (creates "feature/new" branch)
- temp.add_worktree("feature/new");
+ repo.add_worktree("feature/new");
// Create another branch without worktree
Command::new("git")
.args(["branch", "hotfix/bug"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test completion for merge (should show ALL branches, including those with worktrees)
- let output = temp.completion_cmd(&["wt", "merge", ""]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", "merge", ""]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
@@ -485,10 +475,9 @@ fn test_complete_merge_shows_branches() {
assert!(branches.iter().any(|b| b.contains("hotfix/bug")));
}
-#[test]
-fn test_complete_with_special_characters_in_branch_names() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_with_special_characters_in_branch_names(repo: TestRepo) {
+ repo.commit("initial");
// Create branches with various special characters
let branch_names = vec![
@@ -501,13 +490,13 @@ fn test_complete_with_special_characters_in_branch_names() {
for branch in &branch_names {
Command::new("git")
.args(["branch", branch])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
}
// Test completion
- let output = temp.completion_cmd(&["wt", "switch", ""]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", "switch", ""]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
@@ -523,21 +512,20 @@ fn test_complete_with_special_characters_in_branch_names() {
}
}
-#[test]
-fn test_complete_stops_after_branch_provided() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_stops_after_branch_provided(repo: TestRepo) {
+ repo.commit("initial");
// Create branches
Command::new("git")
.args(["branch", "feature/one"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
Command::new("git")
.args(["branch", "feature/two"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
@@ -545,7 +533,7 @@ fn test_complete_stops_after_branch_provided() {
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
settings.bind(|| {
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "feature/one", ""])
.output()
.unwrap();
@@ -561,7 +549,7 @@ fn test_complete_stops_after_branch_provided() {
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
settings.bind(|| {
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "step", "push", "feature/one", ""])
.output()
.unwrap();
@@ -577,7 +565,7 @@ fn test_complete_stops_after_branch_provided() {
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
settings.bind(|| {
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "merge", "feature/one", ""])
.output()
.unwrap();
@@ -590,14 +578,13 @@ fn test_complete_stops_after_branch_provided() {
});
}
-#[test]
-fn test_complete_switch_with_create_flag_no_completion() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_with_create_flag_no_completion(repo: TestRepo) {
+ repo.commit("initial");
Command::new("git")
.args(["branch", "feature/existing"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
@@ -605,7 +592,7 @@ fn test_complete_switch_with_create_flag_no_completion() {
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
settings.bind(|| {
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "--create", ""])
.output()
.unwrap();
@@ -621,7 +608,7 @@ fn test_complete_switch_with_create_flag_no_completion() {
let mut settings = Settings::clone_current();
settings.set_snapshot_path("../snapshots");
settings.bind(|| {
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "-c", ""])
.output()
.unwrap();
@@ -634,20 +621,19 @@ fn test_complete_switch_with_create_flag_no_completion() {
});
}
-#[test]
-fn test_complete_switch_base_flag_after_branch() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_base_flag_after_branch(repo: TestRepo) {
+ repo.commit("initial");
// Create branches
Command::new("git")
.args(["branch", "develop"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test completion for --base even after --create and branch name
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "--create", "new-feature", "--base", ""])
.output()
.unwrap();
@@ -659,23 +645,22 @@ fn test_complete_switch_base_flag_after_branch() {
assert!(stdout.contains("develop"));
}
-#[test]
-fn test_complete_remove_excludes_remote_only_branches() {
- let mut temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_remove_excludes_remote_only_branches(mut repo: TestRepo) {
+ repo.commit("initial");
// Create worktree (creates "feature/new" branch)
- temp.add_worktree("feature/new");
+ repo.add_worktree("feature/new");
// Create another local branch without worktree
Command::new("git")
.args(["branch", "hotfix/bug"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test completion for remove (should show local branches, exclude remote-only)
- let output = temp.completion_cmd(&["wt", "remove", ""]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", "remove", ""]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
@@ -687,13 +672,12 @@ fn test_complete_remove_excludes_remote_only_branches() {
assert!(branches.iter().any(|b| b.contains("hotfix/bug")));
}
-#[test]
-fn test_complete_step_subcommands() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_step_subcommands(repo: TestRepo) {
+ repo.commit("initial");
// Test: No input - shows all step subcommands (git operations only)
- let output = temp.completion_cmd(&["wt", "step", ""]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", "step", ""]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
let subcommands = value_suggestions(&stdout);
@@ -710,13 +694,12 @@ fn test_complete_step_subcommands() {
);
}
-#[test]
-fn test_complete_hook_subcommands() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_hook_subcommands(repo: TestRepo) {
+ repo.commit("initial");
// Test 1: No input - shows all hook subcommands
- let output = temp.completion_cmd(&["wt", "hook", ""]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", "hook", ""]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
let subcommands = value_suggestions(&stdout);
@@ -736,7 +719,7 @@ fn test_complete_hook_subcommands() {
);
// Test 2: Partial input "po" - filters to post-* subcommands
- let output = temp.completion_cmd(&["wt", "hook", "po"]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", "hook", "po"]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
let subcommands = value_suggestions(&stdout);
@@ -747,13 +730,12 @@ fn test_complete_hook_subcommands() {
assert!(!subcommands.contains(&"pre-merge"));
}
-#[test]
-fn test_complete_init_shell_all_variations() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_init_shell_all_variations(repo: TestRepo) {
+ repo.commit("initial");
// Test 1: No input - shows all supported shells
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "config", "shell", "init", ""])
.output()
.unwrap();
@@ -767,7 +749,7 @@ fn test_complete_init_shell_all_variations() {
assert!(!shells.contains(&"nushell"));
// Test 2: Partial input "fi" - filters to fish
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "config", "shell", "init", "fi"])
.output()
.unwrap();
@@ -778,7 +760,7 @@ fn test_complete_init_shell_all_variations() {
assert!(!shells.contains(&"bash"));
// Test 3: Partial input "z" - filters to zsh
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "config", "shell", "init", "z"])
.output()
.unwrap();
@@ -790,7 +772,7 @@ fn test_complete_init_shell_all_variations() {
assert!(!shells.contains(&"fish"));
// Test 4: With --source flag - same behavior
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "--source", "config", "shell", "init", ""])
.output()
.unwrap();
@@ -804,13 +786,12 @@ fn test_complete_init_shell_all_variations() {
// test_complete_init_shell_all_with_source removed - duplicate of test_complete_init_shell_with_source_flag
-#[test]
-fn test_complete_list_format_flag() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_list_format_flag(repo: TestRepo) {
+ repo.commit("initial");
// Test completion for list --format flag
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "list", "--format", ""])
.output()
.unwrap();
@@ -825,14 +806,13 @@ fn test_complete_list_format_flag() {
assert!(values.contains(&"json"));
}
-#[test]
-fn test_complete_switch_execute_all_formats() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_execute_all_formats(repo: TestRepo) {
+ repo.commit("initial");
Command::new("git")
.args(["branch", "feature"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
@@ -845,7 +825,7 @@ fn test_complete_switch_execute_all_formats() {
];
for args in test_cases {
- let output = temp.completion_cmd(args).output().unwrap();
+ let output = repo.completion_cmd(args).output().unwrap();
assert!(output.status.success(), "Failed for args: {:?}", args);
let stdout = String::from_utf8_lossy(&output.stdout);
let branches: Vec<&str> = stdout.lines().collect();
@@ -864,20 +844,19 @@ fn test_complete_switch_execute_all_formats() {
}
}
-#[test]
-fn test_complete_switch_with_double_dash_terminator() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_with_double_dash_terminator(repo: TestRepo) {
+ repo.commit("initial");
Command::new("git")
.args(["branch", "feature"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test: wt switch -- <cursor>
// After --, everything is positional, should complete branches
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "--", ""])
.output()
.unwrap();
@@ -889,20 +868,19 @@ fn test_complete_switch_with_double_dash_terminator() {
assert!(branches.iter().any(|b| b.contains("main")));
}
-#[test]
-fn test_complete_switch_positional_already_provided() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_positional_already_provided(repo: TestRepo) {
+ repo.commit("initial");
Command::new("git")
.args(["branch", "existing"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test: wt switch existing <cursor>
// Positional already provided, should NOT complete branches
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "existing", ""])
.output()
.unwrap();
@@ -915,20 +893,19 @@ fn test_complete_switch_positional_already_provided() {
);
}
-#[test]
-fn test_complete_switch_completing_execute_value() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_completing_execute_value(repo: TestRepo) {
+ repo.commit("initial");
Command::new("git")
.args(["branch", "develop"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test: wt switch --execute <cursor>
// Currently typing the value for --execute, should NOT complete branches
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "--execute", ""])
.output()
.unwrap();
@@ -939,20 +916,19 @@ fn test_complete_switch_completing_execute_value() {
assert_eq!(stdout.trim(), "");
}
-#[test]
-fn test_complete_merge_with_flags() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_merge_with_flags(repo: TestRepo) {
+ repo.commit("initial");
Command::new("git")
.args(["branch", "hotfix"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test: wt merge --no-remove --force <cursor>
// Should complete branches for positional (boolean flags don't consume arguments)
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "merge", "--no-remove", "--force", ""])
.output()
.unwrap();
@@ -964,27 +940,26 @@ fn test_complete_merge_with_flags() {
assert!(branches.iter().any(|b| b.contains("main")));
}
-#[test]
-fn test_complete_switch_base_after_execute_equals() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_base_after_execute_equals(repo: TestRepo) {
+ repo.commit("initial");
// Create branches
Command::new("git")
.args(["branch", "develop"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
Command::new("git")
.args(["branch", "production"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test: wt switch --create --execute=claude --base <cursor>
// This is the reported failing case - should complete branches for --base
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "--create", "--execute=claude", "--base", ""])
.output()
.unwrap();
@@ -1008,20 +983,19 @@ fn test_complete_switch_base_after_execute_equals() {
);
}
-#[test]
-fn test_complete_switch_flexible_argument_ordering() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_flexible_argument_ordering(repo: TestRepo) {
+ repo.commit("initial");
Command::new("git")
.args(["branch", "develop"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test that .last(true) allows positional before flags
// wt switch feature --base <cursor>
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "feature", "--base", ""])
.output()
.unwrap();
@@ -1041,19 +1015,18 @@ fn test_complete_switch_flexible_argument_ordering() {
);
}
-#[test]
-fn test_complete_remove_flexible_argument_ordering() {
- let mut temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_remove_flexible_argument_ordering(mut repo: TestRepo) {
+ repo.commit("initial");
// Create two worktrees
- temp.add_worktree("feature");
- temp.add_worktree("bugfix");
+ repo.add_worktree("feature");
+ repo.add_worktree("bugfix");
// Test that .last(true) allows positional before flags
// wt remove feature --no-delete-branch <cursor>
// Since remove accepts multiple worktrees, should suggest more worktrees
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "remove", "feature", "--no-delete-branch", ""])
.output()
.unwrap();
@@ -1069,20 +1042,19 @@ fn test_complete_remove_flexible_argument_ordering() {
);
}
-#[test]
-fn test_complete_filters_options_when_positionals_exist() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_filters_options_when_positionals_exist(repo: TestRepo) {
+ repo.commit("initial");
Command::new("git")
.args(["branch", "feature"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test: wt switch <cursor>
// Should show branches but NOT options like --config, --verbose, -C
- let output = temp.completion_cmd(&["wt", "switch", ""]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", "switch", ""]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
@@ -1097,14 +1069,13 @@ fn test_complete_filters_options_when_positionals_exist() {
);
}
-#[test]
-fn test_complete_subcommands_filter_options() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_subcommands_filter_options(repo: TestRepo) {
+ repo.commit("initial");
// Test: wt <cursor>
// Should show subcommands but NOT global options
- let output = temp.completion_cmd(&["wt", ""]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", ""]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
let suggestions = value_suggestions(&stdout);
@@ -1122,7 +1093,7 @@ fn test_complete_subcommands_filter_options() {
// Test: wt --<cursor>
// Now options SHOULD appear
- let output = temp.completion_cmd(&["wt", "--"]).output().unwrap();
+ let output = repo.completion_cmd(&["wt", "--"]).output().unwrap();
assert!(output.status.success());
let stdout = String::from_utf8_lossy(&output.stdout);
@@ -1132,27 +1103,26 @@ fn test_complete_subcommands_filter_options() {
);
}
-#[test]
-fn test_complete_switch_option_prefix_shows_options_not_branches() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_option_prefix_shows_options_not_branches(repo: TestRepo) {
+ repo.commit("initial");
// Create branches that happen to contain "-c" in the name
Command::new("git")
.args(["branch", "fish-switch-complete"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
Command::new("git")
.args(["branch", "zsh-bash-complete"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test: wt switch --c<cursor>
// Should show options starting with --c (like --create), NOT branches containing "-c"
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "--c"])
.output()
.unwrap();
@@ -1176,21 +1146,20 @@ fn test_complete_switch_option_prefix_shows_options_not_branches() {
);
}
-#[test]
-fn test_complete_switch_single_dash_shows_options_not_branches() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_switch_single_dash_shows_options_not_branches(repo: TestRepo) {
+ repo.commit("initial");
// Create a branch that contains "-" in the name
Command::new("git")
.args(["branch", "feature-branch"])
- .current_dir(temp.root_path())
+ .current_dir(repo.root_path())
.output()
.unwrap();
// Test: wt switch -<cursor>
// Should show short options, NOT branches containing "-"
- let output = temp
+ let output = repo
.completion_cmd(&["wt", "switch", "-"])
.output()
.unwrap();
@@ -1215,14 +1184,13 @@ fn test_complete_switch_single_dash_shows_options_not_branches() {
/// This is a regression test for a bug where --help was missing from zsh completions
/// because clap's built-in help flag was disabled (to participate in completion filtering)
/// but not replaced with a visible alternative.
-#[test]
-fn test_complete_help_flag_all_shells() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_help_flag_all_shells(repo: TestRepo) {
+ repo.commit("initial");
for shell in ["bash", "zsh", "fish"] {
// Test: wt --help<cursor> - should complete --help
- let output = temp
+ let output = repo
.completion_cmd_for_shell(&["wt", "--help"], shell)
.output()
.unwrap();
@@ -1234,7 +1202,7 @@ fn test_complete_help_flag_all_shells() {
);
// Test: wt config --help<cursor> - should complete --help on subcommands too
- let output = temp
+ let output = repo
.completion_cmd_for_shell(&["wt", "config", "--help"], shell)
.output()
.unwrap();
@@ -1248,14 +1216,13 @@ fn test_complete_help_flag_all_shells() {
}
/// Verify --version appears in completions across all supported shells (root command only).
-#[test]
-fn test_complete_version_flag_all_shells() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_version_flag_all_shells(repo: TestRepo) {
+ repo.commit("initial");
for shell in ["bash", "zsh", "fish"] {
// Test: wt --version<cursor> - should complete --version
- let output = temp
+ let output = repo
.completion_cmd_for_shell(&["wt", "--version"], shell)
.output()
.unwrap();
@@ -1273,14 +1240,13 @@ fn test_complete_version_flag_all_shells() {
/// The --internal flag is used by shell wrappers and should never be exposed to users.
/// This is a regression test for a bug where global hidden args would appear in completions
/// due to clap's "all hidden = all shown" behavior when completing `--`.
-#[test]
-fn test_complete_internal_flag_never_shown() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_internal_flag_never_shown(repo: TestRepo) {
+ repo.commit("initial");
for shell in ["bash", "zsh", "fish"] {
// Test: wt --<cursor> - should NOT show --internal
- let output = temp
+ let output = repo
.completion_cmd_for_shell(&["wt", "--"], shell)
.output()
.unwrap();
@@ -1292,7 +1258,7 @@ fn test_complete_internal_flag_never_shown() {
);
// Test: wt config --<cursor> - should NOT show --internal on subcommands either
- let output = temp
+ let output = repo
.completion_cmd_for_shell(&["wt", "config", "--"], shell)
.output()
.unwrap();
@@ -1304,7 +1270,7 @@ fn test_complete_internal_flag_never_shown() {
);
// Test: wt -<cursor> - should NOT show --internal even with single dash
- let output = temp
+ let output = repo
.completion_cmd_for_shell(&["wt", "-"], shell)
.output()
.unwrap();
@@ -1321,14 +1287,13 @@ fn test_complete_internal_flag_never_shown() {
///
/// When completing `wt -`, users should see both short flags like `-h` and long flags
/// like `--help`. This is more discoverable than requiring users to type `--` first.
-#[test]
-fn test_complete_single_dash_shows_both_short_and_long_flags() {
- let temp = TestRepo::new();
- temp.commit("initial");
+#[rstest]
+fn test_complete_single_dash_shows_both_short_and_long_flags(repo: TestRepo) {
+ repo.commit("initial");
for shell in ["bash", "zsh", "fish"] {
// Test: wt -<cursor> - should show both -h and --help
- let output = temp
+ let output = repo
.completion_cmd_for_shell(&["wt", "-"], shell)
.output()
.unwrap();
@@ -1356,7 +1321,7 @@ fn test_complete_single_dash_shows_both_short_and_long_flags() {
);
// Test: wt config -<cursor> - same behavior on subcommands
- let output = temp
+ let output = repo
.completion_cmd_for_shell(&["wt", "config", "-"], shell)
.output()
.unwrap();
diff --git a/tests/integration_tests/list.rs b/tests/integration_tests/list.rs
index faebfb01e..845fd2255 100644
--- a/tests/integration_tests/list.rs
+++ b/tests/integration_tests/list.rs
@@ -1,8 +1,10 @@
use crate::common::{
- DAY, HOUR, MINUTE, TestRepo, list_snapshots, setup_snapshot_settings, wt_command,
+ DAY, HOUR, MINUTE, TestRepo, list_snapshots, repo, repo_with_remote, setup_snapshot_settings,
+ wt_command,
};
use insta::Settings;
use insta_cmd::assert_cmd_snapshot;
+use rstest::rstest;
use std::path::Path;
use std::process::Command;
@@ -220,17 +222,13 @@ fn push_branch(repo: &TestRepo, branch_name: &str) {
.unwrap();
}
-#[test]
-fn test_list_single_worktree() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_list_single_worktree(repo: TestRepo) {
snapshot_list("single_worktree", &repo);
}
-#[test]
-fn test_list_multiple_worktrees() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_multiple_worktrees(mut repo: TestRepo) {
repo.add_worktree("feature-a");
repo.add_worktree("feature-b");
@@ -240,10 +238,8 @@ fn test_list_multiple_worktrees() {
/// Test that the `-` gutter symbol appears for the previous worktree (target of `wt switch -`).
///
/// Simulates realistic usage by running switch commands from the correct worktree directories.
-#[test]
-fn test_list_previous_worktree_gutter() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_previous_worktree_gutter(mut repo: TestRepo) {
repo.add_worktree("feature");
let feature_path = repo.root_path().parent().unwrap().join(format!(
@@ -268,20 +264,17 @@ fn test_list_previous_worktree_gutter() {
snapshot_list("previous_worktree_gutter", &repo);
}
-#[test]
-fn test_list_detached_head() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_list_detached_head(repo: TestRepo) {
repo.detach_head();
snapshot_list("detached_head", &repo);
}
-#[test]
-fn test_list_detached_head_in_worktree() {
+#[rstest]
+fn test_list_detached_head_in_worktree(mut repo: TestRepo) {
// Non-main worktree in detached HEAD SHOULD show path mismatch flag
// (detached HEAD = "not at home", not on any branch)
- let mut repo = TestRepo::new();
repo.add_worktree("feature");
repo.detach_head_in_worktree("feature");
@@ -289,20 +282,16 @@ fn test_list_detached_head_in_worktree() {
snapshot_list("detached_head_in_worktree", &repo);
}
-#[test]
-fn test_list_locked_worktree() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_locked_worktree(mut repo: TestRepo) {
repo.add_worktree("locked-feature");
repo.lock_worktree("locked-feature", Some("Testing lock functionality"));
snapshot_list("locked_worktree", &repo);
}
-#[test]
-fn test_list_locked_no_reason() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_locked_no_reason(mut repo: TestRepo) {
repo.add_worktree("locked-no-reason");
repo.lock_worktree("locked-no-reason", None);
@@ -311,10 +300,8 @@ fn test_list_locked_no_reason() {
// Removed: test_list_long_branch_name - covered by spacing_edge_cases.rs
-#[test]
-fn test_list_long_commit_message() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_long_commit_message(mut repo: TestRepo) {
// Create commit with very long message
repo.commit("This is a very long commit message that should test how the message column handles truncation and word boundary detection in the list output");
@@ -326,10 +313,8 @@ fn test_list_long_commit_message() {
// Removed: test_list_unicode_branch_name - covered by spacing_edge_cases.rs
-#[test]
-fn test_list_unicode_commit_message() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_unicode_commit_message(mut repo: TestRepo) {
// Create commit with Unicode message
repo.commit("Add support for 日本語 and émoji 🎉");
@@ -339,10 +324,8 @@ fn test_list_unicode_commit_message() {
snapshot_list("unicode_commit_message", &repo);
}
-#[test]
-fn test_list_many_worktrees_with_varied_stats() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_many_worktrees_with_varied_stats(mut repo: TestRepo) {
// Create multiple worktrees with different characteristics
repo.add_worktree("short");
@@ -359,10 +342,8 @@ fn test_list_many_worktrees_with_varied_stats() {
// Removed: test_list_json_single_worktree and test_list_json_multiple_worktrees
// Basic JSON serialization is covered by test_list_json_with_metadata
-#[test]
-fn test_list_json_with_metadata() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_json_with_metadata(mut repo: TestRepo) {
// Create worktree with detached head
repo.add_worktree("feature-detached");
@@ -375,10 +356,8 @@ fn test_list_json_with_metadata() {
/// Test that committed_trees_match is true when a branch has commits ahead but identical tree content.
/// This tests the merge commit scenario where content matches main even with different commit history.
-#[test]
-fn test_list_json_tree_matches_main_after_merge() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_json_tree_matches_main_after_merge(mut repo: TestRepo) {
// Create feature branch with a worktree
let feature_path = repo.add_worktree("feature-merged");
@@ -425,10 +404,8 @@ fn test_list_json_tree_matches_main_after_merge() {
snapshot_list_json("json_tree_matches_main_after_merge", &repo);
}
-#[test]
-fn test_list_with_branches_flag() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_with_branches_flag(mut repo: TestRepo) {
// Create some branches without worktrees
create_branch(&repo, "feature-without-worktree");
create_branch(&repo, "another-branch");
@@ -440,10 +417,8 @@ fn test_list_with_branches_flag() {
snapshot_list_with_branches("with_branches_flag", &repo);
}
-#[test]
-fn test_list_with_branches_flag_no_available() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_with_branches_flag_no_available(mut repo: TestRepo) {
// All branches have worktrees (only main exists and has worktree)
repo.add_worktree("feature-a");
repo.add_worktree("feature-b");
@@ -451,10 +426,8 @@ fn test_list_with_branches_flag_no_available() {
snapshot_list_with_branches("with_branches_flag_none_available", &repo);
}
-#[test]
-fn test_list_with_branches_flag_only_branches() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_list_with_branches_flag_only_branches(repo: TestRepo) {
// Create several branches without worktrees
create_branch(&repo, "branch-alpha");
create_branch(&repo, "branch-beta");
@@ -463,12 +436,8 @@ fn test_list_with_branches_flag_only_branches() {
snapshot_list_with_branches("with_branches_flag_only_branches", &repo);
}
-#[test]
-fn test_list_with_remotes_flag() {
- let mut repo = TestRepo::new();
- // Setup remote creates origin and pushes main to it
- repo.setup_remote("main");
-
+#[rstest]
+fn test_list_with_remotes_flag(#[from(repo_with_remote)] repo: TestRepo) {
// Create feature branches in the main repo and push them
create_branch(&repo, "remote-feature-1");
create_branch(&repo, "remote-feature-2");
@@ -491,11 +460,8 @@ fn test_list_with_remotes_flag() {
snapshot_list_with_remotes("with_remotes_flag", &repo);
}
-#[test]
-fn test_list_with_remotes_and_branches() {
- let mut repo = TestRepo::new();
- repo.setup_remote("main");
-
+#[rstest]
+fn test_list_with_remotes_and_branches(#[from(repo_with_remote)] repo: TestRepo) {
// Create local-only branches (not worktrees, not pushed)
create_branch(&repo, "local-only-1");
create_branch(&repo, "local-only-2");
@@ -521,11 +487,8 @@ fn test_list_with_remotes_and_branches() {
snapshot_list_with_branches_and_remotes("with_remotes_and_branches", &repo);
}
-#[test]
-fn test_list_with_remotes_filters_existing_worktrees() {
- let mut repo = TestRepo::new();
- repo.setup_remote("main");
-
+#[rstest]
+fn test_list_with_remotes_filters_existing_worktrees(#[from(repo_with_remote)] mut repo: TestRepo) {
// Create a worktree and push the branch
repo.add_worktree("feature-with-worktree");
push_branch(&repo, "feature-with-worktree");
@@ -548,9 +511,8 @@ fn test_list_with_remotes_filters_existing_worktrees() {
snapshot_list_with_remotes("with_remotes_filters_worktrees", &repo);
}
-#[test]
-fn test_list_json_with_display_fields() {
- let mut repo = TestRepo::new();
+#[rstest]
+fn test_list_json_with_display_fields(mut repo: TestRepo) {
repo.commit("Initial commit on main");
// Create feature branch with commits (ahead of main)
@@ -595,18 +557,16 @@ fn test_list_json_with_display_fields() {
snapshot_list_json("json_with_display_fields", &repo);
}
-#[test]
-fn test_list_ordering_rules() {
- let mut repo = TestRepo::new();
+#[rstest]
+fn test_list_ordering_rules(mut repo: TestRepo) {
let current_path = setup_timestamped_worktrees(&mut repo);
// Run from feature-current worktree to test "current worktree" logic
snapshot_list_from_dir("list_ordering_rules", &repo, &current_path);
}
-#[test]
-fn test_list_with_upstream_tracking() {
- let mut repo = TestRepo::new();
+#[rstest]
+fn test_list_with_upstream_tracking(mut repo: TestRepo) {
repo.commit("Initial commit on main");
// Set up remote - this already pushes main
@@ -748,10 +708,8 @@ fn test_list_with_upstream_tracking() {
});
}
-#[test]
-fn test_list_primary_on_different_branch() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_primary_on_different_branch(mut repo: TestRepo) {
repo.switch_primary_to("develop");
assert_eq!(repo.current_branch(), "develop");
@@ -761,9 +719,8 @@ fn test_list_primary_on_different_branch() {
snapshot_list("list_primary_on_different_branch", &repo);
}
-#[test]
-fn test_list_with_user_marker() {
- let mut repo = TestRepo::new();
+#[rstest]
+fn test_list_with_user_marker(mut repo: TestRepo) {
repo.commit_with_age("Initial commit", DAY);
// Branch ahead of main with commits and user marker 🤖
@@ -821,9 +778,8 @@ fn test_list_with_user_marker() {
snapshot_list("with_user_marker", &repo);
}
-#[test]
-fn test_list_json_with_user_marker() {
- let mut repo = TestRepo::new();
+#[rstest]
+fn test_list_json_with_user_marker(mut repo: TestRepo) {
repo.commit_with_age("Initial commit", DAY);
// Worktree with user marker (emoji only)
@@ -843,10 +799,9 @@ fn test_list_json_with_user_marker() {
snapshot_list_json("json_with_user_marker", &repo);
}
-#[test]
-fn test_list_json_with_git_operation() {
+#[rstest]
+fn test_list_json_with_git_operation(mut repo: TestRepo) {
// Test JSON output includes git_operation field when worktree is in rebase state
- let mut repo = TestRepo::new();
// Create initial commit with a file that will conflict
std::fs::write(
@@ -916,10 +871,9 @@ fn test_list_json_with_git_operation() {
snapshot_list_json("json_with_git_operation", &repo);
}
-#[test]
-fn test_list_branch_only_with_status() {
+#[rstest]
+fn test_list_branch_only_with_status(repo: TestRepo) {
// Test that branch-only entries (no worktree) can display branch-keyed status
- let repo = TestRepo::new();
// Create a branch-only entry (no worktree)
let mut cmd = Command::new("git");
@@ -941,10 +895,8 @@ fn test_list_branch_only_with_status() {
snapshot_list_with_branches("branch_only_with_status", &repo);
}
-#[test]
-fn test_list_user_marker_with_special_characters() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_user_marker_with_special_characters(mut repo: TestRepo) {
// Test with single emoji
repo.add_worktree("emoji");
@@ -1846,7 +1798,7 @@ fn mock_ci_status(repo: &TestRepo, branch: &str, status: &str, source: &str, is_
/// Shows worktree states with status symbols, divergence, and remote tracking.
/// Uses narrower width (100 cols) to fit in doc site code blocks.
/// Output: tests/snapshots/integration__integration_tests__list__readme_example_list.snap
-#[test]
+#[rstest]
fn test_readme_example_list() {
let (repo, feature_api) = setup_readme_example_repo();
snapshot_readme_list_from_dir("readme_example_list", &repo, &feature_api);
@@ -1857,7 +1809,7 @@ fn test_readme_example_list() {
/// Shows additional columns: main…± (line diffs in commits) and CI status.
/// Uses narrower width (100 cols) to fit in doc site code blocks.
/// Output: tests/snapshots/integration__integration_tests__list__readme_example_list_full.snap
-#[test]
+#[rstest]
fn test_readme_example_list_full() {
let (repo, feature_api) = setup_readme_example_repo();
snapshot_readme_list_full_from_dir("readme_example_list_full", &repo, &feature_api);
@@ -1868,7 +1820,7 @@ fn test_readme_example_list_full() {
/// Shows branches without worktrees (⎇ symbol) alongside worktrees, plus CI status.
/// Uses narrower width (100 cols) to fit in doc site code blocks.
/// Output: tests/snapshots/integration__integration_tests__list__readme_example_list_branches.snap
-#[test]
+#[rstest]
fn test_readme_example_list_branches() {
let (repo, feature_api) = setup_readme_example_repo();
snapshot_readme_list_branches_full_from_dir(
@@ -1878,9 +1830,8 @@ fn test_readme_example_list_branches() {
);
}
-#[test]
-fn test_list_progressive_flag() {
- let mut repo = TestRepo::new();
+#[rstest]
+fn test_list_progressive_flag(mut repo: TestRepo) {
repo.add_worktree("feature-a");
repo.add_worktree("feature-b");
@@ -1889,19 +1840,16 @@ fn test_list_progressive_flag() {
snapshot_list_progressive("progressive_flag", &repo);
}
-#[test]
-fn test_list_no_progressive_flag() {
- let mut repo = TestRepo::new();
+#[rstest]
+fn test_list_no_progressive_flag(mut repo: TestRepo) {
repo.add_worktree("feature");
// Explicitly force buffered mode
snapshot_list_no_progressive("no_progressive_flag", &repo);
}
-#[test]
-fn test_list_progressive_with_branches() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_progressive_with_branches(mut repo: TestRepo) {
// Create worktrees
repo.add_worktree("feature-a");
@@ -1918,17 +1866,13 @@ fn test_list_progressive_with_branches() {
// Task DAG Mode Tests
// ============================================================================
-#[test]
-fn test_list_task_dag_single_worktree() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_list_task_dag_single_worktree(repo: TestRepo) {
snapshot_list_progressive("task_dag_single_worktree", &repo);
}
-#[test]
-fn test_list_task_dag_multiple_worktrees() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_task_dag_multiple_worktrees(mut repo: TestRepo) {
repo.add_worktree("feature-a");
repo.add_worktree("feature-b");
repo.add_worktree("feature-c");
@@ -1936,10 +1880,8 @@ fn test_list_task_dag_multiple_worktrees() {
snapshot_list_progressive("task_dag_multiple_worktrees", &repo);
}
-#[test]
-fn test_list_task_dag_full_with_diffs() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_task_dag_full_with_diffs(mut repo: TestRepo) {
// Create worktree with changes
let feature_a = repo.add_worktree("feature-a");
std::fs::write(feature_a.join("new.txt"), "content").unwrap();
@@ -1963,9 +1905,8 @@ fn test_list_task_dag_full_with_diffs() {
snapshot_list_progressive_full("task_dag_full_with_diffs", &repo);
}
-#[test]
-fn test_list_task_dag_with_upstream() {
- let mut repo = TestRepo::new();
+#[rstest]
+fn test_list_task_dag_with_upstream(mut repo: TestRepo) {
repo.commit("Initial commit on main");
repo.setup_remote("main");
@@ -2000,10 +1941,8 @@ fn test_list_task_dag_with_upstream() {
snapshot_list_progressive_full("task_dag_with_upstream", &repo);
}
-#[test]
-fn test_list_task_dag_many_worktrees() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_task_dag_many_worktrees(mut repo: TestRepo) {
// Create 10 worktrees to test parallel processing
for i in 1..=10 {
repo.add_worktree(&format!("feature-{}", i));
@@ -2012,10 +1951,8 @@ fn test_list_task_dag_many_worktrees() {
snapshot_list_progressive("task_dag_many_worktrees", &repo);
}
-#[test]
-fn test_list_task_dag_with_locked_worktree() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_task_dag_with_locked_worktree(mut repo: TestRepo) {
repo.add_worktree("normal");
repo.add_worktree("locked");
repo.lock_worktree("locked", Some("Testing task DAG with locked worktree"));
@@ -2023,19 +1960,17 @@ fn test_list_task_dag_with_locked_worktree() {
snapshot_list_progressive("task_dag_with_locked", &repo);
}
-#[test]
-fn test_list_task_dag_detached_head() {
- let repo = TestRepo::new();
+#[rstest]
+fn test_list_task_dag_detached_head(repo: TestRepo) {
repo.detach_head();
snapshot_list_progressive("task_dag_detached_head", &repo);
}
-#[test]
-fn test_list_task_dag_ordering_stability() {
+#[rstest]
+fn test_list_task_dag_ordering_stability(mut repo: TestRepo) {
// Test that task_dag mode produces same ordering as buffered mode
// Regression test for progressive rendering order instability
- let mut repo = TestRepo::new();
let current_path = setup_timestamped_worktrees(&mut repo);
// Run from feature-current worktree
@@ -2047,8 +1982,8 @@ fn test_list_task_dag_ordering_stability() {
);
}
-#[test]
-fn test_list_progressive_vs_buffered_identical_data() {
+#[rstest]
+fn test_list_progressive_vs_buffered_identical_data(mut repo: TestRepo) {
// Critical test: Verify that progressive and buffered modes collect identical data
// despite using different rendering strategies (real-time UI vs collect-then-print).
// This ensures consolidation on task DAG data collection works correctly.
@@ -2058,8 +1993,6 @@ fn test_list_progressive_vs_buffered_identical_data() {
// - Buffered mode renders headers after data collection (uses actual widths)
// - The DATA must be identical, but table formatting may differ slightly
- let mut repo = TestRepo::new();
-
// Create varied worktrees to test multiple data points
repo.add_worktree("feature-a");
repo.add_worktree("feature-b");
@@ -2105,10 +2038,8 @@ fn test_list_progressive_vs_buffered_identical_data() {
);
}
-#[test]
-fn test_list_with_c_flag() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_with_c_flag(mut repo: TestRepo) {
// Create some worktrees
repo.add_worktree("feature-a");
repo.add_worktree("feature-b");
@@ -2126,10 +2057,8 @@ fn test_list_with_c_flag() {
});
}
-#[test]
-fn test_list_large_diffs_alignment() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_large_diffs_alignment(mut repo: TestRepo) {
// Worktree with large uncommitted changes and ahead commits
// Use a longer branch name similar to user's "wli-sequence" to trigger column width
let large_wt = repo.add_worktree("feature-changes");
@@ -2233,10 +2162,8 @@ fn test_list_large_diffs_alignment() {
snapshot_list("large_diffs_alignment", &repo);
}
-#[test]
-fn test_list_status_column_padding_with_emoji() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_list_status_column_padding_with_emoji(mut repo: TestRepo) {
// Create worktree matching user's exact scenario: "wli-sequence"
let wli_seq = repo.add_worktree("wli-sequence");
@@ -2336,12 +2263,11 @@ fn test_list_status_column_padding_with_emoji() {
snapshot_list("status_column_padding_emoji", &repo);
}
-#[test]
-fn test_list_maximum_working_tree_symbols() {
+#[rstest]
+fn test_list_maximum_working_tree_symbols(mut repo: TestRepo) {
// Test that all 5 working tree symbols can appear simultaneously:
// ? (untracked), ! (modified), + (staged), » (renamed), ✘ (deleted)
// This verifies the maximum width of the working_tree position (5 chars)
- let mut repo = TestRepo::new();
let feature = repo.add_worktree("feature");
@@ -2400,12 +2326,11 @@ fn test_list_maximum_working_tree_symbols() {
snapshot_list("maximum_working_tree_symbols", &repo);
}
-#[test]
-fn test_list_maximum_status_with_git_operation() {
+#[rstest]
+fn test_list_maximum_status_with_git_operation(mut repo: TestRepo) {
// Test maximum status symbols including git operation (rebase/merge):
// ?!+ (working_tree) + = (conflicts) + ↻ (rebase) + ↕ (diverged) + ⊠ (locked) + 🤖 (user marker)
// This pushes the Status column to ~10-11 chars of actual content
- let mut repo = TestRepo::new();
// Create initial commit with a file that will conflict
std::fs::write(
@@ -2516,12 +2441,11 @@ fn test_list_maximum_status_with_git_operation() {
});
}
-#[test]
-fn test_list_maximum_status_symbols() {
+#[rstest]
+fn test_list_maximum_status_symbols(mut repo: TestRepo) {
// Test the maximum status symbols possible:
// ?!+»✘ (5) + ⚠ (1) + ⊠ (1) + ↕ (1) + ⇅ (1) + 🤖 (2) = 11 chars
// Missing: ✖ (actual conflicts), ↻ (git operation - can't have with divergence), ◇ (bare), ⚠ (prunable)
- let mut repo = TestRepo::new();
// Create initial commit on main with shared files
std::fs::write(repo.root_path().join("shared.txt"), "original").unwrap();
@@ -2682,9 +2606,8 @@ fn test_list_maximum_status_symbols() {
});
}
-#[test]
-fn test_list_warns_when_default_branch_missing_worktree() {
- let repo = TestRepo::new();
+#[rstest]
+fn test_list_warns_when_default_branch_missing_worktree(repo: TestRepo) {
// Move primary worktree off the default branch so no worktree holds it
repo.switch_primary_to("develop");
diff --git a/tests/integration_tests/merge.rs b/tests/integration_tests/merge.rs
index 516ac1a88..296aebc2b 100644
--- a/tests/integration_tests/merge.rs
+++ b/tests/integration_tests/merge.rs
@@ -1,7 +1,11 @@
-use crate::common::{TestRepo, make_snapshot_cmd, setup_snapshot_settings};
+use crate::common::{
+ TestRepo, make_snapshot_cmd, merge_scenario, merge_scenario_multi_commit, repo,
+ setup_snapshot_settings,
+};
use insta_cmd::assert_cmd_snapshot;
+use rstest::rstest;
use std::fs;
-use std::path::Path;
+use std::path::{Path, PathBuf};
use std::process::Command;
/// Helper to create snapshot with normalized paths
@@ -40,104 +44,16 @@ fn snapshot_merge_with_env(
});
}
-/// Standard merge test setup: creates repo with main worktree and feature worktree with one commit.
-/// Returns (repo, feature_wt_path).
-///
-/// Note: No remote is set up - merge works with local branches only. Tests that
-/// specifically need remote behavior should call `repo.setup_remote()` explicitly.
-fn setup_merge_scenario() -> (TestRepo, std::path::PathBuf) {
- let mut repo = TestRepo::new();
-
- // Create a worktree for main
- let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["worktree", "add", main_wt.to_str().unwrap(), "main"])
- .current_dir(repo.root_path())
- .output()
- .unwrap();
-
- // Create a feature worktree and make a commit
- let feature_wt = repo.add_worktree("feature");
- std::fs::write(feature_wt.join("feature.txt"), "feature content").unwrap();
-
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["add", "feature.txt"])
- .current_dir(&feature_wt)
- .output()
- .unwrap();
-
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["commit", "-m", "Add feature file"])
- .current_dir(&feature_wt)
- .output()
- .unwrap();
-
- (repo, feature_wt)
-}
-
-/// Merge test setup with multiple commits on feature branch.
-/// Returns (repo, feature_wt_path).
-fn setup_merge_scenario_multi_commit() -> (TestRepo, std::path::PathBuf) {
- let mut repo = TestRepo::new();
-
- // Create a worktree for main
- let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["worktree", "add", main_wt.to_str().unwrap(), "main"])
- .current_dir(repo.root_path())
- .output()
- .unwrap();
-
- // Create a feature worktree and make multiple commits
- let feature_wt = repo.add_worktree("feature");
-
- std::fs::write(feature_wt.join("file1.txt"), "content 1").unwrap();
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["add", "file1.txt"])
- .current_dir(&feature_wt)
- .output()
- .unwrap();
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["commit", "-m", "feat: add file 1"])
- .current_dir(&feature_wt)
- .output()
- .unwrap();
-
- std::fs::write(feature_wt.join("file2.txt"), "content 2").unwrap();
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["add", "file2.txt"])
- .current_dir(&feature_wt)
- .output()
- .unwrap();
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["commit", "-m", "feat: add file 2"])
- .current_dir(&feature_wt)
- .output()
- .unwrap();
-
- (repo, feature_wt)
-}
-
-#[test]
-fn test_merge_fast_forward() {
- let (repo, feature_wt) = setup_merge_scenario();
+#[rstest]
+fn test_merge_fast_forward(merge_scenario: (TestRepo, PathBuf)) {
+ let (repo, feature_wt) = merge_scenario;
// Merge feature into main
snapshot_merge("merge_fast_forward", &repo, &["main"], Some(&feature_wt));
}
-#[test]
-fn test_merge_when_primary_not_on_default_but_default_has_worktree() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_when_primary_not_on_default_but_default_has_worktree(mut repo: TestRepo) {
// Move the primary worktree off main
repo.switch_primary_to("develop");
@@ -170,9 +86,9 @@ fn test_merge_when_primary_not_on_default_but_default_has_worktree() {
);
}
-#[test]
-fn test_merge_with_no_remove_flag() {
- let (repo, feature_wt) = setup_merge_scenario();
+#[rstest]
+fn test_merge_with_no_remove_flag(merge_scenario: (TestRepo, PathBuf)) {
+ let (repo, feature_wt) = merge_scenario;
// Merge with --no-remove flag (should not finish worktree)
snapshot_merge(
@@ -183,18 +99,14 @@ fn test_merge_with_no_remove_flag() {
);
}
-#[test]
-fn test_merge_already_on_target() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_already_on_target(repo: TestRepo) {
// Already on main branch (repo root)
snapshot_merge("merge_already_on_target", &repo, &[], None);
}
-#[test]
-fn test_merge_dirty_working_tree() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_dirty_working_tree(mut repo: TestRepo) {
// Create a feature worktree with uncommitted changes
let feature_wt = repo.add_worktree("feature");
std::fs::write(feature_wt.join("dirty.txt"), "uncommitted content").unwrap();
@@ -208,10 +120,8 @@ fn test_merge_dirty_working_tree() {
);
}
-#[test]
-fn test_merge_not_fast_forward() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_not_fast_forward(mut repo: TestRepo) {
// Create commits in both branches
// Add commit to main (repo root)
std::fs::write(repo.root_path().join("main.txt"), "main content").unwrap();
@@ -260,10 +170,8 @@ fn test_merge_not_fast_forward() {
/// Test that `wt merge --no-commit` shows merge-context hint when main has newer commits.
/// The --no-commit flag skips the rebase step, so the push fails with not-fast-forward error.
/// The hint should say "Run 'wt merge' again" (not "Use 'wt merge'").
-#[test]
-fn test_merge_no_commit_not_fast_forward() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_no_commit_not_fast_forward(repo: TestRepo) {
// Get the initial commit SHA to create feature branch from there
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
@@ -336,10 +244,8 @@ fn test_merge_no_commit_not_fast_forward() {
);
}
-#[test]
-fn test_merge_rebase_conflict() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_rebase_conflict(repo: TestRepo) {
// Create a shared file
std::fs::write(repo.root_path().join("shared.txt"), "initial content\n").unwrap();
@@ -425,26 +331,24 @@ fn test_merge_rebase_conflict() {
snapshot_merge("merge_rebase_conflict", &repo, &["main"], Some(&feature_wt));
}
-#[test]
-fn test_merge_to_default_branch() {
- let (repo, feature_wt) = setup_merge_scenario();
+#[rstest]
+fn test_merge_to_default_branch(merge_scenario: (TestRepo, PathBuf)) {
+ let (repo, feature_wt) = merge_scenario;
// Merge without specifying target (should use default branch)
snapshot_merge("merge_to_default", &repo, &[], Some(&feature_wt));
}
-#[test]
-fn test_merge_with_caret_symbol() {
- let (repo, feature_wt) = setup_merge_scenario();
+#[rstest]
+fn test_merge_with_caret_symbol(merge_scenario: (TestRepo, PathBuf)) {
+ let (repo, feature_wt) = merge_scenario;
// Merge using ^ symbol (should resolve to default branch)
snapshot_merge("merge_with_caret", &repo, &["^"], Some(&feature_wt));
}
-#[test]
-fn test_merge_error_detached_head() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_error_detached_head(repo: TestRepo) {
// Detach HEAD in the repo
repo.detach_head();
@@ -457,10 +361,8 @@ fn test_merge_error_detached_head() {
);
}
-#[test]
-fn test_merge_squash_deterministic() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_squash_deterministic(mut repo: TestRepo) {
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
let mut cmd = Command::new("git");
@@ -524,10 +426,8 @@ fn test_merge_squash_deterministic() {
);
}
-#[test]
-fn test_merge_squash_with_llm() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_squash_with_llm(mut repo: TestRepo) {
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
let mut cmd = Command::new("git");
@@ -581,10 +481,8 @@ args = ["-c", "cat >/dev/null && echo 'feat: implement user authentication syste
snapshot_merge("merge_squash_with_llm", &repo, &["main"], Some(&feature_wt));
}
-#[test]
-fn test_merge_squash_llm_command_not_found() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_squash_llm_command_not_found(mut repo: TestRepo) {
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
let mut cmd = Command::new("git");
@@ -638,10 +536,9 @@ fn test_merge_squash_llm_command_not_found() {
);
}
-#[test]
-fn test_merge_squash_llm_error() {
+#[rstest]
+fn test_merge_squash_llm_error(mut repo: TestRepo) {
// Test that LLM command errors show proper gutter formatting with full command
- let mut repo = TestRepo::new();
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -704,10 +601,8 @@ args = ["-c", "cat > /dev/null; echo 'Error: connection refused' >&2 && exit 1"]
);
}
-#[test]
-fn test_merge_squash_single_commit() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_squash_single_commit(mut repo: TestRepo) {
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
let mut cmd = Command::new("git");
@@ -743,9 +638,9 @@ fn test_merge_squash_single_commit() {
);
}
-#[test]
-fn test_merge_no_squash() {
- let (repo, feature_wt) = setup_merge_scenario_multi_commit();
+#[rstest]
+fn test_merge_no_squash(merge_scenario_multi_commit: (TestRepo, PathBuf)) {
+ let (repo, feature_wt) = merge_scenario_multi_commit;
// Merge with --no-squash - should NOT squash the commits
snapshot_merge(
@@ -756,10 +651,8 @@ fn test_merge_no_squash() {
);
}
-#[test]
-fn test_merge_squash_empty_changes() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_squash_empty_changes(mut repo: TestRepo) {
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
let mut cmd = Command::new("git");
@@ -830,10 +723,8 @@ fn test_merge_squash_empty_changes() {
);
}
-#[test]
-fn test_merge_auto_commit_deterministic() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_auto_commit_deterministic(mut repo: TestRepo) {
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
let mut cmd = Command::new("git");
@@ -873,10 +764,8 @@ fn test_merge_auto_commit_deterministic() {
);
}
-#[test]
-fn test_merge_auto_commit_with_llm() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_auto_commit_with_llm(mut repo: TestRepo) {
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
let mut cmd = Command::new("git");
@@ -925,9 +814,9 @@ args = ["-c", "cat >/dev/null && echo 'fix: improve auth validation logic'"]
);
}
-#[test]
-fn test_merge_auto_commit_and_squash() {
- let (repo, feature_wt) = setup_merge_scenario_multi_commit();
+#[rstest]
+fn test_merge_auto_commit_and_squash(merge_scenario_multi_commit: (TestRepo, PathBuf)) {
+ let (repo, feature_wt) = merge_scenario_multi_commit;
// Add uncommitted tracked changes
std::fs::write(feature_wt.join("file1.txt"), "updated content 1").unwrap();
@@ -950,10 +839,8 @@ args = ["-c", "cat >/dev/null && echo 'fix: update file 1 content'"]
);
}
-#[test]
-fn test_merge_with_untracked_files() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_with_untracked_files(mut repo: TestRepo) {
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
let mut cmd = Command::new("git");
@@ -998,10 +885,8 @@ fn test_merge_with_untracked_files() {
/// Skipped on Windows: snapshot output differs due to shell/path differences.
#[cfg_attr(windows, ignore)]
-#[test]
-fn test_merge_pre_merge_command_success() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_pre_merge_command_success(mut repo: TestRepo) {
// Create project config with pre-merge command
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -1047,10 +932,8 @@ fn test_merge_pre_merge_command_success() {
/// Skipped on Windows: snapshot output differs due to shell/path differences.
#[cfg_attr(windows, ignore)]
-#[test]
-fn test_merge_pre_merge_command_failure() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_pre_merge_command_failure(mut repo: TestRepo) {
// Create project config with failing pre-merge command
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -1094,10 +977,8 @@ fn test_merge_pre_merge_command_failure() {
);
}
-#[test]
-fn test_merge_pre_merge_command_no_hooks() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_pre_merge_command_no_hooks(mut repo: TestRepo) {
// Create project config with failing pre-merge command
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -1143,10 +1024,8 @@ fn test_merge_pre_merge_command_no_hooks() {
/// Skipped on Windows: snapshot output differs due to shell/path differences.
#[cfg_attr(windows, ignore)]
-#[test]
-fn test_merge_pre_merge_command_named() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_pre_merge_command_named(mut repo: TestRepo) {
// Create project config with named pre-merge commands
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -1201,10 +1080,8 @@ test = "exit 0"
/// Skipped on Windows: snapshot output differs due to shell/path differences.
#[cfg_attr(windows, ignore)]
-#[test]
-fn test_merge_post_merge_command_success() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_post_merge_command_success(mut repo: TestRepo) {
// Create project config with post-merge command that writes a marker file
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -1265,10 +1142,8 @@ fn test_merge_post_merge_command_success() {
);
}
-#[test]
-fn test_merge_post_merge_command_skipped_with_no_verify() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_post_merge_command_skipped_with_no_verify(mut repo: TestRepo) {
// Create project config with post-merge command that writes a marker file
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -1325,10 +1200,8 @@ fn test_merge_post_merge_command_skipped_with_no_verify() {
/// Skipped on Windows: snapshot output differs due to shell/path differences.
#[cfg_attr(windows, ignore)]
-#[test]
-fn test_merge_post_merge_command_failure() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_post_merge_command_failure(mut repo: TestRepo) {
// Create project config with failing post-merge command
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -1374,10 +1247,8 @@ fn test_merge_post_merge_command_failure() {
/// Skipped on Windows: snapshot output differs due to shell/path differences.
#[cfg_attr(windows, ignore)]
-#[test]
-fn test_merge_post_merge_command_named() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_post_merge_command_named(mut repo: TestRepo) {
// Create project config with named post-merge commands
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -1443,10 +1314,9 @@ deploy = "echo 'Deploying branch {{ branch }}' > deploy.txt"
/// Skipped on Windows: snapshot output differs due to shell/path differences.
#[cfg_attr(windows, ignore)]
-#[test]
-fn test_merge_post_merge_runs_with_nothing_to_merge() {
+#[rstest]
+fn test_merge_post_merge_runs_with_nothing_to_merge(mut repo: TestRepo) {
// Verify post-merge hooks run even when there's nothing to merge
- let mut repo = TestRepo::new();
// Create project config with post-merge command
let config_dir = repo.root_path().join(".config");
@@ -1489,10 +1359,9 @@ fn test_merge_post_merge_runs_with_nothing_to_merge() {
/// Skipped on Windows: snapshot output differs due to shell/path differences.
#[cfg_attr(windows, ignore)]
-#[test]
-fn test_merge_post_merge_runs_from_main_branch() {
+#[rstest]
+fn test_merge_post_merge_runs_from_main_branch(repo: TestRepo) {
// Verify post-merge hooks run when merging from main to main (nothing to do)
- let repo = TestRepo::new();
// Create project config with post-merge command
let config_dir = repo.root_path().join(".config");
@@ -1523,10 +1392,8 @@ fn test_merge_post_merge_runs_from_main_branch() {
/// Skipped on Windows: snapshot output differs due to shell/path differences.
#[cfg_attr(windows, ignore)]
-#[test]
-fn test_merge_pre_commit_command_success() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_pre_commit_command_success(mut repo: TestRepo) {
// Create project config with pre-commit command
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -1562,10 +1429,8 @@ fn test_merge_pre_commit_command_success() {
/// Skipped on Windows: snapshot output differs due to shell/path differences.
#[cfg_attr(windows, ignore)]
-#[test]
-fn test_merge_pre_commit_command_failure() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_pre_commit_command_failure(mut repo: TestRepo) {
// Create project config with failing pre-commit command
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -1597,10 +1462,8 @@ fn test_merge_pre_commit_command_failure() {
/// Skipped on Windows: snapshot output differs due to shell/path differences.
#[cfg_attr(windows, ignore)]
-#[test]
-fn test_merge_pre_squash_command_success() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_pre_squash_command_success(mut repo: TestRepo) {
// Create project config with pre-commit command (used for both squash and no-squash)
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -1650,10 +1513,8 @@ fn test_merge_pre_squash_command_success() {
/// Skipped on Windows: snapshot output differs due to shell/path differences.
#[cfg_attr(windows, ignore)]
-#[test]
-fn test_merge_pre_squash_command_failure() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_pre_squash_command_failure(mut repo: TestRepo) {
// Create project config with failing pre-commit command (used for both squash and no-squash)
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -1697,9 +1558,8 @@ fn test_merge_pre_squash_command_failure() {
);
}
-#[test]
-fn test_merge_no_remote() {
- let mut repo = TestRepo::new();
+#[rstest]
+fn test_merge_no_remote(mut repo: TestRepo) {
// Deliberately NOT calling setup_remote to test the error case
// Create a feature worktree and make a commit
@@ -1737,11 +1597,9 @@ fn test_merge_no_remote() {
/// Switch output: tests/snapshots/integration__integration_tests__merge__readme_example_simple_switch.snap
///
/// Skipped on Windows: Uses Unix shell commands (chmod, echo) for mock command scripts.
-#[test]
+#[rstest]
#[cfg_attr(windows, ignore)]
-fn test_readme_example_simple() {
- let repo = TestRepo::new();
-
+fn test_readme_example_simple(repo: TestRepo) {
// Snapshot the switch --create command (runs from bare repo)
snapshot_switch(
"readme_example_simple_switch",
@@ -1794,11 +1652,9 @@ pub fn refresh(refresh_token: &str) -> String {
/// Source: tests/snapshots/integration__integration_tests__merge__readme_example_complex.snap
///
/// Skipped on Windows: Uses Unix shell commands (chmod, echo) for mock command scripts.
-#[test]
+#[rstest]
#[cfg_attr(windows, ignore)]
-fn test_readme_example_complex() {
- let mut repo = TestRepo::new();
-
+fn test_readme_example_complex(mut repo: TestRepo) {
// Create project config with multiple hooks
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -2032,11 +1888,9 @@ command = "{}"
/// Source: tests/snapshots/integration__integration_tests__merge__readme_example_hooks_post_create.snap
///
/// Skipped on Windows: Uses Unix shell commands (chmod, echo) for mock command scripts.
-#[test]
+#[rstest]
#[cfg_attr(windows, ignore)]
-fn test_readme_example_hooks_post_create() {
- let repo = TestRepo::new();
-
+fn test_readme_example_hooks_post_create(repo: TestRepo) {
// Create project config with post-create and post-start hooks
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -2119,11 +1973,9 @@ fi
/// Source: tests/snapshots/integration__integration_tests__merge__readme_example_hooks_pre_merge.snap
///
/// Skipped on Windows: Uses Unix shell commands (chmod, echo) for mock command scripts.
-#[test]
+#[rstest]
#[cfg_attr(windows, ignore)]
-fn test_readme_example_hooks_pre_merge() {
- let mut repo = TestRepo::new();
-
+fn test_readme_example_hooks_pre_merge(mut repo: TestRepo) {
// Create project config with pre-merge hooks
let config_dir = repo.root_path().join(".config");
fs::create_dir_all(&config_dir).unwrap();
@@ -2374,10 +2226,8 @@ command = "{}"
);
}
-#[test]
-fn test_merge_no_commit_with_clean_tree() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_no_commit_with_clean_tree(mut repo: TestRepo) {
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
let mut cmd = Command::new("git");
@@ -2430,10 +2280,8 @@ fn test_merge_no_commit_with_clean_tree() {
});
}
-#[test]
-fn test_merge_no_commit_with_dirty_tree() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_no_commit_with_dirty_tree(mut repo: TestRepo) {
// Create a feature worktree with a commit
let feature_wt = repo.add_worktree("feature");
fs::write(feature_wt.join("committed.txt"), "committed content").unwrap();
@@ -2473,10 +2321,8 @@ fn test_merge_no_commit_with_dirty_tree() {
});
}
-#[test]
-fn test_merge_no_commit_no_squash_no_remove_redundant() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_no_commit_no_squash_no_remove_redundant(mut repo: TestRepo) {
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
let mut cmd = Command::new("git");
@@ -2529,10 +2375,8 @@ fn test_merge_no_commit_no_squash_no_remove_redundant() {
});
}
-#[test]
-fn test_merge_no_commits() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_no_commits(mut repo: TestRepo) {
// Create a worktree for main
repo.add_main_worktree();
@@ -2543,10 +2387,8 @@ fn test_merge_no_commits() {
snapshot_merge("merge_no_commits", &repo, &["main"], Some(&feature_wt));
}
-#[test]
-fn test_merge_no_commits_with_changes() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_no_commits_with_changes(mut repo: TestRepo) {
// Create a worktree for main
repo.add_main_worktree();
@@ -2563,11 +2405,10 @@ fn test_merge_no_commits_with_changes() {
);
}
-#[test]
-fn test_merge_rebase_fast_forward() {
+#[rstest]
+fn test_merge_rebase_fast_forward(mut repo: TestRepo) {
// Test fast-forward case: branch has no commits, main moved ahead
// Should show "Fast-forwarded to main" without progress message
- let mut repo = TestRepo::new();
// Create a feature worktree with NO commits (just branched from main)
let feature_wt = repo.add_worktree("fast-forward-test");
@@ -2598,11 +2439,10 @@ fn test_merge_rebase_fast_forward() {
);
}
-#[test]
-fn test_merge_rebase_true_rebase() {
+#[rstest]
+fn test_merge_rebase_true_rebase(mut repo: TestRepo) {
// Test true rebase case: branch has commits and main moved ahead
// Should show "Rebasing onto main..." progress message
- let mut repo = TestRepo::new();
// Create a feature worktree with a commit
let feature_wt = repo.add_worktree("true-rebase-test");
@@ -2648,10 +2488,8 @@ fn test_merge_rebase_true_rebase() {
);
}
-#[test]
-fn test_merge_primary_on_different_branch() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_primary_on_different_branch(mut repo: TestRepo) {
repo.switch_primary_to("develop");
assert_eq!(repo.current_branch(), "develop");
@@ -2684,10 +2522,8 @@ fn test_merge_primary_on_different_branch() {
assert_eq!(repo.current_branch(), "develop");
}
-#[test]
-fn test_merge_primary_on_different_branch_dirty() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_primary_on_different_branch_dirty(mut repo: TestRepo) {
// Make main and develop diverge - modify file.txt on main
fs::write(repo.root_path().join("file.txt"), "main version").unwrap();
@@ -2753,10 +2589,8 @@ fn test_merge_primary_on_different_branch_dirty() {
);
}
-#[test]
-fn test_merge_race_condition_commit_after_push() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_race_condition_commit_after_push(mut repo: TestRepo) {
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
let mut cmd = Command::new("git");
@@ -2859,10 +2693,8 @@ fn test_merge_race_condition_commit_after_push() {
);
}
-#[test]
-fn test_merge_to_non_default_target() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_to_non_default_target(repo: TestRepo) {
// Switch back to main and add a commit there
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
@@ -2973,10 +2805,8 @@ fn test_merge_to_non_default_target() {
);
}
-#[test]
-fn test_merge_squash_with_working_tree_creates_backup() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_merge_squash_with_working_tree_creates_backup(mut repo: TestRepo) {
// Create a worktree for main
repo.add_main_worktree();
@@ -3047,18 +2877,19 @@ fn test_merge_squash_with_working_tree_creates_backup() {
);
}
-#[test]
-fn test_merge_when_default_branch_missing_worktree() {
- let repo = TestRepo::new();
+#[rstest]
+fn test_merge_when_default_branch_missing_worktree(repo: TestRepo) {
// Move primary off default branch so no worktree holds it
repo.switch_primary_to("develop");
snapshot_merge("merge_default_branch_missing_worktree", &repo, &[], None);
}
-#[test]
-fn test_merge_does_not_permanently_set_receive_deny_current_branch() {
- let (repo, feature_wt) = setup_merge_scenario();
+#[rstest]
+fn test_merge_does_not_permanently_set_receive_deny_current_branch(
+ merge_scenario: (TestRepo, PathBuf),
+) {
+ let (repo, feature_wt) = merge_scenario;
// Explicitly set config to "refuse" - this would block pushes to checked-out branches
let mut cmd = Command::new("git");
@@ -3137,10 +2968,8 @@ fn snapshot_step_commit_with_env(
});
}
-#[test]
-fn test_step_squash_with_no_verify_flag() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_step_squash_with_no_verify_flag(mut repo: TestRepo) {
// Create a feature worktree with multiple commits
let feature_wt = repo.add_worktree("feature");
@@ -3197,10 +3026,8 @@ fn test_step_squash_with_no_verify_flag() {
);
}
-#[test]
-fn test_step_squash_with_stage_tracked_flag() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_step_squash_with_stage_tracked_flag(mut repo: TestRepo) {
let feature_wt = repo.add_worktree("feature");
fs::write(feature_wt.join("file1.txt"), "content 1").expect("Failed to write file");
@@ -3249,10 +3076,8 @@ fn test_step_squash_with_stage_tracked_flag() {
);
}
-#[test]
-fn test_step_squash_with_both_flags() {
- let mut repo = TestRepo::new();
-
+#[rstest]
+fn test_step_squash_with_both_flags(mut repo: TestRepo) {
let feature_wt = repo.add_worktree("feature");
// Add a pre-commit hook so --no-verify has something to skip
@@ -3310,10 +3135,9 @@ fn test_step_squash_with_both_flags() {
);
}
-#[test]
-fn test_step_squash_no_commits() {
+#[rstest]
+fn test_step_squash_no_commits(mut repo: TestRepo) {
// Test "nothing to squash; no commits ahead" message
- let mut repo = TestRepo::new();
// Create a feature worktree but don't add any commits
let feature_wt = repo.add_worktree("feature");
@@ -3321,10 +3145,9 @@ fn test_step_squash_no_commits() {
snapshot_step_squash_with_env("step_squash_no_commits", &repo, &[], Some(&feature_wt), &[]);
}
-#[test]
-fn test_step_squash_single_commit() {
+#[rstest]
+fn test_step_squash_single_commit(mut repo: TestRepo) {
// Test "nothing to squash; already a single commit" message
- let mut repo = TestRepo::new();
// Create a feature worktree with exactly one commit
let feature_wt = repo.add_worktree("feature");
@@ -3352,10 +3175,8 @@ fn test_step_squash_single_commit() {
);
}
-#[test]
-fn test_step_commit_with_no_verify_flag() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_step_commit_with_no_verify_flag(repo: TestRepo) {
// Add a pre-commit hook so --no-verify has something to skip
fs::create_dir_all(repo.root_path().join(".config")).expect("Failed to create .config");
fs::write(
@@ -3378,10 +3199,8 @@ fn test_step_commit_with_no_verify_flag() {
);
}
-#[test]
-fn test_step_commit_with_stage_tracked_flag() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_step_commit_with_stage_tracked_flag(repo: TestRepo) {
fs::write(repo.root_path().join("tracked.txt"), "initial").expect("Failed to write file");
repo.commit("add tracked file");
@@ -3407,10 +3226,8 @@ fn test_step_commit_with_stage_tracked_flag() {
);
}
-#[test]
-fn test_step_commit_with_both_flags() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_step_commit_with_both_flags(repo: TestRepo) {
// Add a pre-commit hook so --no-verify has something to skip
fs::create_dir_all(repo.root_path().join(".config")).expect("Failed to create .config");
fs::write(
@@ -3436,10 +3253,8 @@ fn test_step_commit_with_both_flags() {
);
}
-#[test]
-fn test_step_commit_nothing_to_commit() {
- let repo = TestRepo::new();
-
+#[rstest]
+fn test_step_commit_nothing_to_commit(repo: TestRepo) {
// No changes made - commit should fail with "nothing to commit"
snapshot_step_commit_with_env(
"step_commit_nothing_to_commit",
@@ -3460,10 +3275,9 @@ fn test_step_commit_nothing_to_commit() {
// Error message snapshot tests
// =============================================================================
-#[test]
-fn test_merge_error_uncommitted_changes_with_no_commit() {
+#[rstest]
+fn test_merge_error_uncommitted_changes_with_no_commit(mut repo: TestRepo) {
// Tests the `uncommitted_changes()` error function when using --no-commit with dirty tree
- let mut repo = TestRepo::new();
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -3489,11 +3303,10 @@ fn test_merge_error_uncommitted_changes_with_no_commit() {
);
}
-#[test]
-fn test_merge_error_conflicting_changes_in_target() {
+#[rstest]
+fn test_merge_error_conflicting_changes_in_target(mut repo: TestRepo) {
// Tests the `conflicting_changes()` error function when target worktree has
// uncommitted changes that overlap with files being pushed
- let mut repo = TestRepo::new();
// Switch primary worktree off main so we can create a worktree for main
repo.switch_primary_to("develop");