mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 03:19:01 +00:00
Fix test cases
We were not properly waiting for truthy-ness in until blocks.
Need Minitest with 21d9e804b6
This commit is contained in:
parent
d2d4d68585
commit
2166b4ca17
@ -1,6 +1,6 @@
|
|||||||
FROM archlinux/base:latest
|
FROM archlinux/base:latest
|
||||||
RUN pacman -Sy && pacman --noconfirm -S awk git tmux zsh fish ruby procps go make gcc
|
RUN pacman -Sy && pacman --noconfirm -S awk git tmux zsh fish ruby procps go make gcc
|
||||||
RUN gem install --no-document minitest
|
RUN gem install --no-document -v 5.14.2 minitest
|
||||||
RUN echo '. /usr/share/bash-completion/completions/git' >> ~/.bashrc
|
RUN echo '. /usr/share/bash-completion/completions/git' >> ~/.bashrc
|
||||||
RUN echo '. ~/.bashrc' >> ~/.bash_profile
|
RUN echo '. ~/.bashrc' >> ~/.bash_profile
|
||||||
|
|
||||||
|
@ -11,12 +11,13 @@ require 'tempfile'
|
|||||||
TEMPLATE = DATA.read
|
TEMPLATE = DATA.read
|
||||||
UNSETS = %w[
|
UNSETS = %w[
|
||||||
FZF_DEFAULT_COMMAND FZF_DEFAULT_OPTS
|
FZF_DEFAULT_COMMAND FZF_DEFAULT_OPTS
|
||||||
|
FZF_TMUX FZF_TMUX_OPTS
|
||||||
FZF_CTRL_T_COMMAND FZF_CTRL_T_OPTS
|
FZF_CTRL_T_COMMAND FZF_CTRL_T_OPTS
|
||||||
FZF_ALT_C_COMMAND
|
FZF_ALT_C_COMMAND
|
||||||
FZF_ALT_C_OPTS FZF_CTRL_R_OPTS
|
FZF_ALT_C_OPTS FZF_CTRL_R_OPTS
|
||||||
fish_history
|
fish_history
|
||||||
].freeze
|
].freeze
|
||||||
DEFAULT_TIMEOUT = 20
|
DEFAULT_TIMEOUT = 10
|
||||||
|
|
||||||
FILE = File.expand_path(__FILE__)
|
FILE = File.expand_path(__FILE__)
|
||||||
BASE = File.expand_path('..', __dir__)
|
BASE = File.expand_path('..', __dir__)
|
||||||
@ -26,7 +27,7 @@ FZF = "FZF_DEFAULT_OPTS= FZF_DEFAULT_COMMAND= #{BASE}/bin/fzf"
|
|||||||
def wait
|
def wait
|
||||||
since = Time.now
|
since = Time.now
|
||||||
begin
|
begin
|
||||||
yield
|
yield or raise Minitest::Assertion, 'Assertion failure'
|
||||||
rescue Minitest::Assertion
|
rescue Minitest::Assertion
|
||||||
raise if Time.now - since > DEFAULT_TIMEOUT
|
raise if Time.now - since > DEFAULT_TIMEOUT
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ class Tmux
|
|||||||
return unless shell == :fish
|
return unless shell == :fish
|
||||||
|
|
||||||
send_keys 'function fish_prompt; end; clear', :Enter
|
send_keys 'function fish_prompt; end; clear', :Enter
|
||||||
self.until { |lines| raise Minitest::Assertion unless lines.empty? }
|
self.until(&:empty?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def kill
|
def kill
|
||||||
@ -149,7 +150,7 @@ class Tmux
|
|||||||
begin
|
begin
|
||||||
self.until do |lines|
|
self.until do |lines|
|
||||||
send_keys ' ', 'C-u', :Enter, 'hello', :Left, :Right
|
send_keys ' ', 'C-u', :Enter, 'hello', :Left, :Right
|
||||||
raise Minitest::Assertion unless lines[-1] == 'hello'
|
lines[-1] == 'hello'
|
||||||
end
|
end
|
||||||
rescue Minitest::Assertion
|
rescue Minitest::Assertion
|
||||||
(tries += 1) < 5 ? retry : raise
|
(tries += 1) < 5 ? retry : raise
|
||||||
@ -1790,20 +1791,20 @@ class TestGoFZF < TestBase
|
|||||||
|
|
||||||
def test_preview_scroll_begin_constant
|
def test_preview_scroll_begin_constant
|
||||||
tmux.send_keys "echo foo 123 321 | #{FZF} --preview 'seq 1000' --preview-window left:+123", :Enter
|
tmux.send_keys "echo foo 123 321 | #{FZF} --preview 'seq 1000' --preview-window left:+123", :Enter
|
||||||
tmux.until { |lines| lines.item_count == 1 }
|
tmux.until { |lines| assert_match %r{1/1}, lines[-2] }
|
||||||
tmux.until { |lines| assert_match %r{123.*123/1000}, lines[1] }
|
tmux.until { |lines| assert_match %r{123.*123/1000}, lines[1] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_preview_scroll_begin_expr
|
def test_preview_scroll_begin_expr
|
||||||
tmux.send_keys "echo foo 123 321 | #{FZF} --preview 'seq 1000' --preview-window left:+{3}", :Enter
|
tmux.send_keys "echo foo 123 321 | #{FZF} --preview 'seq 1000' --preview-window left:+{3}", :Enter
|
||||||
tmux.until { |lines| lines.item_count == 1 }
|
tmux.until { |lines| assert_match %r{1/1}, lines[-2] }
|
||||||
tmux.until { |lines| assert_match %r{321.*321/1000}, lines[1] }
|
tmux.until { |lines| assert_match %r{321.*321/1000}, lines[1] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_preview_scroll_begin_and_offset
|
def test_preview_scroll_begin_and_offset
|
||||||
['echo foo 123 321', 'echo foo :123: 321'].each do |input|
|
['echo foo 123 321', 'echo foo :123: 321'].each do |input|
|
||||||
tmux.send_keys "#{input} | #{FZF} --preview 'seq 1000' --preview-window left:+{2}-2", :Enter
|
tmux.send_keys "#{input} | #{FZF} --preview 'seq 1000' --preview-window left:+{2}-2", :Enter
|
||||||
tmux.until { |lines| lines.item_count == 1 }
|
tmux.until { |lines| assert_match %r{1/1}, lines[-2] }
|
||||||
tmux.until { |lines| assert_match %r{121.*121/1000}, lines[1] }
|
tmux.until { |lines| assert_match %r{121.*121/1000}, lines[1] }
|
||||||
tmux.send_keys 'C-c'
|
tmux.send_keys 'C-c'
|
||||||
end
|
end
|
||||||
@ -1970,7 +1971,7 @@ module CompletionTest
|
|||||||
FileUtils.mkdir_p('/tmp/fzf-test')
|
FileUtils.mkdir_p('/tmp/fzf-test')
|
||||||
FileUtils.mkdir_p('/tmp/fzf test')
|
FileUtils.mkdir_p('/tmp/fzf test')
|
||||||
(1..100).each { |i| FileUtils.touch("/tmp/fzf-test/#{i}") }
|
(1..100).each { |i| FileUtils.touch("/tmp/fzf-test/#{i}") }
|
||||||
['no~such~user', '/tmp/fzf test/foobar', '~/.fzf-home'].each do |f|
|
['no~such~user', '/tmp/fzf test/foobar'].each do |f|
|
||||||
FileUtils.touch(File.expand_path(f))
|
FileUtils.touch(File.expand_path(f))
|
||||||
end
|
end
|
||||||
tmux.prepare
|
tmux.prepare
|
||||||
@ -1986,14 +1987,15 @@ module CompletionTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
# ~USERNAME**<TAB>
|
# ~USERNAME**<TAB>
|
||||||
|
user = ENV['USER']
|
||||||
tmux.send_keys 'C-u'
|
tmux.send_keys 'C-u'
|
||||||
tmux.send_keys "cat ~#{ENV['USER']}**", :Tab
|
tmux.send_keys "cat ~#{user}**", :Tab
|
||||||
tmux.until { |lines| assert_operator lines.match_count, :>, 0 }
|
tmux.until { |lines| assert_operator lines.match_count, :>, 0 }
|
||||||
tmux.send_keys "'.fzf-home"
|
tmux.send_keys "/#{user}"
|
||||||
tmux.until { |lines| assert(lines.any? { |l| l.end_with?('/.fzf-home') }) }
|
tmux.until { |lines| assert(lines.any? { |l| l.end_with?("/#{user}") }) }
|
||||||
tmux.send_keys :Enter
|
tmux.send_keys :Enter
|
||||||
tmux.until(true) do |lines|
|
tmux.until(true) do |lines|
|
||||||
assert_match %r{cat .*/\.fzf-home}, lines[-1]
|
assert_match %r{cat .*/#{user}}, lines[-1]
|
||||||
end
|
end
|
||||||
|
|
||||||
# ~INVALID_USERNAME**<TAB>
|
# ~INVALID_USERNAME**<TAB>
|
||||||
@ -2241,6 +2243,11 @@ class TestFish < TestBase
|
|||||||
end
|
end
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
|
PS1= PROMPT_COMMAND= HISTFILE= HISTSIZE=100
|
||||||
|
unset <%= UNSETS.join(' ') %>
|
||||||
|
unset $(env | sed -n /^_fzf_orig/s/=.*//p)
|
||||||
|
unset $(declare -F | sed -n "/_fzf/s/.*-f //p")
|
||||||
|
|
||||||
# Setup fzf
|
# Setup fzf
|
||||||
# ---------
|
# ---------
|
||||||
if [[ ! "$PATH" == *<%= BASE %>/bin* ]]; then
|
if [[ ! "$PATH" == *<%= BASE %>/bin* ]]; then
|
||||||
@ -2255,9 +2262,6 @@ fi
|
|||||||
# ------------
|
# ------------
|
||||||
source "<%= BASE %>/shell/key-bindings.<%= __method__ %>"
|
source "<%= BASE %>/shell/key-bindings.<%= __method__ %>"
|
||||||
|
|
||||||
PS1= PROMPT_COMMAND= HISTFILE= HISTSIZE=100
|
|
||||||
unset <%= UNSETS.join(' ') %>
|
|
||||||
|
|
||||||
# Old API
|
# Old API
|
||||||
_fzf_complete_f() {
|
_fzf_complete_f() {
|
||||||
_fzf_complete "+m --multi --prompt \"prompt-f> \"" "$@" < <(
|
_fzf_complete "+m --multi --prompt \"prompt-f> \"" "$@" < <(
|
||||||
|
Loading…
Reference in New Issue
Block a user