chiark / gitweb /
Test suite: Allow for t-stunt to override Perl modules
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 30 May 2015 12:50:36 +0000 (13:50 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 31 May 2015 11:21:36 +0000 (12:21 +0100)
tests/lib

index 1a9b042..5adcf0b 100644 (file)
--- a/tests/lib
+++ b/tests/lib
@@ -323,17 +323,28 @@ t-822-field () {
        ' <$file
 }
 
+t-stunt-envvar () {
+       local var=$1
+       local tstunt=$2
+       eval '
+               case "'$var'" in
+               "$tstunt:"*)    ;;
+               *":$tstunt:"*)  ;;
+               *)              '$var'="$tstunt:$'$var'" ;;
+               esac
+       '
+}
+
 t-tstunt () {
        local tstunt=$tmp/tstunt
-       mkdir -p $tstunt
-       case "$PATH" in
-       "$tstunt:"*)    ;;
-       *":$tstunt:"*)  ;;
-       *)              PATH="$tstunt:$PATH" ;;
-       esac
+       t-stunt-envvar PATH $tstunt
+       t-stunt-envvar PERLLIB $tstunt
        local f
        for f in "$@"; do
-               ln -sf "$troot/tstunt/$f" "$tstunt"/.
+               f="./$f"
+               local d="$tstunt/${f%/*}"
+               mkdir -p $d
+               ln -sf "$troot/tstunt/$f" "$d"/.
        done
 }