Test files are .fish files with one or more test blocks. A test block consists of an optional description and any test expression supported by test(1).
test "current directory is home" $HOME = $DIRNAME end test "math still works" 42 -eq (math 41 + 1) end test "test is a builtin" "test" = (builtin -n) end test "no odds are evens" 1 3 5 7 != ( for i in (seq $n) if test (math $i%2) = 0 echo $i end end ) end
Fishtape reads any given files, or the standard input if no files are given, and converts test blocks into valid Fish syntax which is then evaluated, producing a TAP stream.
Setup and Teardown
Include a setup and teardown method in your test file with code that must be run before and after every test.
Run before each test in the current file. Use setup to load fixtures and/or set up your environment.
set path $DIRNAME/$TESTNAME function setup mkdir -p $path end
Run after each test in the current file. Use teardown to clean up loaded resources, etc.
function teardown rm -rf $path end
The following variables are available inside a test file:
Path to the running script.
Directory name of the running script.
Name of the running script.
TAP protocol version.
Line Buffered Output
According to fish-shell/#1396, redirections and pipes involving blocks are run serially, not in parallel. This causes fishtape to block the pipeline and buffer all of its output. To emit a line buffered stream use --pipe=program.
fishtape test.fish --pipe=tap-nyan
Only one expression per test block is allowed. Use command substitutions to create complex test expressions.
Each test file is wrapped in
begin; endblocks under the hood to protect your local scope. In addition, global and universal variables are restored before each test.
See Awesome TAP for a list of consumers / reporters, tools and other TAP resources.