3 changed files with 30 additions and 22 deletions
@ -1,6 +1,21 @@ |
|||||
#!/usr/bin/env bash |
#!/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' |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue