jorgebucaran/fishtape

Migrating from V1 to V2

jorgebucaran opened this issue ยท 0 comments

Just upgraded to V2? You'll need to make some adjustments. In this issue, I'll explain what these changes are and how to migrate your tests. ๐Ÿ™Œ

Background

Fishtape V1 test syntax wasn't valid Fish syntax. Running fishtape test.fish transformed test blocks to valid to test builtin declarations under the hood.

That means you couldn't use fish_indent to format your files. Blocks didn't let you create multiple assertions either, defeating the purpose of a "block" in the first place. Even if you never used fish_indent, why write pseudo-Fish code when you can write real Fish?

What's new?

V2 introduces a new @test function. It wraps the test builtin, so you can specify an optional description for your test. Another small difference is no support for -o or -a operators.

Here are some examples:

@test "current directory is home" $PWD = $HOME

@test "hello has length 5" (string length "hello") = 5

@test "math still works" 42 -eq (math 41 + 1)

@test "test is a builtin" (contains -- test (builtin -n)) $status -eq 0

Also new is the @mesg function. It creates a TAP comment like # my message that will be written together with the TAP output.

Other changes include the removal of all special variables, leaving only $current_filename. If we need more variables, we can always add them later when the need arises.