sstephenson / bats

Bash Automated Testing System
MIT License
7.12k stars 519 forks source link

Assertions in not intended places #227

Closed quilir closed 7 years ago

quilir commented 7 years ago

I have problem with bats. For example I get output:

1..3
ok 1 test1
ok 2 test2
not ok 3 test3
# (in test file test.bats, line 36)
#   `echo $servers | grep $server' failed

Yes, I have in line 36 following code:

echo $servers | grep $server

servers has value "" server has value "172.24.101.1"

I don't now why bats sees there assertion. Possibly it's tricky part of this tool. Can you explain to me what code should I avoid to prevent unexpected checks?

EDIT: Oh, right. Every line is checked. Grep returns non-zero value so test fails...