refactored test

This commit is contained in:
pvincent
2026-07-18 14:18:55 +04:00
parent 089553cf3a
commit c846767bc8
3 changed files with 30 additions and 22 deletions
+19 -4
View File
@@ -1,6 +1,21 @@
#!/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' ]]
# functions
function assert {
./test/stub/scenario.bash "$1" >/dev/null || (echo "error in: $1" && exit 1)
}
function fail_type {
stderr=$(./test/stub/scenario.bash "$1" 2>&1 >/dev/null)
code="$?"
regex="TYPE: $2"
[[ "$code" != 0 ]] && [[ "$stderr" =~ $regex ]] || (echo "error in: $1" && exit 1)
}
# main
assert success
fail_type subshell_term 'SUBSHELL TERM'
fail_type unbound_variable 'UNBOUND VARIABLE'
fail_type false 'FALSE'