|
|
|
@ -780,11 +780,6 @@ class TestGoFZF < TestBase
|
|
|
|
|
tmux.send_keys :Enter
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_invalid_term
|
|
|
|
|
tmux.send_keys "TERM=xxx fzf", :Enter
|
|
|
|
|
tmux.until { |lines| lines.any? { |l| l.include? 'Invalid $TERM: xxx' } }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_with_nth
|
|
|
|
|
writelines tempname, ['hello world ', 'byebye']
|
|
|
|
|
assert_equal 'hello world ', `cat #{tempname} | #{FZF} -f"^he hehe" -x -n 2.. --with-nth 2,1,1`.chomp
|
|
|
|
@ -801,6 +796,47 @@ class TestGoFZF < TestBase
|
|
|
|
|
assert_equal src, `cat #{tempname} | #{FZF} -fhehe -x -n 2.. --with-nth 2,1,1 --no-ansi`.chomp
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_exit_0_exit_code
|
|
|
|
|
`echo foo | #{FZF} -q bar -0`
|
|
|
|
|
assert_equal 1, $?.exitstatus
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_invalid_term
|
|
|
|
|
lines = `TERM=xxx #{FZF}`
|
|
|
|
|
assert_equal 2, $?.exitstatus
|
|
|
|
|
assert lines.include?('Invalid $TERM: xxx')
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_invalid_option
|
|
|
|
|
lines = `#{FZF} --foobar 2>&1`
|
|
|
|
|
assert_equal 2, $?.exitstatus
|
|
|
|
|
assert lines.include?('unknown option: --foobar'), lines
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_filter_exitstatus
|
|
|
|
|
# filter / streaming filter
|
|
|
|
|
["", "--no-sort"].each do |opts|
|
|
|
|
|
assert `echo foo | #{FZF} -f foo #{opts}`.include?('foo')
|
|
|
|
|
assert_equal 0, $?.exitstatus
|
|
|
|
|
|
|
|
|
|
assert `echo foo | #{FZF} -f bar #{opts}`.empty?
|
|
|
|
|
assert_equal 1, $?.exitstatus
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def test_exitstatus_empty
|
|
|
|
|
{ '99' => '0', '999' => '1' }.each do |query, status|
|
|
|
|
|
tmux.send_keys "seq 100 | #{FZF} -q #{query}", :Enter
|
|
|
|
|
tmux.until { |lines| lines[-2] =~ %r{ [10]/100} }
|
|
|
|
|
tmux.send_keys :Enter
|
|
|
|
|
|
|
|
|
|
tmux.send_keys 'echo --\$?--'
|
|
|
|
|
tmux.until { |lines| lines.last.include? "echo --$?--" }
|
|
|
|
|
tmux.send_keys :Enter
|
|
|
|
|
tmux.until { |lines| lines.last.include? "--#{status}--" }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
def writelines path, lines
|
|
|
|
|
File.unlink path while File.exists? path
|
|
|
|
|