assertTrue does not work with "set -e"
GoogleCodeExporter opened this issue · comments
The below script crashes but would works fine if you remove '-e'
#! /bin/sh -e
testTrue()
{
assertTrue 0
}
. shunit2
I'm using shunit2 v2.1.6-1 from ubuntu raring
Original issue reported on code.google.com by ert...@gmail.com
on 21 Jul 2013 at 9:28
The problem in this case was the shunit_match_=`expr "${shunit_condition_}" :
'\([0-9]*\)'` which returned a 1. i attached an || true to ensure that return
value is always 0 (since it won't be evaluated by the script).
I also fixed the problem for the AssertEquals and AssertNotEquals functions.
there the problem came frmo failNotEquals.
One remaining problem is that an `assertTrue 1` will still cause the crash
since the assertion function returns failure in this case. I'm not sure if this
is a responsibility of the assetion function or the caller that should check
the return value. I tend to give the responsibility to the caller.
I did not write test yet because I'm not sure how this behaviour could be
tested.
Original comment by bitschup...@googlemail.com
on 13 Sep 2013 at 11:49
Attachments:
@kward this is quite a gotcha. Is this issue just waiting on someone to rebase the above patch on the latest shunit2 in master?
Fixed by 6f6a642