From ca51a57aed7c40e113d1e3e2219f2314fb1558a7 Mon Sep 17 00:00:00 2001 From: LangLangBart <92653266+LangLangBart@users.noreply.github.com> Date: Thu, 30 Jul 2026 17:15:49 +0200 Subject: [PATCH] test(zsh): verify chpwd fires once in alt-c widget --- test/test_shell_integration.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test_shell_integration.rb b/test/test_shell_integration.rb index c50164cc..c281cc89 100644 --- a/test/test_shell_integration.rb +++ b/test/test_shell_integration.rb @@ -965,6 +965,18 @@ class TestZsh < TestBase end end + # Duplicate 'chpwd' calls overcount visits => skews rank tracking tools (e.g. 'zoxide') + def test_alt_c_chpwd_hook_once + tmux.send_keys "chpwd() { echo 'chpwd hook fired' >&2 }", :Enter + tmux.prepare + tmux.send_keys :Escape, :c + tmux.until { |lines| assert_operator lines.match_count, :>, 0 } + tmux.send_keys :Enter + tmux.until do |lines| + assert_equal 1, lines.count { |l| l.include?('chpwd hook fired') } + end + end + # Helper function to run test with Perl and again with Awk def self.test_perl_and_awk(name, &block) define_method(:"test_#{name}") do