Update test

Make sure to print when a control character is present. If it doesn't,
it leads to confusion when bash reports two apparently-equal strings
don't actually match due to the presence of a non-printing character.
This commit is contained in:
Dan Church 2020-12-14 10:19:28 -06:00
parent 5454fe681f
commit c750b11c7e
Signed by: h3xx
GPG key ID: EA2BF379CD2CDBD0

View file

@ -4,25 +4,29 @@
echo_success() { echo_success() {
printf '[\033[1;32m%s\033[0;39m] %s' \ printf '[\033[1;32m%s\033[0;39m] %s' \
' OK ' \ ' OK ' \
"$*" "$(escape_nonprinting "$*")"
} }
echo_failure() { echo_failure() {
printf '[\033[1;31m%s\033[0;39m] %s' \ printf '[\033[1;31m%s\033[0;39m] %s' \
'FAILED' \ 'FAILED' \
"$*" "$(escape_nonprinting "$*")"
} }
echo_warning() { echo_warning() {
printf '[\033[1;33m%s\033[0;39m] %s' \ printf '[\033[1;33m%s\033[0;39m] %s' \
'WARNING' \ 'WARNING' \
"$*" "$(escape_nonprinting "$*")"
} }
echo_passed() { echo_passed() {
printf '[\033[1;33m%s\033[0;39m] %s' \ printf '[\033[1;33m%s\033[0;39m] %s' \
'PASSED' \ 'PASSED' \
"$*" "$(escape_nonprinting "$*")"
}
escape_nonprinting() {
echo "$*" |cat -v
} }
assert_equals() { assert_equals() {