You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed a small glitch when I use set -e in my code. For example:
#!/usr/bin/env bashset -euo pipefail
functionhello() {
echo"something"| grep "else"# this will exit at this point, because this line finishes with a non-zero exit statusecho"hello"
}
# Make sure that I can use source in the testif [[ "${BASH_SOURCE[0]}"=="${0}" ]];then
hello
fi
Executing this tests fails with an error code, which is expected, but the report is a bit scrambled as there's no status indicator for the test that fails due to -e:
I'm trying to reproduce your first case but I can't see the same result as you. I've create hello.sh and test_hello with the following code inside and you can see what is the output of bash_unit for me.
#> cat hello.sh #!/usr/bin/env bashset -euo pipefail
functionhello() {
echo"something"| grep "else"# this will exit at this point, because this line finishes with a non-zero exit statusecho"hello"
}
# Make sure that I can use source in the testif [[ "${BASH_SOURCE[0]}"=="${0}" ]];then
hello
fi#> cat test_hello functiontest_fail_due_to_e() {
source hello.sh
result=$(hello)
assert_equals 0 $?
assert_equals "hello""${result}"
}
#> ./bash_unit test_hello
Running tests in test_hello
Running test_fail_due_to_e... SUCCESS
Could you reproduce this and confirm you see the same thing as me?
Could you correct my code above so that I reproduce the same issue as yours?
Hi!
I noticed a small glitch when I use
set -e
in my code. For example:I have the following test:
Executing this tests fails with an error code, which is expected, but the report is a bit scrambled as there's no status indicator for the test that fails due to
-e
:Also, if I extract the sourcing from the
test_fail_due_to_e
function, like:Then the whole test file will be missing from the report.
Would it be possible to include such failures in the report?
Thanks,
David
The text was updated successfully, but these errors were encountered: