Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Test: fix user_pre_remove test to be cross-platform (#171)
Maximilian Roos12877262998f
diff --git a/tests/integration_tests/user_hooks.rs b/tests/integration_tests/user_hooks.rsindex 1907104cd..1cc3a6931 100644--- a/tests/integration_tests/user_hooks.rs+++ b/tests/integration_tests/user_hooks.rs@@ -436,19 +436,18 @@ fn snapshot_remove(test_name: &str, repo: &TestRepo, args: &[&str], cwd: Option<});}-/// Skipped on Windows: Uses /tmp path and file locking prevents worktree removal.#[rstest]-#[cfg_attr(windows, ignore)]fn test_user_pre_remove_hook_executes(mut repo: TestRepo) {// Create a worktree to removelet _feature_wt = repo.add_worktree("feature");// Write user config with pre-remove hook+ // Hook writes to parent dir (temp dir) since the worktree itself gets removedrepo.write_test_config(r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"[pre-remove]-cleanup = "echo 'USER_PRE_REMOVE_RAN' > /tmp/user_preremove_marker.txt"+cleanup = "echo 'USER_PRE_REMOVE_RAN' > ../user_preremove_marker.txt""#,);@@ -459,11 +458,13 @@ cleanup = "echo 'USER_PRE_REMOVE_RAN' > /tmp/user_preremove_marker.txt"Some(repo.root_path()),);- // Verify user hook ran (writes to /tmp since worktree is being removed)- let marker_file = std::path::Path::new("/tmp/user_preremove_marker.txt");+ // Verify user hook ran (writes to parent dir since worktree is being removed)+ let marker_file = repo+ .root_path()+ .parent()+ .unwrap()+ .join("user_preremove_marker.txt");assert!(marker_file.exists(), "User pre-remove hook should have run");- // Clean up- let _ = fs::remove_file(marker_file);}#[rstest]diff --git a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_executes.snap b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_executes.snapindex b1a30307d..53f9b1e96 100644--- a/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_executes.snap+++ b/tests/snapshots/integration__integration_tests__user_hooks__user_pre_remove_executes.snap@@ -7,6 +7,7 @@ info:- feature- "--force-delete"env:+ APPDATA: "[TEST_CONFIG_HOME]"CLICOLOR_FORCE: "1"COLUMNS: "150"GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"@@ -14,10 +15,14 @@ info:GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"GIT_CONFIG_SYSTEM: /dev/nullGIT_EDITOR: ""+ HOME: "[TEST_HOME]"LANG: CLC_ALL: C+ PATH: "[PATH]"SOURCE_DATE_EPOCH: "1735776000"+ USERPROFILE: "[TEST_HOME]"WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"---success: trueexit_code: 0@@ -25,5 +30,5 @@ exit_code: 0----- stderr -----🔄 [36mRunning user pre-remove [1mcleanup[22m:[39m-[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'USER_PRE_REMOVE_RAN'[0m[2m [0m[2m[36m>[0m[2m /tmp/user_preremove_marker.txt+[107m [0m [2m[0m[2m[34mecho[0m[2m [0m[2m[32m'USER_PRE_REMOVE_RAN'[0m[2m [0m[2m[36m>[0m[2m ../user_preremove_marker.txt[0m🔄 [36m[36mRemoving [1mfeature[22m worktree & branch in background (--force-delete)[39m[39m