Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Reduce post-start command sleep times for faster tests
Maximilian Roosc923421941e2
diff --git a/tests/integration_tests/e2e_shell_post_start.rs b/tests/integration_tests/e2e_shell_post_start.rsindex 3b87b4dd2..edef7dc57 100644--- a/tests/integration_tests/e2e_shell_post_start.rs+++ b/tests/integration_tests/e2e_shell_post_start.rs@@ -28,7 +28,7 @@ fn test_e2e_post_start_background_command(#[case] shell: &str) {fs::create_dir_all(&config_dir).expect("Failed to create .config dir");fs::write(config_dir.join("wt.toml"),- r#"post-start-command = "sleep 0.5 && echo 'Background task done' > bg_marker.txt""#,+ r#"post-start-command = "sleep 0.05 && echo 'Background task done' > bg_marker.txt""#,).expect("Failed to write config");@@ -40,7 +40,7 @@ fn test_e2e_post_start_background_command(#[case] shell: &str) {r#"worktree-path = "../{main-worktree}.{branch}"[projects."test-repo"]-approved-commands = ["sleep 0.5 && echo 'Background task done' > bg_marker.txt"]+approved-commands = ["sleep 0.05 && echo 'Background task done' > bg_marker.txt"]"#,).expect("Failed to write user config");@@ -71,8 +71,8 @@ approved-commands = ["sleep 0.5 && echo 'Background task done' > bg_marker.txt"]output);- // Wait for background command to complete- thread::sleep(Duration::from_secs(2));+ // Wait for background command to complete (command has sleep 0.05 + margin)+ thread::sleep(Duration::from_millis(150));// Verify background command actually ranlet worktree_path = repo@@ -143,8 +143,8 @@ fn test_bash_post_start_multiple_parallel_commands() {fs::write(config_dir.join("wt.toml"),r#"[post-start-command]-task1 = "sleep 0.5 && echo 'Task 1' > task1.txt"-task2 = "sleep 0.5 && echo 'Task 2' > task2.txt"+task1 = "sleep 0.05 && echo 'Task 1' > task1.txt"+task2 = "sleep 0.05 && echo 'Task 2' > task2.txt""#,).expect("Failed to write config");@@ -158,8 +158,8 @@ task2 = "sleep 0.5 && echo 'Task 2' > task2.txt"[projects."test-repo"]approved-commands = [- "sleep 0.5 && echo 'Task 1' > task1.txt",- "sleep 0.5 && echo 'Task 2' > task2.txt",+ "sleep 0.05 && echo 'Task 1' > task1.txt",+ "sleep 0.05 && echo 'Task 2' > task2.txt",]"#,)@@ -187,8 +187,8 @@ approved-commands = [output);- // Wait for background commands to complete- thread::sleep(Duration::from_secs(1));+ // Wait for background commands to complete (commands have sleep 0.05 + margin)+ thread::sleep(Duration::from_millis(150));// Verify both background commands ranlet worktree_path = repo@@ -290,7 +290,7 @@ fn test_fish_post_start_background() {fs::write(config_dir.join("wt.toml"),r#"[post-start-command]-fish_bg = "sleep 0.5 && echo 'Fish background done' > fish_bg.txt"+fish_bg = "sleep 0.05 && echo 'Fish background done' > fish_bg.txt""#,).expect("Failed to write config");@@ -303,7 +303,7 @@ fish_bg = "sleep 0.5 && echo 'Fish background done' > fish_bg.txt"r#"worktree-path = "../{main-worktree}.{branch}"[projects."test-repo"]-approved-commands = ["sleep 0.5 && echo 'Fish background done' > fish_bg.txt"]+approved-commands = ["sleep 0.05 && echo 'Fish background done' > fish_bg.txt"]"#,).expect("Failed to write test config");@@ -331,8 +331,8 @@ approved-commands = ["sleep 0.5 && echo 'Fish background done' > fish_bg.txt"]output);- // Wait for background command- thread::sleep(Duration::from_secs(1));+ // Wait for background command (command has sleep 0.05 + margin)+ thread::sleep(Duration::from_millis(150));// Verify background command ranlet worktree_path = repodiff --git a/tests/integration_tests/post_start_commands.rs b/tests/integration_tests/post_start_commands.rsindex 58d59d422..45e6fdfa8 100644--- a/tests/integration_tests/post_start_commands.rs+++ b/tests/integration_tests/post_start_commands.rs@@ -9,13 +9,14 @@ use std::time::Duration;// These allow time for background processes to complete and write output files/// Short wait for fast commands (simple echo statements)-const SLEEP_FAST_COMMAND: Duration = Duration::from_millis(500);+const SLEEP_FAST_COMMAND: Duration = Duration::from_millis(100);/// Standard wait for background commands with sleep/processing-const SLEEP_BACKGROUND_COMMAND: Duration = Duration::from_secs(1);+const SLEEP_BACKGROUND_COMMAND: Duration = Duration::from_millis(200);-/// Extended wait for commands that need extra time (e.g., in e2e shell tests)-const SLEEP_EXTENDED: Duration = Duration::from_secs(2);+/// Extended wait for commands that include explicit sleep in the command itself+/// (e.g., "sleep 0.1 && echo ..." requires at least 100ms + margin)+const SLEEP_EXTENDED: Duration = Duration::from_millis(250);/// Helper to create snapshot with normalized paths and SHAs///@@ -238,7 +239,7 @@ fn test_post_start_single_background_command() {// Create project config with a background commandrepo.write_project_config(- r#"post-start-command = "sleep 1 && echo 'Background task done' > background.txt""#,+ r#"post-start-command = "sleep 0.1 && echo 'Background task done' > background.txt""#,);repo.commit("Add background command");@@ -248,7 +249,7 @@ fn test_post_start_single_background_command() {r#"worktree-path = "../{main-worktree}.{branch}"[projects."test-repo"]-approved-commands = ["sleep 1 && echo 'Background task done' > background.txt"]+approved-commands = ["sleep 0.1 && echo 'Background task done' > background.txt"]"#,);@@ -329,7 +330,7 @@ fn test_both_post_create_and_post_start() {r#"post-create-command = "echo 'Setup done' > setup.txt"[post-start-command]-server = "sleep 0.5 && echo 'Server running' > server.txt"+server = "sleep 0.05 && echo 'Server running' > server.txt""#,);@@ -342,7 +343,7 @@ server = "sleep 0.5 && echo 'Server running' > server.txt"[projects."test-repo"]approved-commands = ["echo 'Setup done' > setup.txt",- "sleep 0.5 && echo 'Server running' > server.txt",+ "sleep 0.05 && echo 'Server running' > server.txt",]"#,);@@ -357,8 +358,8 @@ approved-commands = ["Post-create command should have completed before wt exits");- // Wait for background command- thread::sleep(SLEEP_BACKGROUND_COMMAND);+ // Wait for background command (command has sleep 0.05 + margin)+ thread::sleep(Duration::from_millis(150));// Server file should exist after background task completesassert!(diff --git a/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap b/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snapindex 998c052cb..aa8f3c6b6 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__both_create_and_start.snap@@ -17,7 +17,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp9MgCyO/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpJGcCK2/test-config.toml---success: trueexit_code: 0@@ -27,7 +27,7 @@ exit_code: 0β [32mCreated new worktree for [1m[32mfeature[0m[32m from [1m[32mmain[0m[32m at [1m[32m[REPO].feature[0m[0mπ‘ [2mTo enable automatic cd, run: wt config shell[0mπ [36mRunning post-start [1mserver[0m:[0m-[40m [0m [1m[34msleep[0m 0.5 [36m&&[0m [1m[34mecho[0m [32m'Server running'[0m [36m>[0m server.txt[0m+[40m [0m [1m[34msleep[0m 0.05 [36m&&[0m [1m[34mecho[0m [32m'Server running'[0m [36m>[0m server.txt[0m----- stderr -----[0mdiff --git a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snapindex c7d3a8eea..1865521d4 100644--- a/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap+++ b/tests/snapshots/integration__integration_tests__post_start_commands__post_start_single_background.snap@@ -17,7 +17,7 @@ info:LANG: CLC_ALL: CSOURCE_DATE_EPOCH: "1761609600"- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpivRQ5w/test-config.toml+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpg1VG2v/test-config.toml---success: trueexit_code: 0@@ -25,6 +25,6 @@ exit_code: 0β [32mCreated new worktree for [1m[32mfeature[0m[32m from [1m[32mmain[0m[32m at [1m[32m[REPO].feature[0m[0mπ‘ [2mTo enable automatic cd, run: wt config shell[0mπ [36mRunning post-start:[0m-[40m [0m [1m[34msleep[0m 1 [36m&&[0m [1m[34mecho[0m [32m'Background task done'[0m [36m>[0m background.txt[0m+[40m [0m [1m[34msleep[0m 0.1 [36m&&[0m [1m[34mecho[0m [32m'Background task done'[0m [36m>[0m background.txt[0m----- stderr -----