refactored test
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -10,6 +10,8 @@ readonly BASEDIR
|
||||
function do_subshell_term {
|
||||
# grep nope nope
|
||||
echo "found=$(grep nope nope)"
|
||||
echo "found=$(command_not_found)"
|
||||
command_not_found
|
||||
}
|
||||
|
||||
function do_last_false {
|
||||
|
||||
Reference in New Issue
Block a user