fzf

The atago project wrote these specs on its own initiative and runs them in its own CI, to exercise atago against a real program. They are not fzf’s official test suite, and the fzf project is not affiliated with atago.

Summary #

1 suite · 8 scenarios

Contents #

fzf (third-party CLI, pty testbed) #

fzf is the archetype of a CLI you cannot test by piping to it: it refuses to run without a terminal, redraws the screen as you type, and is driven entirely by keystrokes.

Both halves are covered. fzf --filter is a plain program with a plain contract — given a query and a list on stdin, it prints the matches and exits with a code that says whether anything matched. The interactive scenarios run the real finder inside a pseudo-terminal and drive it the way a person does: type to narrow the list, move the selection, press Enter, and assert on what fzf finally printed.

Source: test/e2e/thirdparty/fzf/fzf.atago.yaml

Scenario: version prints a semantic version #

only when fzf --version succeeds

When #

fzf --version

Then #

  • exit code is 0
  • stdout matches /^[0-9]+\.[0-9]+/

Scenario: filter mode matches fuzzily on stdin without a terminal #

only when fzf --version succeeds

Inputs #

stdin for fzf:

apple
banana
cherry

When #

fzf --filter=bna

Then #

  • exit code is 0
  • stdout equals an exact value

Scenario: filter mode exits 1 when nothing matches #

only when fzf --version succeeds

Inputs #

stdin for fzf:

apple
banana
cherry

When #

fzf --filter=zzz

Then #

  • exit code is 1
  • stdout is empty

Scenario: interactive mode refuses to start without a terminal #

only when env CI is set

When #

printf 'apple\n' | fzf

Then #

  • exit code is 2
  • stderr contains ioctl

Scenario: interactive selection picks the queried line #

only when fzf --version succeeds · skipped on Windows

When #

# interactive (pty): printf 'apple\nbanana\ncherry\n' | fzf > pick.txt

Then #

  • exit code is 0
  • file pick.txt contains cherry
  • file pick.txt does not contain banana

Scenario: multi-select accepts several lines at once #

only when fzf --version succeeds · skipped on Windows

When #

# interactive (pty): printf 'apple\nbanana\ncherry\n' | fzf -m --bind ctrl-a:select-all > pick.txt

Then #

  • exit code is 0
  • file pick.txt contains apple, banana, cherry

Scenario: aborting the finder exits 130 #

only when fzf --version succeeds · skipped on Windows

When #

# interactive (pty): printf 'apple\nbanana\ncherry\n' | fzf

Then #

  • exit code is 130

Scenario: the finder screen narrows to the typed query #

only when fzf --version succeeds · skipped on Windows

When #

# interactive (pty): printf 'apple\nbanana\ncherry\n' | fzf

Then #

  • rendered screen contains banana
  • rendered screen does not contain cherry