mirror of
https://github.com/tests-always-included/mo.git
synced 2024-12-18 16:27:52 +00:00
Merge pull request #39 from felipecassiors/felipecassiors/fail-on-function
Add fail on function
This commit is contained in:
commit
8cd67fb908
8
mo
8
mo
@ -155,7 +155,7 @@ mo() (
|
|||||||
#
|
#
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
moCallFunction() {
|
moCallFunction() {
|
||||||
local moArgs moFunctionArgs
|
local moArgs moFunctionArgs moFunctionResult
|
||||||
|
|
||||||
moArgs=()
|
moArgs=()
|
||||||
moTrimWhitespace moFunctionArgs "$3"
|
moTrimWhitespace moFunctionArgs "$3"
|
||||||
@ -166,6 +166,12 @@ moCallFunction() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "$2" | MO_FUNCTION_ARGS="$moFunctionArgs" eval "$1" "$moArgs"
|
echo -n "$2" | MO_FUNCTION_ARGS="$moFunctionArgs" eval "$1" "$moArgs"
|
||||||
|
moFunctionResult=$?
|
||||||
|
|
||||||
|
if [[ -n "${MO_FAIL_ON_FUNCTION-}" && "$moFunctionResult" != 0 ]]; then
|
||||||
|
echo "Function '$1' with args '${moArgs@}' failed with status code $moFunctionResult"
|
||||||
|
exit $moFunctionResult
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user