Assertion with `contains` and empty $output produces automatic pass
MichaelAquilina opened this issue · 5 comments
Simplest way to explain this is with a test example:
@test 'This test will pass no matter what' {
assert "$output" contains "hello"
assert $state equals 0
}
This also works with any other empty variable being tested - but output is usually the most likely case.
This is likely to do with the way assert has been written so that the assert operator is after the first operand. So zunit treats the the assert as assert contains "hello"
since "$output" is empty.
I suspect that the only proper way to fix this is to change the way assert
statements are run (change the ordering of the operator to be directly after the assert
function
If it comes to it we can do that, but I'd rather keep it readable. The double quotes should prevent that from happening, so I'm inclined to think it's a bug
Nothing stands out as obvious from the source code 🤔 there are clearly quite a few things I need to learn about shell scripts
@molovo any chance we could get the relevant PR merged for this? I'm still affected by this bug right now :(
@MichaelAquilina whoops, thought I'd already merged it. I'll tag a new release tonight