about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-10-18 23:09:09 -0700
committerEric Wong <normalperson@yhbt.net>2009-10-18 23:09:09 -0700
commitdbb2e039fac19d9b74075fd79cddade534cafeca (patch)
treee17398443ea9fdac9aa239a7ea577ed7de6f6f14
parent9922b5e683e86c6df48931ee90da1c5e6ad419ef (diff)
downloadrainbows-dbb2e039fac19d9b74075fd79cddade534cafeca.tar.gz
Instead of using completely random names, we'll use
predictable ones since we already depend on them for
exit codes and such.  This drops our ability to run
the same test for the same version of Ruby in the
same working tree, but that's an unlikely scenario.

While we're at it, avoid remove tempfiles if a test
failed.  This should make debugging easier.
-rw-r--r--t/GNUmakefile2
-rw-r--r--t/lib-reopen-logs.sh2
-rwxr-xr-xt/test-lib.sh28
3 files changed, 25 insertions, 7 deletions
diff --git a/t/GNUmakefile b/t/GNUmakefile
index 993aa35..552f9d0 100644
--- a/t/GNUmakefile
+++ b/t/GNUmakefile
@@ -14,7 +14,7 @@ ifeq ($(RUBYLIB),)
 else
   RUBYLIB := $(rainbows_lib):$(RUBYLIB)
 endif
-export RUBYLIB
+export RUBYLIB RUBY_VERSION
 
 T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
 
diff --git a/t/lib-reopen-logs.sh b/t/lib-reopen-logs.sh
index 1bfa3a0..813f204 100644
--- a/t/lib-reopen-logs.sh
+++ b/t/lib-reopen-logs.sh
@@ -25,7 +25,7 @@ do
 done
 check_stderr
 
-rm $r_rot
+rm -f $r_rot
 mv $r_err $r_rot
 
 kill -USR1 $(cat $pid)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index be2dce2..86476e0 100755
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -27,8 +27,10 @@ then
         esac
 fi
 
+ruby="${ruby-'ruby'}"
+RUBY_VERSION=${RUBY_VERSION-$($ruby -e 'puts RUBY_VERSION')}
+t_pfx=$PWD/trash/$T-$RUBY_VERSION
 set -u
-ruby="${ruby-ruby}"
 
 # ensure a sane environment
 TZ=UTC LC_ALL=C LANG=C
@@ -40,8 +42,22 @@ die () {
         exit 1
 }
 
-_TEST_RM_LIST=""
-trap 'rm -f $_TEST_RM_LIST' 0
+_test_on_exit () {
+        code=$?
+        case $code in
+        0)
+                echo "ok $T"
+                rm -f $_TEST_OK_RM_LIST
+        ;;
+        *) echo "not ok $T" ;;
+        esac
+        rm -f $_TEST_RM_LIST
+        exit $code
+}
+
+_TEST_RM_LIST=
+_TEST_OK_RM_LIST=
+trap _test_on_exit EXIT
 PATH=$PWD/bin:$PATH
 export PATH
 
@@ -73,14 +89,16 @@ rtmpfiles () {
         for id in "$@"
         do
                 name=$id
-                _tmp=$(mktemp -t rainbows.$$.$id.XXXXXXXX)
+                _tmp=$t_pfx.$id
+                > $_tmp
                 eval "$id=$_tmp"
-                _TEST_RM_LIST="$_TEST_RM_LIST $_tmp"
+                _TEST_OK_RM_LIST="$_TEST_OK_RM_LIST $_tmp"
 
                 case $name in
                 *fifo)
                         rm -f $_tmp
                         mkfifo $_tmp
+                        _TEST_RM_LIST="$_TEST_RM_LIST $_tmp"
                         ;;
                 esac
         done