Commit ae7c595e authored by Matthew Brett's avatar Matthew Brett
Browse files

Tests for new suppress functionality

parent 8977eb2b
...@@ -41,6 +41,7 @@ function bad_cmd { ...@@ -41,6 +41,7 @@ function bad_cmd {
} }
function bad_mid_cmd { function bad_mid_cmd {
# Command returns 0, but errors in the middle
echo ok for now echo ok for now
false false
echo should be bad now echo should be bad now
...@@ -52,14 +53,25 @@ function good_cmd { ...@@ -52,14 +53,25 @@ function good_cmd {
return 0 return 0
} }
# Check state of set -e, disable if set # Store state of options including -e, -x
# https://stackoverflow.com/questions/14564746/in-bash-how-to-get-the-current-status-of-set-x?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa # https://stackoverflow.com/questions/14564746/in-bash-how-to-get-the-current-status-of-set-x?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
using_e=${-//[^e]/} ORIG_OPTS=$-
set +e set +ex
[ "$(suppress bad_cmd)" == "$(printf "Running bad_cmd\nbad")" ] || ingest "suppress bad_cmd" [ "$(suppress bad_cmd)" == "$(printf "Running bad_cmd\nbad")" ] \
[ "$(suppress good_cmd)" == "Running good_cmd" ] || ingest "suppress good_cmd" || ingest "suppress bad_cmd"
[ "$(suppress bad_mid_cmd)" == "Running bad_mid_cmd" ] || ingest "suppress bad_mid_cmd" [ "$(suppress good_cmd)" == "Running good_cmd" ] \
if [ -n "$using_e" ]; then set -e; fi || ingest "suppress good_cmd"
[ "$(suppress bad_mid_cmd)" == "Running bad_mid_cmd" ] \
|| ingest "suppress bad_mid_cmd"
[ "$(set -e; suppress bad_cmd)" == "$(printf "Running bad_cmd\nbad")" ] \
|| ingest "suppress bad_cmd set -e"
[ "$(set -e; suppress good_cmd)" == "Running good_cmd" ] || \
ingest "suppress good_cmd set -e"
expected="$(printf "Running bad_mid_cmd\nok for now")"
[ "$(set -e; suppress bad_mid_cmd)" == "$expected" ] \
|| ingest "suppress bad_mid_cmd set -e"
# Reset options
set_opts $ORIG_OPTS
# On Linux docker containers in travis, can only be x86_64 or i686 # On Linux docker containers in travis, can only be x86_64 or i686
[ "$(get_platform)" == x86_64 ] || [ "$(get_platform)" == i686 ] || exit 1 [ "$(get_platform)" == x86_64 ] || [ "$(get_platform)" == i686 ] || exit 1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment