automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FYI] {micro} tests: only activate 'unset' alias if required


From: Stefano Lattarini
Subject: [FYI] {micro} tests: only activate 'unset' alias if required
Date: Tue, 21 May 2013 17:40:14 +0200

This makes the test logs easier to read for most shells (which do not
actually require that alias).  This is especially important now that
'unset' is used in the new 'run_make()' function, and that function is
likely going to be used more and more in the future.

* t/ax/test-lib.sh (_am_unset, unset): Only define this function and
alias if "unset VAR" returns a non-zero exit status when VAR is already
unset.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 t/ax/test-lib.sh     | 30 ++++++++++++++++++------------
 t/instmany-mans.sh   |  3 ++-
 t/instmany-python.sh |  3 ++-
 t/instmany.sh        |  3 ++-
 4 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/t/ax/test-lib.sh b/t/ax/test-lib.sh
index ee83dcf..aa015d6 100644
--- a/t/ax/test-lib.sh
+++ b/t/ax/test-lib.sh
@@ -105,18 +105,24 @@ alias exit=_am_exit
 # "unset VAR" returns a non-zero exit status in case the VAR variable
 # is already unset.  This doesn't interact well with our usage of
 # "set -e" in the testsuite.  This function and the alias below help
-# to work around the issue.
-_am_unset ()
-{
-  for _am_v
-  do
-    # Extra escaping (here and below) to ensure we do not call our
-    # 'unset' alias.
-    eval ${_am_v}=dummy && \unset ${_am_v} || exit 1
-  done
-  \unset _am_v
-}
-alias unset=_am_unset
+# to work around the issue.  But be sure to use them only if actually
+# needed.  The repeated unset in the check below cater to the very
+# unlikely case where the '_am_v' variable is set in the environment.
+if unset _am_v && unset _am_v; then
+  : Nothing needs to be done.
+else
+  _am_unset ()
+  {
+    for _am_v
+    do
+      # Extra escaping (here and below) to ensure we do not call our
+      # 'unset' alias.
+      eval ${_am_v}=dummy && \unset ${_am_v} || return 1
+    done
+    \unset _am_v
+  }
+  alias unset=_am_unset
+fi
 
 ## ------------------------------------ ##
 ##  General testsuite shell functions.  ##
diff --git a/t/instmany-mans.sh b/t/instmany-mans.sh
index 35539dd..eb0c9db 100644
--- a/t/instmany-mans.sh
+++ b/t/instmany-mans.sh
@@ -69,7 +69,8 @@ exec $RM "$@"
 exit 1
 END
 
-chmod +x x-bin/rm x-bin/my-install
+# Creative quoting in the next line to please maintainer-check.
+chmod +x x-bin/'rm' x-bin/my-install
 
 cat > setenv.in <<'END'
 orig_INSTALL='@INSTALL@'; export orig_INSTALL
diff --git a/t/instmany-python.sh b/t/instmany-python.sh
index eea5dc4..dfcf14b 100644
--- a/t/instmany-python.sh
+++ b/t/instmany-python.sh
@@ -65,7 +65,8 @@ exec $RM "$@"
 exit 1
 END
 
-chmod +x x-bin/rm x-bin/my-install
+# Creative quoting in the next line to please maintainer-check.
+chmod +x x-bin/'rm' x-bin/my-install
 
 cat > setenv.in <<'END'
 orig_INSTALL='@INSTALL@'; export orig_INSTALL
diff --git a/t/instmany.sh b/t/instmany.sh
index 357b59c..0a479cc 100644
--- a/t/instmany.sh
+++ b/t/instmany.sh
@@ -77,7 +77,8 @@ exec $RM "$@"
 exit 1
 END
 
-chmod +x x-bin/rm x-bin/my-install
+# Creative quoting in the next line to please maintainer-check.
+chmod +x x-bin/'rm' x-bin/my-install
 
 cat > setenv.in <<'END'
 orig_INSTALL='@INSTALL@'; export orig_INSTALL
-- 
1.8.3.rc2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]