Can't run with "errexit"
Hi,
I'm trying out bashunit and found a bug. Most of the times I run my script with set -e errexit. But then bashunit no longer works. Only when I turn it off with set +e, bashunit does it's job.
Can you describe in which form the script "no longer works"? Does it not even start up/run?
Uh, it's some time ago. I no longer have the code. Take for example a script that relies on errexit. Now I want to test if a command fails and the script exits (because of errexit). That no longer works because bashunit won't run at all. Example code:
#!/usr/bin/env bash
set -euo pipefail
DIRNAME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
testFindBuilds () {
assertEqual "$( eco 2 )" "2"
}
source "$DIRNAME"/bashunit.bash
This gives when run the result:
[shorty@krusty 25] test > ./test.sh
./test.sh: Zeile 14: eco: command not found
[shorty@krusty 26] test > echo $?
1
The output is not coming from Bashunit but from the shell. I expected the output to be coming from Bashunit.
If I run it with set +e just before sourcing bashunit.bash I get this:
[shorty@krusty 32] test > ./findBuildFiles.sh
./findBuildFiles.sh: Zeile 14: eco: command not found
[./findBuildFiles.sh:testFindBuilds:14:Failed
Done. 0 passed. 1 failed. 0 skipped.
[shorty@krusty 33] test > echo $?
1