From fe58973929143af72662078ad6ff1d6a4ea66222 Mon Sep 17 00:00:00 2001 From: Michał Łyszczek Date: Wed, 29 Apr 2020 11:34:29 +0200 Subject: mtest.sh: redirect evaluated output to stderr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Output of test expression and asserts should go to stderr, and only test results should be printed to stdout. This allows doing ./tests.sh >results 2>errors This might be usefull when tests prints tons of diagnostic messages and test results are lost within output. Also, it helps parser to quickly get info about ok/nok tests. Signed-off-by: Michał Łyszczek --- mtest.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mtest.sh b/mtest.sh index 5f3d685..a87b753 100755 --- a/mtest.sh +++ b/mtest.sh @@ -137,8 +137,8 @@ mt_fail() err_msg="$2" fi mt_total_checks=$(( mt_total_checks + 1 )) - if ! eval $1; then - echo "# assert $mt_current_test, '$err_msg'" + if ! eval $1 >&2; then + echo "# assert $mt_current_test, '$err_msg'" >&2 mt_test_status=1 mt_checks_failed=$(( mt_checks_failed + 1 )) fi @@ -156,8 +156,8 @@ mt_fail() mt_dfail() { mt_total_checks=$(( mt_total_checks + 1 )) - if ! $@; then - echo "# assert $mt_current_test, '$@'" + if ! $@ >&2; then + echo "# assert $mt_current_test, '$@'" >&2 mt_test_status=1 mt_checks_failed=$(( mt_checks_failed + 1 )) fi -- cgit v1.2.3-8-gadcc