pvincent 2 weeks ago
parent
commit
6fb25d217d
  1. 15
      poc
  2. 13
      test/stub/scenario.bash

15
poc

@ -86,13 +86,14 @@ function dump_stacktrace {
function on_exit {
code="${1:-0}"
failure_type="${failure_type:-UNDEFINED}"
2>&3 >&3 dump_stderr
if [[ -v failure_type ]]; then
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 {
@ -131,12 +132,16 @@ set -euo pipefail
set -E # HALT on subshell error
# 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_exit $?' EXIT
trap 'on_pipe' PIPE
echo "--SOURCE scenario ${BASHPID}"
miaou_debug "--source from ${BASHPID}"
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>-
echo "--SUCCESS scenario"
miaou_debug '--source success'

13
test/stub/scenario.bash

@ -165,10 +165,15 @@ function usage {
introspect_scenarii
(
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 "\tthese case scenarii helps testing the miaou-bash script"
echo -e "\trun a case scenario built from various bash statements and mostly ends up on failure"
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 {
@ -183,7 +188,7 @@ function test_contain_item {
# MAIN
[[ $# -eq 0 ]] && >&2 echo 'arg1 expected!' && usage && exit 1
[[ $# -eq 0 ]] && >&2 echo '<case_scenario> required!' && usage && exit 1
scenario="$1"
introspect_scenarii

Loading…
Cancel
Save