Introduce assert_output
This commit is contained in:
parent
f9d6696687
commit
b57d527d6e
2 changed files with 29 additions and 2 deletions
|
|
@ -35,7 +35,7 @@ export -f assert_fails
|
|||
# helper functions inspired by bats/bats-assert
|
||||
run() {
|
||||
set +e
|
||||
("$@")
|
||||
output="$("$@" 2>&1)"
|
||||
status=$?
|
||||
set -e
|
||||
return 0
|
||||
|
|
@ -52,7 +52,14 @@ assert_failure() {
|
|||
exit 1
|
||||
fi
|
||||
}
|
||||
export -f run assert_success assert_failure
|
||||
assert_output() {
|
||||
if [ "$output" != "$1" ]; then
|
||||
echo "Expected output to equal: $1"
|
||||
echo "Actual output: $output"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
export -f run assert_success assert_failure assert_output
|
||||
|
||||
# main flow
|
||||
orig_ref="$(git symbolic-ref --quiet --short HEAD || git rev-parse HEAD)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue