mirror of
https://github.com/junegunn/fzf.git
synced 2025-12-13 20:36:25 +01:00
zsh foreign test (#4622)
* test(zsh): add test for C-r with foreign commands * ci: make docker command configurable via variable Allows using alternative container runtimes, e.g., DOCKER=podman make docker-test * test(zsh): use unique histfile for foreign commands test * test(zsh): use multi select in foreign test
This commit is contained in:
9
Makefile
9
Makefile
@@ -1,4 +1,5 @@
|
||||
GO ?= go
|
||||
DOCKER ?= docker
|
||||
GOOS ?= $(shell $(GO) env GOOS)
|
||||
|
||||
MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST)))
|
||||
@@ -192,12 +193,12 @@ bin/fzf: target/$(BINARY) | bin
|
||||
cp -f target/$(BINARY) bin/fzf
|
||||
|
||||
docker:
|
||||
docker build -t fzf-ubuntu .
|
||||
docker run -it fzf-ubuntu tmux
|
||||
$(DOCKER) build -t fzf-ubuntu .
|
||||
$(DOCKER) run -it fzf-ubuntu tmux
|
||||
|
||||
docker-test:
|
||||
docker build -t fzf-ubuntu .
|
||||
docker run -it fzf-ubuntu
|
||||
$(DOCKER) build -t fzf-ubuntu .
|
||||
$(DOCKER) run -it fzf-ubuntu
|
||||
|
||||
update:
|
||||
$(GO) get -u
|
||||
|
||||
@@ -540,6 +540,41 @@ class TestZsh < TestBase
|
||||
assert_equal ['cat <<EOF | wc -c', 'qux thud', 'EOF'], lines[-3..]
|
||||
end
|
||||
end
|
||||
|
||||
# NOTE: 'Perl/$history' won't see foreign cmds immediately, unlike 'awk/fc'.
|
||||
# Perl passes only because another cmd runs between mocking and triggering C-r
|
||||
# https://github.com/junegunn/fzf/issues/4061
|
||||
# https://zsh.org/mla/users/2024/msg00692.html
|
||||
test_perl_and_awk 'ctrl_r_foreign_commands' do
|
||||
histfile = "#{tempname}-foreign-hist"
|
||||
tmux.send_keys "HISTFILE=#{histfile}", :Enter
|
||||
tmux.prepare
|
||||
# SHARE_HISTORY picks up foreign commands; marked with * in fc
|
||||
tmux.send_keys 'setopt SHARE_HISTORY', :Enter
|
||||
tmux.prepare
|
||||
tmux.send_keys 'fzf_cmd_local', :Enter
|
||||
tmux.prepare
|
||||
# Mock foreign command (for testing only; don't edit your HISTFILE this way)
|
||||
tmux.send_keys "echo ': 0:0;fzf_cmd_foreign' >> $HISTFILE", :Enter
|
||||
tmux.prepare
|
||||
# Verify fc shows foreign command with asterisk
|
||||
tmux.send_keys 'fc -rl -1', :Enter
|
||||
tmux.until { |lines| assert lines.any? { |l| l.match?(/^\s*\d+\* fzf_cmd_foreign/) } }
|
||||
tmux.prepare
|
||||
# Test ctrl-r correctly extracts the foreign command
|
||||
tmux.send_keys 'C-r'
|
||||
tmux.until { |lines| assert_operator lines.match_count, :>, 0 }
|
||||
tmux.send_keys '^fzf_cmd_'
|
||||
tmux.until { |lines| assert_equal 2, lines.match_count }
|
||||
tmux.send_keys :BTab, :BTab
|
||||
tmux.until { |lines| assert_includes lines[-2], '(2)' }
|
||||
tmux.send_keys :Enter
|
||||
tmux.until do |lines|
|
||||
assert_equal ['fzf_cmd_foreign', 'fzf_cmd_local'], lines[-2..]
|
||||
end
|
||||
ensure
|
||||
FileUtils.rm_f(histfile)
|
||||
end
|
||||
end
|
||||
|
||||
class TestFish < TestBase
|
||||
|
||||
Reference in New Issue
Block a user