miaou-bash.test.bash
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env miaou-bash
|
||||
|
||||
[[ $(./test/stub/scenario.bash unbound_variable 2>&1 1>/dev/null) =~ 'TYPE: UNBOUND VARIABLE' ]]
|
||||
@@ -52,13 +52,22 @@ function F3 {
|
||||
}
|
||||
|
||||
function usage {
|
||||
echo "USAGE: $0 <success|unbound-variable>"
|
||||
introspect_scenarii
|
||||
(
|
||||
IFS='|'
|
||||
echo "USAGE: $0 <${SCENARII[*]}>"
|
||||
)
|
||||
echo -e "\trun case scenario which performs various bash statements and mostly fails"
|
||||
echo -e "\tthese case scenarii helps testing the miaou-bash script"
|
||||
}
|
||||
|
||||
function do_success {
|
||||
echo SUCCESS
|
||||
echo -n 'SUCCESS args=['
|
||||
(
|
||||
IFS='|'
|
||||
echo -n "$*"
|
||||
)
|
||||
echo ']'
|
||||
}
|
||||
|
||||
function do_unbound_variable {
|
||||
@@ -68,35 +77,23 @@ function do_unbound_variable {
|
||||
}
|
||||
|
||||
function introspect_scenarii {
|
||||
mapfile -t SCENARII <<<"$(compgen -A function | grep ^do_)"
|
||||
mapfile -t SCENARII <<<"$(compgen -A function | grep ^do_ | sed 's/...//')"
|
||||
}
|
||||
function test_contain_item {
|
||||
local -n array=$1
|
||||
for item in "${array[@]}"; do [[ "$item" == "$2" ]] && return 0; done
|
||||
return 1
|
||||
}
|
||||
|
||||
# MAIN
|
||||
|
||||
[[ $# -eq 0 ]] && >&2 echo 'arg1 expected!' && usage && exit 1
|
||||
|
||||
scenario="$1"
|
||||
shift
|
||||
mapfile -t scenarii <<<"$(compgen -A function | grep ^do_)"
|
||||
|
||||
args=("$@")
|
||||
|
||||
echo "scenarii = ${scenarii[@]}"
|
||||
exit 0
|
||||
|
||||
echt "start of useless $0 $* ($# args)"
|
||||
if grep titi nope 2>/dev/null; then
|
||||
echo OK
|
||||
introspect_scenarii
|
||||
if test_contain_item SCENARII "$scenario"; then
|
||||
shift
|
||||
"do_${scenario}" "$@"
|
||||
else
|
||||
echo not found but ok
|
||||
(>&2 echo "scenario <${scenario}> not found!" && usage && exit 2)
|
||||
fi
|
||||
if grep titi "$BASEDIR/lib/utility.bash"; then
|
||||
echo OK
|
||||
else
|
||||
echo not found but ok
|
||||
fi
|
||||
echo question?:
|
||||
# read -r answer
|
||||
# echo "$answer"
|
||||
echo suite
|
||||
main
|
||||
echo end of useless
|
||||
Reference in New Issue
Block a user