diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2020-04-29 11:34:29 +0200 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2020-04-29 11:52:51 +0200 |
commit | fe58973929143af72662078ad6ff1d6a4ea66222 (patch) | |
tree | 063bf78ad50ebae948699d877b8547a133cd7029 | |
parent | 864dd863bf59d3182fc98fcf353dd730801af261 (diff) | |
download | mtest-fe58973929143af72662078ad6ff1d6a4ea66222.tar.gz mtest-fe58973929143af72662078ad6ff1d6a4ea66222.tar.bz2 mtest-fe58973929143af72662078ad6ff1d6a4ea66222.zip |
mtest.sh: redirect evaluated output to stderr
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 <michal.lyszczek@bofc.pl>
-rwxr-xr-x | mtest.sh | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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 |