chiark / gitweb /
test suite: Generalise DGIT_TEST_REAL_<FOO> handling
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Jan 2017 13:40:14 +0000 (13:40 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Jan 2017 20:10:51 +0000 (20:10 +0000)
No overall functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
tests/lib

index 5d4560f..3e3aa57 100644 (file)
@@ -1,6 +1,7 @@
 dgit (2.17~) unstable; urgency=medium
 
-  * 
+  Test suite:
+  * Internal improvements.
 
  --
 
index 50d614e..993ec36 100644 (file)
--- a/tests/lib
+++ b/tests/lib
@@ -789,12 +789,41 @@ t-stunt-envvar () {
        '
 }
 
+t-tstunt--save-real () {
+       local f="$1"
+       case "$f" in
+       */*) return ;;
+       esac
+
+       local rc
+       local real
+       set +e
+       real=$(type -p "$f")
+       rc=$?
+       set -e
+
+       case $rc in
+       1)      return ;;
+       0)      ;;
+       *)      fail "did not find $f on PATH $PATH" ;;
+       esac
+
+       local varname=${f//[^_0-9a-zA-Z]/_}
+       varname=DGIT_TEST_REAL_${varname^^}
+
+       eval "
+               : \${$varname:=\$real}
+               export $varname
+       "
+}
+
 t-tstunt () {
        local tstunt=$tmp/tstunt
        t-stunt-envvar PATH $tstunt
        t-stunt-envvar PERLLIB $tstunt
        local f
        for f in "$@"; do
+               t-tstunt--save-real $f
                f="./$f"
                local d="$tstunt/${f%/*}"
                mkdir -p $d
@@ -811,8 +840,6 @@ t-tstunt-lintian () {
 }
 
 t-tstunt-debuild () {
-       : ${DGIT_TEST_REAL_DEBUILD:=$(type -p debuild)}
-       export DGIT_TEST_REAL_DEBUILD
        t-tstunt debuild
 }