Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
test(hooks): pin that a source-scoped filter stays in its source (#3851)
Maximilian Roos8fd946546c53
diff --git a/tests/integration_tests/user_hooks.rs b/tests/integration_tests/user_hooks.rsindex 56f0ad3e9..40ccd1452 100644--- a/tests/integration_tests/user_hooks.rs+++ b/tests/integration_tests/user_hooks.rs@@ -2323,6 +2323,56 @@ fn test_hook_multiple_name_filters(repo: TestRepo) {);}+/// A source-scoped filter must not bleed its name into another source.+/// `wt hook pre-merge user:foo bar`, with user `foo`, project `foo`, and+/// project `bar` defined, runs user `foo` and project `bar` — but not project+/// `foo`, which the `user:foo` scope excludes even though the unscoped `bar`+/// admits the project source.+///+/// Each command writes a marker file rather than echoing. The announcement+/// prints a command's body before running it, so asserting on stdout would+/// pin which commands were selected rather than which ones ran.+#[rstest]+fn test_hook_source_scoped_filter_does_not_bleed_into_other_source(repo: TestRepo) {+ repo.write_test_config(+ r#"[pre-merge]+foo = "echo ran > user_foo.txt"+"#,+ );+ repo.write_project_config(+ r#"[pre-merge]+foo = "echo ran > project_foo.txt"+bar = "echo ran > project_bar.txt"+"#,+ );+ repo.commit("Add pre-merge hooks");++ let output = repo+ .wt_command()+ .args(["hook", "pre-merge", "user:foo", "bar", "--yes"])+ .output()+ .expect("Failed to run wt hook pre-merge");++ assert!(+ output.status.success(),+ "wt hook pre-merge failed: {}",+ String::from_utf8_lossy(&output.stderr)+ );++ assert!(+ repo.root_path().join("user_foo.txt").exists(),+ "user:foo should run the user's foo"+ );+ assert!(+ repo.root_path().join("project_bar.txt").exists(),+ "unscoped bar should run the project's bar"+ );+ assert!(+ !repo.root_path().join("project_foo.txt").exists(),+ "project foo must not run — user:foo is scoped to the user source"+ );+}+#[rstest]fn test_hook_multiple_name_filters_none_match(repo: TestRepo) {// Write project config with named hooks