worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

test: add integration tests for post-commit hook execution

Open worktrunk-bot opened this issue 8 months ago • 2 comments

Missing Coverage

The post-commit hook type was added in #1679 (hook rationalization) and is wired into wt step commit and wt step squash. However, there are no integration tests verifying that post-commit hooks actually execute after a commit.

Completion tests confirm the hook name appears in the CLI, but no test configures a post-commit hook, runs a commit operation, and verifies the hook ran.

Suggested Tests

Add tests in tests/integration_tests/user_hooks.rs (or a new file) that:

  1. Configure a post-commit hook that writes a marker file
  2. Run wt step commit
  3. Use wait_for_file to verify the hook ran
  4. Test failure behavior (background hook — should not affect exit code)

Similar pattern to existing user_post_merge_executes test.

worktrunk-bot avatar Mar 24 '26 06:03 worktrunk-bot

@worktrunk-bot fix

max-sixty avatar Mar 24 '26 07:03 max-sixty

Added integration tests for post-commit hook execution in #1711.

Three tests covering wt step commit:

  1. test_user_post_commit_hook_executes — configures a post-commit hook that writes a marker file, runs wt step commit, verifies the hook ran via wait_for_file_content
  2. test_user_post_commit_skipped_with_no_verify — verifies --no-verify skips post-commit hooks
  3. test_user_post_commit_failure_does_not_block_commit — verifies failing background hook doesn't affect exit code

One observation: post-commit hooks don't appear to fire during wt merge (when merge auto-commits dirty changes). The code path in CommitOptions::commit() spawns them, but the merge output shows no "Running post-commit" message. This might be worth a separate investigation.

worktrunk-bot avatar Mar 24 '26 08:03 worktrunk-bot