Skip to content
Myr

Fix tests for tcell build

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 1416e69 · Browse files · 5 files+68 added−24 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+68 added−24 removed

  • tests:+39 added−15 removed
  • other:+29 added−9 removed

5 files+68 added−24 removed

modified:.github/workflows/linux.yml+3 added
modified:src/tui/tcell.go+7 added
141 unmodified lines
142// they are declared here to prevent introducing tcell library in non-windows builds143var (144 _screen tcell.Screen145 _prevMouseButton tcell.ButtonMask146 _initialResize bool = true147)148149func (r *FullscreenRenderer) initScreen() {150 s, e := tcell.NewScreen()
69 unmodified lines
220func (r *FullscreenRenderer) GetChar() Event {221 ev := _screen.PollEvent()222 switch ev := ev.(type) {223 case *tcell.EventResize:224 // Ignore the first resize event225 // https://github.com/gdamore/tcell/blob/v2.7.0/TUTORIAL.md?plain=1#L18226 if _initialResize {227 _initialResize = false228 return Event{Invalid, 0, nil}229 }230 return Event{Resize, 0, nil}231232 // process mouse events:233 case *tcell.EventMouse:
566 unmodified lines
modified:test/test_go.rb+39 added-15 removed
962 unmodified lines
963 end964965 def test_execute966 output = '/tmp/fzf-test-execute'967 opts = %[--bind "alt-a:execute(echo /{}/ >> #{output}),alt-b:execute[echo /{}{}/ >> #{output}],C:execute:echo /{}{}{}/ >> #{output}"]967 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)"]968 writelines(tempname, %w[foo'bar foo"bar foo$bar])969 tmux.send_keys "cat #{tempname} | #{fzf(opts)}", :Enter970 tmux.until { |lines| assert_equal ' 3/3', lines[-2] }970971 ready = ->(s) { tmux.until { |lines| assert_includes lines[-3], s } }972 tmux.send_keys :Escape, :a973 ready.call('alt-a')972 tmux.send_keys :Escape, :a974 tmux.send_keys :Escape, :b975 ready.call('alt-b')976977 tmux.send_keys :Up978 tmux.send_keys :Escape, :a979 ready.call('alt-a')980 tmux.send_keys :Escape, :b975 tmux.send_keys :Escape, :b981 ready.call('alt-b')982983 tmux.send_keys :Up984 tmux.send_keys :C985 ready.call('C')986987 tmux.send_keys 'barfoo'988 tmux.until { |lines| assert_equal ' 0/3', lines[-2] }989990 tmux.send_keys :Escape, :a991 ready.call('alt-a')992 tmux.send_keys :Escape, :b993 ready.call('alt-b')994995 wait do996 assert_path_exists output997 assert_equal %w[985 /foo'bar/ /foo'bar/986 /foo"barfoo"bar/ /foo"barfoo"bar/998 /foo'bar/ /foo'barfoo'bar/999 /foo"bar/ /foo"barfoo"bar/1000 /foo$barfoo$barfoo$bar/1001 ], File.readlines(output, chomp: true)1002 end1003 ensure
1 unmodified line
1005 end10061007 def test_execute_multi1008 output = '/tmp/fzf-test-execute-multi'996 opts = %[--multi --bind "alt-a:execute-multi(echo {}/{+} >> #{output})"]1009 opts = %[--multi --bind "alt-a:execute-multi(echo {}/{+} >> #{output})+change-header(alt-a),alt-b:change-header(alt-b)"]1010 writelines(tempname, %w[foo'bar foo"bar foo$bar foobar])1011 tmux.send_keys "cat #{tempname} | #{fzf(opts)}", :Enter1012 ready = ->(s) { tmux.until { |lines| assert_includes lines[-3], s } }10131014 tmux.until { |lines| assert_equal ' 4/4 (0)', lines[-2] }1015 tmux.send_keys :Escape, :a1016 ready.call('alt-a')1017 tmux.send_keys :Escape, :b1018 ready.call('alt-b')10191020 tmux.send_keys :BTab, :BTab, :BTab1021 tmux.until { |lines| assert_equal ' 4/4 (3)', lines[-2] }1022 tmux.send_keys :Escape, :a1023 ready.call('alt-a')1024 tmux.send_keys :Escape, :b1025 ready.call('alt-b')10261027 tmux.send_keys :Tab, :Tab1028 tmux.until { |lines| assert_equal ' 4/4 (3)', lines[-2] }1029 tmux.send_keys :Escape, :a1030 ready.call('alt-a')1031 wait do1032 assert_path_exists output1033 assert_equal [1034 %(foo'bar/foo'bar),
209 unmodified lines
1244 end1245 end12461247 def test_toggle_header1224 tmux.send_keys "seq 4 | #{FZF} --header-lines 2 --header foo --bind space:toggle-header --header-first --height 10 --border", :Enter1248 tmux.send_keys "seq 4 | #{FZF} --header-lines 2 --header foo --bind space:toggle-header --header-first --height 10 --border rounded", :Enter1249 before = <<~OUTPUT1250 ╭───────1251 │1252 │ 4
1386 unmodified lines
2639 assert_equal_org expected, actual2640 end26412642 def test_height_range_fit2619 tmux.send_keys 'seq 3 | fzf --height ~100% --info=inline --border', :Enter2643 tmux.send_keys 'seq 3 | fzf --height ~100% --info=inline --border rounded', :Enter2644 expected = <<~OUTPUT2645 ╭──────────2646 │ 32647 │ 2
4 unmodified lines
2652 tmux.until { assert_block(expected, _1) }2653 end26542655 def test_height_range_fit_preview_above2632 tmux.send_keys 'seq 3 | fzf --height ~100% --info=inline --border --preview "seq {}" --preview-window up,60%', :Enter2656 tmux.send_keys 'seq 3 | fzf --height ~100% --info=inline --border rounded --preview-window border-rounded --preview "seq {}" --preview-window up,60%', :Enter2657 expected = <<~OUTPUT2658 ╭──────────2659 │ ╭────────2660 │ │ 1
47 unmodified lines
2708 tmux.until { assert_block(expected, _1) }2709 end27102711 def test_height_range_overflow2688 tmux.send_keys 'seq 100 | fzf --height ~5 --info=inline --border', :Enter2712 tmux.send_keys 'seq 100 | fzf --height ~5 --info=inline --border rounded', :Enter2713 expected = <<~OUTPUT2714 ╭──────────────2715 │ 22716 │ > 1
56 unmodified lines
2773 end2774 end27752776 def test_labels_left2753 tmux.send_keys ': | fzf --border --border-label foobar --border-label-pos 2 --preview : --preview-label barfoo --preview-label-pos 2', :Enter2777 tmux.send_keys ': | fzf --border rounded --preview-window border-rounded --border-label foobar --border-label-pos 2 --preview : --preview-label barfoo --preview-label-pos 2', :Enter2778 tmux.until do2779 assert_includes(_1[0], '╭foobar─')2780 assert_includes(_1[1], '╭barfoo─')2781 end2782 end27832784 def test_labels_right2761 tmux.send_keys ': | fzf --border --border-label foobar --border-label-pos -2 --preview : --preview-label barfoo --preview-label-pos -2', :Enter2785 tmux.send_keys ': | fzf --border rounded --preview-window border-rounded --border-label foobar --border-label-pos -2 --preview : --preview-label barfoo --preview-label-pos -2', :Enter2786 tmux.until do2787 assert_includes(_1[0], '─foobar╮')2788 assert_includes(_1[1], '─barfoo╮')2789 end2790 end27912792 def test_labels_bottom2769 tmux.send_keys ': | fzf --border --border-label foobar --border-label-pos 2:bottom --preview : --preview-label barfoo --preview-label-pos -2:bottom', :Enter2793 tmux.send_keys ': | fzf --border rounded --preview-window border-rounded --border-label foobar --border-label-pos 2:bottom --preview : --preview-label barfoo --preview-label-pos -2:bottom', :Enter2794 tmux.until do2795 assert_includes(_1[-1], '╰foobar─')2796 assert_includes(_1[-2], '─barfoo╯')2797 end
120 unmodified lines
2918 tmux.until { |lines| assert_equal 99, lines.item_count }2919 end29202921 def test_no_extra_newline_issue_32092898 tmux.send_keys(%(seq 100 | #{FZF} --height 10 --preview-window up,wrap --preview 'printf "─%.0s" $(seq 1 "$((FZF_PREVIEW_COLUMNS - 5))"); printf $"\\e[7m%s\\e[0m" title; echo; echo something'), :Enter)2922 tmux.send_keys(%(seq 100 | #{FZF} --height 10 --preview-window up,wrap,border-rounded --preview 'printf "─%.0s" $(seq 1 "$((FZF_PREVIEW_COLUMNS - 5))"); printf $"\\e[7m%s\\e[0m" title; echo; echo something'), :Enter)2923 expected = <<~OUTPUT2924 ╭──────────2925 │ ─────────2926 │ something
696 unmodified lines
modified:go.mod+3 added-3 removed
1module github.com/junegunn/fzf23require (4 github.com/gdamore/tcell/v2 v2.5.44 github.com/gdamore/tcell/v2 v2.7.05 github.com/mattn/go-isatty v0.0.176 github.com/mattn/go-shellwords v1.0.127 github.com/rivo/uniseg v0.4.68 github.com/saracen/walker v0.1.3
3 unmodified lines
1213require (14 github.com/gdamore/encoding v1.0.0 // indirect15 github.com/lucasb-eyer/go-colorful v1.2.0 // indirect16 github.com/mattn/go-runewidth v0.0.14 // indirect16 github.com/mattn/go-runewidth v0.0.15 // indirect17 golang.org/x/sync v0.5.0 // indirect18 golang.org/x/text v0.5.0 // indirect18 golang.org/x/text v0.14.0 // indirect19)2021go 1.17
modified:go.sum+16 added-6 removed
1github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=2github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=3github.com/gdamore/tcell/v2 v2.5.4 h1:TGU4tSjD3sCL788vFNeJnTdzpNKIw1H5dgLnJRQVv/k=4github.com/gdamore/tcell/v2 v2.5.4/go.mod h1:dZgRy5v4iMobMEcWNYBtREnDZAT9DYmfqIkrgEMxLyw=3github.com/gdamore/tcell/v2 v2.7.0 h1:I5LiGTQuwrysAt1KS9wg1yFfOI3arI3ucFrxtd/xqaA=4github.com/gdamore/tcell/v2 v2.7.0/go.mod h1:hl/KtAANGBecfIPxk+FzKvThTqI84oplgbPEmVX60b8=5github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=6github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=7github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=8github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=9github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=10github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=9github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=10github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=11github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=12github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=13github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=14github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=15github.com/rivo/uniseg v0.4.6 h1:Sovz9sDSwbOz9tgUy8JpT+KgCkPYJEN/oYzlJiYTNLg=16github.com/rivo/uniseg v0.4.6/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=17github.com/saracen/walker v0.1.3 h1:YtcKKmpRPy6XJTHJ75J2QYXXZYWnZNQxPCVqZSHVV/g=18github.com/saracen/walker v0.1.3/go.mod h1:FU+7qU8DeQQgSZDmmThMJi93kPkLFgy0oVAcLxurjIk=19github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=20golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=21golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=22golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=23golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=24golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=25golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=26golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=27golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=28golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=29golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=30golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=31golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=32golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=33golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=34golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=35golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=36golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=37golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=38golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=39golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=40golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=41golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=42golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=43golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=44golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=45golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=46golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=47golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=48golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=49golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=50golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=51golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=52golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=45golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=46golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=53golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=54golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=55golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=56golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=57golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=58golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=59golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=60golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=