test TYPE: FALSE
This commit is contained in:
+7
-4
@@ -8,6 +8,10 @@ readonly MIAOU_BASH_ERROR MIAOU_BASH_DEBUG
|
||||
|
||||
# FUNCTIONS
|
||||
|
||||
function is_true {
|
||||
[[ "${1,,}" =~ ^(true|yes|1)$ ]]
|
||||
}
|
||||
|
||||
# overridden function which permits backtracing of original `return` statement
|
||||
function false {
|
||||
>&2 echo "${BASH_SOURCE[1]}:${BASH_LINENO[0]} false"
|
||||
@@ -178,8 +182,7 @@ function on_exit {
|
||||
}
|
||||
|
||||
function debug {
|
||||
[[ "${MIAOU_BASH_DEBUG}" == true ]] && >/dev/tty echo "*********** DEBUG: $*" ||
|
||||
true
|
||||
is_true "${MIAOU_BASH_DEBUG}" && >/dev/tty echo "*********** DEBUG: $*" || true
|
||||
}
|
||||
|
||||
function dump_failure {
|
||||
@@ -206,9 +209,9 @@ function dump_failure {
|
||||
function dump_stderr {
|
||||
last_trim=${1:-false}
|
||||
mapfile -t tmp_error <"$MIAOU_BASH_ERROR"
|
||||
$last_trim && unset 'tmp_error[-1]' && tmp_error=("${tmp_error[@]}")
|
||||
is_true "$last_trim" && unset 'tmp_error[-1]' && tmp_error=("${tmp_error[@]}")
|
||||
if [[ "${#tmp_error[@]}" -gt 0 ]]; then
|
||||
$MIAOU_BASH_DEBUG && >/dev/tty echo '---stderr---'
|
||||
debug '---stderr---'
|
||||
for i in "${tmp_error[@]}"; do
|
||||
>&4 echo -e "$i"
|
||||
done
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# do not use miaou-bash as the shebang
|
||||
|
||||
./test/stub/scenario.bash success >/dev/null
|
||||
[[ $(./test/stub/scenario.bash unbound_variable 2>&1 1>/dev/null) =~ 'TYPE: UNBOUND VARIABLE' ]]
|
||||
[[ $(./test/stub/scenario.bash false 2>&1 1>/dev/null) =~ 'TYPE: FALSE' ]]
|
||||
|
||||
@@ -30,7 +30,7 @@ function do_success {
|
||||
source "${MIAOU_BASH_DIR}/lib/ansi.bash"
|
||||
local content
|
||||
content=$(PADDING_LEFT=2 PADDING_RIGHT=6 style_padding 'this is success')
|
||||
content=$(FG=PURPLE BG=GRAY style_ansi "$content")
|
||||
content=$(FG=YELLOW BG=BLUE style_ansi "$content")
|
||||
FG=BLACK BG=RED PADDING=8 style_block "$content"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user