Fishtape is a TAP producing test runner for fish. It scans one or more .fish files and evaluates test blocks producing a TAP stream.
With fisherman:
fisher fishtape
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.
fishtape path/to/tests/*.fish
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.
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; end
blocks 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.