Skip to content

Commit

Permalink
Document @test function argument order (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgebucaran committed Jan 16, 2021
1 parent 5094268 commit ca79287
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Fishtape is a <a href=https://testanything.org title="Test Anything Protocol">Test Anything Protocol</a> compliant test runner for Fish. Use it to test anything: scripts, functions, plugins without ever leaving your favorite shell. Here's the first example to get you started:

```fish
@test "has a config.fish file" -e ~/.config/fish/config.fish
@test "the ultimate question" (math "6 * 7") -eq 42
@test "got root?" $USER = root
Expand All @@ -15,17 +17,18 @@ Now put that in a `fish` file and run it with `fishtape` installed. Behold, the
```console
$ fishtape example.fish
TAP version 13
ok 1 the ultimate question
not ok 2 got root?
ok 1 has a config.fish file
ok 2 the ultimate question
not ok 3 got root?
---
operator: =
expected: root
actual: jb
at: ~/example.fish:3
at: ~/fishtape/tests/example.fish:5
...

1..2
# pass 1
1..3
# pass 2
# fail 1
```

Expand All @@ -45,11 +48,11 @@ fisher install jorgebucaran/fishtape

Tests are defined with the `@test` function. Each test begins with a description, followed by a typical `test` expression. Refer to the `test` builtin [documentation](https://fishshell.com/docs/current/cmds/test.html) for operators and usage details.

> Operators to combine expressions are not currently supported: `!`, `-a`, `-o`.
<pre>
@<a href=#writing-tests>test</a> <i>description</i> [<i>actual</i>] <a href=https://fishshell.com/docs/current/cmds/test.html#operators-for-files-and-directories>operator</a> <i>expected</i>
</pre>

```fish
@test "has a config.fish file" -e ~/.config/fish/config.fish
```
> Operators to combine expressions are not currently supported: `!`, `-a`, `-o`.
Sometimes you need to test the exit status of running one or more commands and for that, you use command substitutions. Just make sure to suppress stdout to avoid cluttering your `test` expression.

Expand Down

0 comments on commit ca79287

Please sign in to comment.