junegunn/fzf
Testing
fzf has two distinct test suites: Go unit tests and Ruby + tmux integration tests. They cover different layers and are run separately.
Go unit tests
make testUnder the hood that runs:
go test -v -tags "$(TAGS)" \
github.com/junegunn/fzf/src \
github.com/junegunn/fzf/src/algo \
github.com/junegunn/fzf/src/tui \
github.com/junegunn/fzf/src/utilTest files live next to their subjects:
| Subject | Test file |
|---|---|
src/algo/algo.go |
src/algo/algo_test.go |
src/algo/indexbyte2_*.go |
src/algo/indexbyte2_test.go |
src/ansi.go |
src/ansi_test.go |
src/cache.go |
src/cache_test.go |
src/chunklist.go |
src/chunklist_test.go |
src/history.go |
src/history_test.go |
src/item.go |
src/item_test.go |
src/merger.go |
src/merger_test.go |
src/options.go |
src/options_test.go |
src/pattern.go |
src/pattern_test.go |
src/reader.go |
src/reader_test.go |
src/result.go |
src/result_test.go |
src/terminal.go |
src/terminal_test.go |
src/tokenizer.go |
src/tokenizer_test.go |
src/tui/light.go |
src/tui/light_test.go |
src/tui/tcell.go |
src/tui/tcell_test.go |
src/tui/tui.go |
src/tui/tui_test.go |
src/util/*.go |
src/util/*_test.go |
src/options_pprof.go |
src/options_pprof_test.go |
The CI workflow also runs fuzz tests on the SIMD IndexByteTwo helpers in src/algo/:
go test ./src/algo/ -fuzz=FuzzIndexByteTwo -fuzztime=5s
go test ./src/algo/ -fuzz=FuzzLastIndexByteTwo -fuzztime=5sBenchmarks
make benchRuns go test -run=Bench -bench=. -benchmem inside src/. Useful when changing the matcher or the chunk-list snapshot path.
Ruby + tmux integration tests
make itestThis is the primary regression suite for everything user-visible: rendering, key bindings, actions, preview, popup mode, shell integration. The harness:
- Lives under
test/(test_core.rb,test_layout.rb,test_preview.rb,test_filter.rb,test_exec.rb,test_raw.rb,test_server.rb,test_shell_integration.rb). - Uses helpers in
test/lib/to drive a real tmux pane: it sends keystrokes, captures the pane, and asserts on the rendered output. - Must be invoked inside an existing tmux session. The CI workflow runs
tmux new-session -dfirst.
A typical test (from test/test_core.rb) opens a tmux pane, types a query, presses enter, and asserts on what was printed:
def test_basic_filter
tmux.send_keys "(echo 1; echo 2; echo 3) | fzf -q 2", :Enter
tmux.until { |lines| lines[-1].include?('2') }
tmux.send_keys :Enter
assert_equal '2', tmux.capture
endRun a single test:
ruby test/runner.rb --name test_basic_filter
ruby test/runner.rb --verbosePass FZF_DEFAULT_OPTS= and other env vars exactly as the production binary would consume them.
Shell integration tests
test/test_shell_integration.rb exercises the embedded Bash, Zsh, and Fish scripts. The CI workflow installs zsh fish tmux shfmt so all three shells are available. Skips kick in if a particular shell is missing on your machine.
Vim plugin tests
test/vim/ contains a minimal Vim-based smoke test for plugin/fzf.vim.
Linting
make lintThis runs three checks:
gofmt -s -d src— must produce no diff.bundle exec rubocop -a --require rubocop-minitest --require rubocop-performance— auto-fixes and asserts clean.shell/update.sh --checkagainst the bash scripts — asserts the include-directive blocks are in sync withshell/common.sh.
Coverage
There is no formal coverage target, but in practice:
src/algois heavily covered by unit tests.src/optionsis covered bysrc/options_test.go(parser cases) plus the integration suite.src/terminalis mostly covered by integration tests; the unit test only covers small helpers.- The
algoSIMD helpers have both unit tests and fuzz tests.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.