Skip to content

Commit

Permalink
More test fixes for tcell on GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
junegunn committed Feb 1, 2024
1 parent 413c66b commit b359463
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
permissions:
contents: read

env:
LC_ALL: C
LANG: en_US.UTF-8

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -42,7 +46,7 @@ jobs:
run: make test

- name: Integration test
run: make install && ./install --all && LC_ALL=C tmux new-session -d && ruby test/test_go.rb --verbose
run: make install && ./install --all && tmux new-session -d && ruby test/test_go.rb --verbose

- name: Integration test (tcell)
run: TAGS=tcell make clean install && ruby test/test_go.rb --verbose
16 changes: 9 additions & 7 deletions test/test_go.rb
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ def test_execute
opts = %[--bind "alt-a:execute(echo /{}/ >> #{output})+change-header(alt-a),alt-b:execute[echo /{}{}/ >> #{output}]+change-header(alt-b),C:execute(echo /{}{}{}/ >> #{output})+change-header(C)"]
writelines(tempname, %w[foo'bar foo"bar foo$bar])
tmux.send_keys "cat #{tempname} | #{fzf(opts)}", :Enter
tmux.until { |lines| assert_equal 3, lines.item_count }

ready = ->(s) { tmux.until { |lines| assert_includes lines[-3], s } }
tmux.send_keys :Escape, :a
Expand Down Expand Up @@ -2184,22 +2185,23 @@ def test_preview_window_follow
file = Tempfile.new('fzf-follow')
file.sync = true

tmux.send_keys %(seq 100 | #{FZF} --preview 'tail -f "#{file.path}"' --preview-window follow --bind 'up:preview-up,down:preview-down,space:change-preview-window:follow|nofollow' --preview-window '~3'), :Enter
tmux.send_keys %(seq 100 | #{FZF} --preview 'echo start; tail -f "#{file.path}"' --preview-window follow --bind 'up:preview-up,down:preview-down,space:change-preview-window:follow|nofollow' --preview-window '~4'), :Enter
tmux.until { |lines| lines.item_count == 100 }

# Write to the temporary file, and check if the preview window is showing
# the last line of the file
tmux.until { |lines| assert_includes lines[1], 'start' }
3.times { file.puts _1 } # header lines
1000.times { file.puts _1 }
tmux.until { |lines| assert_includes lines[1], '/1003' }
tmux.until { |lines| assert_includes lines[1], '/1004' }
tmux.until { |lines| assert_includes lines[-2], '999' }

# Scroll the preview window and fzf should stop following the file content
tmux.send_keys :Up
tmux.until { |lines| assert_includes lines[-2], '998' }
file.puts 'foo', 'bar'
tmux.until do |lines|
assert_includes lines[1], '/1005'
assert_includes lines[1], '/1006'
assert_includes lines[-2], '998'
end

Expand All @@ -2212,7 +2214,7 @@ def test_preview_window_follow
end
file.puts 'baz'
tmux.until do |lines|
assert_includes lines[1], '/1006'
assert_includes lines[1], '/1007'
assert_includes lines[-2], 'baz'
end

Expand All @@ -2221,7 +2223,7 @@ def test_preview_window_follow
wait { assert_includes lines[-2], 'bar' }
file.puts 'aaa'
tmux.until do |lines|
assert_includes lines[1], '/1007'
assert_includes lines[1], '/1008'
assert_includes lines[-2], 'bar'
end

Expand All @@ -2230,15 +2232,15 @@ def test_preview_window_follow
tmux.until { |lines| assert_includes lines[-2], 'aaa' }
file.puts 'bbb'
tmux.until do |lines|
assert_includes lines[1], '/1008'
assert_includes lines[1], '/1009'
assert_includes lines[-2], 'bbb'
end

# Disable following
tmux.send_keys :Space
file.puts 'ccc', 'ddd'
tmux.until do |lines|
assert_includes lines[1], '/1010'
assert_includes lines[1], '/1011'
assert_includes lines[-2], 'bbb'
end
rescue StandardError
Expand Down

0 comments on commit b359463

Please sign in to comment.