diff --git a/README.adoc b/README.adoc index 98fa737..84f847e 100644 --- a/README.adoc +++ b/README.adoc @@ -206,6 +206,7 @@ Running tests in tests/test_core.sh Running test_fake_transmits_params_to_fake_code ... SUCCESS Running test_fake_transmits_params_to_fake_code_as_array ... SUCCESS Running test_should_pretty_format_even_when_LANG_is_unset ... SUCCESS + Running test_should_pretty_format_even_with_pipefail_set ... SUCCESS Overall result: SUCCESS ``` @@ -315,7 +316,8 @@ ok - test_fake_exports_faked_in_subshells ok - test_fake_transmits_params_to_fake_code ok - test_fake_transmits_params_to_fake_code_as_array ok - test_should_pretty_format_even_when_LANG_is_unset -1..30 +ok - test_should_pretty_format_even_with_pipefail_set +1..31 ``` == How to write tests diff --git a/bash_unit b/bash_unit index 9318a02..e24f406 100755 --- a/bash_unit +++ b/bash_unit @@ -357,8 +357,8 @@ pretty_format() { if $term_utf8 then echo -en " $pretty_symbol " - else - [[ -n "$alt_symbol" ]] && echo -en " $alt_symbol " + elif [[ -n "$alt_symbol" ]]; then + echo -en " $alt_symbol " fi ) | color "$color" } diff --git a/tests/test_core.sh b/tests/test_core.sh index c5fcede..02bd596 100644 --- a/tests/test_core.sh +++ b/tests/test_core.sh @@ -225,6 +225,15 @@ test_should_pretty_format_even_when_LANG_is_unset() { assert "echo foo | pretty_format GREEN I" } +test_should_pretty_format_even_with_pipefail_set() { + # pretty_success must not fail when alt_symbol is empty with pipefail set. + ( + set -o pipefail + unset LANG + assert "echo foo | pretty_success" + ) +} + if [[ "${STICK_TO_CWD:-}" != true ]] then # do not test for cwd if STICK_TO_CWD is true