Closed jorgebucaran closed 5 years ago
Sound nice.
I will recommend to use the command substitution syntax test "description" ( … )
in order to isolate test from one another. The last example, with code outside, could have side effects on following test case.
I also reckon the former allow one to use local
variables but not the letter (I'm on mobile so didn't check this)
@edouard-lopez To isolate your test you have two options.
begin..end
block:begin
pushd /path/to/some/dirty/git/repo
git_is_dirty
test "git_is_dirty shows changes not staged for commit" $status = 1
popd
end
test "git_is_dirty shows changes not staged for commit" (
pushd /path/to/some/dirty/git/repo
git_is_dirty
echo $status
popd
) = 1
Instead of overloading the test
builtin I propose using a different syntax for creating tests, e.g. assert
or @test
. I prefer @test
(to take advantage of syntax highlighting).
This helps make clear when you are writing a test or using the test
builtin for something else.
if test "$version" = 3.0.0
@test "Has some file" -f somefile
end
BATS, the test framework for bash use @test
syntax too.
🎉 I'm done implementing everything. See the changelog:
Fishtape 2 will break the test syntax as we want to make it compatible with
fish_indent
#32, #34.Summary
fish_indent
--pipe
in favor of any userland solution like"fish -c "fishtape *.fish | tap-nyan"
test
array extensions (don't know what I am talking about? don't worry then)Here's the new test syntax I have in mind. See that
test
blocks are now gone. Thetest
builtin has been "enhanced" to take an optional test description. If you already know how to use the shell'stest
builtin you already know how to create valid assertions in Fishtape 2.Notice that there is no reason you couldn't write the last test from above as follows (if you prefer):
Issue History
@test
instead oftest
https://github.com/jorgebucaran/fish-tape/issues/31#issuecomment-460995673