arg0
This commit is contained in:
@@ -86,13 +86,14 @@ function dump_stacktrace {
|
|||||||
|
|
||||||
function on_exit {
|
function on_exit {
|
||||||
code="${1:-0}"
|
code="${1:-0}"
|
||||||
failure_type="${failure_type:-UNDEFINED}"
|
|
||||||
|
|
||||||
2>&3 >&3 dump_stderr
|
2>&3 >&3 dump_stderr
|
||||||
2>&3 >&3 dump_failure
|
if [[ -v failure_type ]]; then
|
||||||
2>&3 >&3 dump_stacktrace
|
2>&3 >&3 dump_failure
|
||||||
|
2>&3 >&3 dump_stacktrace
|
||||||
|
fi
|
||||||
|
|
||||||
miaou_debug "on_exit $code $failure_type"
|
miaou_debug "on_exit $code"
|
||||||
}
|
}
|
||||||
|
|
||||||
function on_pipe {
|
function on_pipe {
|
||||||
@@ -131,12 +132,16 @@ set -euo pipefail
|
|||||||
set -E # HALT on subshell error
|
set -E # HALT on subshell error
|
||||||
# set -T # DEBUG RETURN
|
# set -T # DEBUG RETURN
|
||||||
|
|
||||||
|
[[ $# -lt 1 ]] && >&2 echo 'ERROR: script expected!' && builtin exit 1
|
||||||
|
BASH_ARGV0="$1" && shift # to pretend script runs by itself
|
||||||
|
|
||||||
trap 'on_error $?' ERR
|
trap 'on_error $?' ERR
|
||||||
trap 'on_exit $?' EXIT
|
trap 'on_exit $?' EXIT
|
||||||
trap 'on_pipe' PIPE
|
trap 'on_pipe' PIPE
|
||||||
|
|
||||||
echo "--SOURCE scenario ${BASHPID}"
|
miaou_debug "--source from ${BASHPID}"
|
||||||
exec 3>/dev/stderr
|
exec 3>/dev/stderr
|
||||||
2>"$MIAOU_BASH_ERROR" source ./test/stub/scenario.bash subshell_term
|
# shellcheck source=/dev/null
|
||||||
|
2>"$MIAOU_BASH_ERROR" source "$BASH_ARGV0"
|
||||||
exec 3>-
|
exec 3>-
|
||||||
echo "--SUCCESS scenario"
|
miaou_debug '--source success'
|
||||||
|
|||||||
@@ -165,10 +165,15 @@ function usage {
|
|||||||
introspect_scenarii
|
introspect_scenarii
|
||||||
(
|
(
|
||||||
IFS='|'
|
IFS='|'
|
||||||
echo "USAGE: $0 <${SCENARII[*]}>"
|
echo "USAGE: $0 <case_scenario>"
|
||||||
)
|
)
|
||||||
echo -e "\trun case scenario which performs various bash statements and mostly fails"
|
echo -e "\trun a case scenario built from various bash statements and mostly ends up on failure"
|
||||||
echo -e "\tthese case scenarii helps testing the miaou-bash script"
|
echo -e "\tthese case scenarii provide the help suite needed for \`miaou-bash\`"
|
||||||
|
echo -e "\there is the list of available case scenario:"
|
||||||
|
local i
|
||||||
|
for i in "${SCENARII[@]}"; do
|
||||||
|
echo -e "\t- $i"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function introspect_scenarii {
|
function introspect_scenarii {
|
||||||
@@ -183,7 +188,7 @@ function test_contain_item {
|
|||||||
|
|
||||||
# MAIN
|
# MAIN
|
||||||
|
|
||||||
[[ $# -eq 0 ]] && >&2 echo 'arg1 expected!' && usage && exit 1
|
[[ $# -eq 0 ]] && >&2 echo '<case_scenario> required!' && usage && exit 1
|
||||||
|
|
||||||
scenario="$1"
|
scenario="$1"
|
||||||
introspect_scenarii
|
introspect_scenarii
|
||||||
|
|||||||
Reference in New Issue
Block a user