diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-08 00:43:24 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-08 00:43:24 -0700 |
commit | ee703a7af485ecdd2b8c96b0ad87f10d6b71a1fc (patch) | |
tree | 5a4b57dad27a9b19ee95f85fa87fcdb71e85a323 /t/test-lib.sh | |
parent | be9e098dc8945e5abddc9a80fc38ce29fc813fc4 (diff) | |
download | rainbows-ee703a7af485ecdd2b8c96b0ad87f10d6b71a1fc.tar.gz |
Since we rely heavily on temporary files in tests, make sure management of them is easy and reliable.
Diffstat (limited to 't/test-lib.sh')
-rw-r--r-- | t/test-lib.sh | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh index 5551378..c8e069d 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -15,8 +15,8 @@ die () { exit 1 } -TEST_RM_LIST="" -trap 'rm -f $TEST_RM_LIST' 0 +_TEST_RM_LIST="" +trap 'rm -f $_TEST_RM_LIST' 0 PATH=$PWD/bin:$PATH export PATH @@ -39,3 +39,14 @@ require_revactor () { exit 0 fi } + +# given a list of variable names, create temporary files and assign +# the pathnames to those variables +rtmpfiles () { + for id in "$@" + do + _tmp=$(mktemp -t rainbows.$$.$id.XXXXXXXX) + eval "$id=$_tmp" + _TEST_RM_LIST="$_TEST_RM_LIST $_tmp" + done +} |