]> ruderich.org/simon Gitweb - coloredstderr/coloredstderr.git/blobdiff - tests/lib.sh
Overwrite tracked file descriptors when exporting COLORED_STDERR_FDS.
[coloredstderr/coloredstderr.git] / tests / lib.sh
index 27653f760908487ae64d793092daf4d02db00f03..2f2c736711fc787fb74ca066aac4d3afb68b4cc6 100644 (file)
@@ -40,7 +40,10 @@ fi
 LC_ALL=C
 unset LANGUAGE
 
-# Set default COLORED_STDERR_FDS value.
+# Clear user defined variables.
+unset COLORED_STDERR_FDS
+unset COLORED_STDERR_FORCE_WRITE
+# Set default COLORED_STDERR_PRIVATE_FDS value.
 fds=2,
 
 
@@ -78,9 +81,9 @@ run_test() {
     (
         # Standard setup.
         LD_PRELOAD="$library"
-        COLORED_STDERR_FDS="$fds"
+        COLORED_STDERR_PRIVATE_FDS="$fds"
         export LD_PRELOAD
-        export COLORED_STDERR_FDS
+        export COLORED_STDERR_PRIVATE_FDS
 
         # Change pre/post strings for simpler testing.
         COLORED_STDERR_PRE='>STDERR>'
@@ -88,7 +91,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
@@ -105,7 +108,9 @@ run_test() {
 test_script() {
     testcase="$1"
     expected="$2"
-    shift; shift || true
+    # shift || true is not enough for dash.
+    test $# -ge 2 && shift
+    shift
 
     if test -z "$expected"; then
         expected="$testcase"
@@ -118,7 +123,8 @@ test_script_subshell() {
 test_program() {
     testcase="$1"
     expected="$2"
-    shift; shift || true
+    test $# -ge 2 && shift
+    shift
 
     if test -z "$expected"; then
         expected="$testcase"