X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=tests%2Flib.sh;h=3427b5608fc36cdf7dca0824fbca4b4f97979f73;hb=ca12529c8f3880c008212e97cf6b4b7d6981dec8;hp=b1c8bc0276e22ac23215726fdb086e307ea990bb;hpb=04ac66863a96d0c80bd00cc02bc3ab1e6aa8a620;p=coloredstderr%2Fcoloredstderr.git diff --git a/tests/lib.sh b/tests/lib.sh index b1c8bc0..3427b56 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -40,6 +40,9 @@ fi LC_ALL=C unset LANGUAGE +# Set default COLORED_STDERR_FDS value. +fds=2, + die() { echo "$@" >&2 @@ -75,7 +78,7 @@ run_test() { ( # Standard setup. LD_PRELOAD="$library" - COLORED_STDERR_FDS=2, + COLORED_STDERR_FDS="$fds" export LD_PRELOAD export COLORED_STDERR_FDS @@ -85,7 +88,7 @@ run_test() { export COLORED_STDERR_PRE export COLORED_STDERR_POST # And force writes to a file (unless we are testing the force). - if test "x$force_write" != x; then + if test -n "$force_write"; then COLORED_STDERR_FORCE_WRITE=1 export COLORED_STDERR_FORCE_WRITE fi @@ -101,17 +104,30 @@ run_test() { test_script() { testcase="$1" + expected="$2" + # shift || true is not enough for dash. + test $# -ge 2 && shift shift - run_test "$srcdir/$testcase" "$srcdir/$testcase.expected" "$@" + + if test -z "$expected"; then + expected="$testcase" + fi + run_test "$srcdir/$testcase" "$srcdir/$expected.expected" "$@" } test_script_subshell() { - test_script "$1" bash -c 'bash $1' '' + test_script "$1" "$2" bash -c 'bash $1' '' } test_program() { testcase="$1" + expected="$2" + test $# -ge 2 && shift shift - run_test "$builddir/$testcase" "$srcdir/$testcase.expected" "$@" + + if test -z "$expected"; then + expected="$testcase" + fi + run_test "$builddir/$testcase" "$srcdir/$expected.expected" "$@" } test_program_subshell() { - test_program "$1" sh -c '$1' '' + test_program "$1" "$2" sh -c '$1' '' }