Browse Source

test TYPE: FALSE

main
pvincent 1 week ago
parent
commit
9d3652a655
  1. 11
      bin/miaou-bash
  2. 3
      test/miaou-bash.test.bash
  3. 2
      test/stub/scenario.bash

11
bin/miaou-bash

@ -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

3
test/miaou-bash.test.bash

@ -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' ]]

2
test/stub/scenario.bash

@ -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"
}

Loading…
Cancel
Save