diff --git a/shunit2_misc_test.sh b/shunit2_misc_test.sh index 12cc2d4..c82aa8f 100755 --- a/shunit2_misc_test.sh +++ b/shunit2_misc_test.sh @@ -3,7 +3,7 @@ # # shUnit2 unit tests of miscellaneous things # -# Copyright 2008-2021 Kate Ward. All Rights Reserved. +# Copyright 2008-2023 Kate Ward. All Rights Reserved. # Released under the Apache 2.0 license. # http://www.apache.org/licenses/LICENSE-2.0 # @@ -269,6 +269,31 @@ mock_tput() { return 1 } +# Note: the test script is prefixed with '#' chars so that shUnit2 does not +# incorrectly interpret the embedded functions as real functions. +testPipefail() { + unittestF="${SHUNIT_TMPDIR}/unittest" + sed 's/^#//' >"${unittestF}" <"${stdoutF}" 2>"${stderrF}" ); then + fail 'expected a zero exit value' + fi + if ! grep '^Ran [0-9]* test' "${stdoutF}" >/dev/null; then + fail 'test count message was not generated' + fi +} + setUp() { for f in "${stdoutF}" "${stderrF}"; do cp /dev/null "${f}"